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.
3588 lines
288 KiB
C#
3588 lines
288 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.Models.MonthDataSet;
|
|
using DSWeb.MvcShipping.Models.MsRptOpProfitZou;
|
|
using DSWeb.MvcShipping.Models.MsTemplet;
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 业务走势对比图表分析
|
|
/// </summary>
|
|
[JsonRequestBehavior]
|
|
public class MsRptOpProfitCompareController : Controller
|
|
{
|
|
//
|
|
// GET: /MvcShipping/MsRptOpProfit
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
|
|
public ActionResult YearIndex()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
|
|
|
|
//
|
|
// GET: /
|
|
public ActionResult LayShow()
|
|
{
|
|
string id = "";
|
|
string url = "";
|
|
string gid = Request.QueryString["gid"];//模板ID
|
|
string mid = Request.QueryString["mid"];//MODULEID
|
|
//string id = Request.QueryString["id"];//模块ID
|
|
//根据模板gid判断加载的页面templet url
|
|
var list = GetTempletURL(gid, mid, Session["USERID"].ToString(), Session["COMPANYID"].ToString());
|
|
foreach (var listStr in list)
|
|
{
|
|
id += listStr.GID;
|
|
url = listStr.LINKURL;
|
|
}
|
|
Response.Redirect("../MsTemplet/" + url + "?id=" + id + "&cid=" + Session["COMPANYID"].ToString() + "&tid=" + gid + "&t=1&p=1");
|
|
return View();
|
|
}
|
|
#region 查询模板地址
|
|
public static List<MsTempletStructure> GetTempletURL(string gid, string mid, string userid, string companyid)
|
|
{
|
|
List<MsTempletStructure> list = new List<MsTempletStructure>();
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.AppendLine("select distinct B.GID,A.TEMPLETURL ");
|
|
sql.AppendLine("from templet as A ");
|
|
sql.AppendLine("left join user_templet as B on A.TEMPLETID=B.TEMPLETID ");
|
|
sql.AppendLine("where A.TEMPLETID='" + gid + "' and B.PARENTID='" + mid + "' and B.COMPANYID='" + companyid + "' ");
|
|
sql.AppendLine("and A.USERID='" + userid + "'and B.USERID='" + userid + "' ");
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsTempletStructure data = new MsTempletStructure();
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.LINKURL = Convert.ToString(reader["TEMPLETURL"]);
|
|
list.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return list;
|
|
}
|
|
#endregion
|
|
#region 小窗口查询
|
|
public ContentResult DataListForColumn(string condition, string objname, string sumfieldtype)
|
|
{
|
|
//解析condition,objname,sumfieldtype
|
|
string startMonthStr = "";
|
|
string endMonthStr = "";
|
|
switch (condition)
|
|
{
|
|
case "thMonth":
|
|
DateTime dateCondition = DateTime.Now;
|
|
DateTime startMonth = dateCondition.AddDays(1 - dateCondition.Day);//本月月初
|
|
DateTime endMonth = startMonth.AddMonths(1).AddDays(-1);//本月月末
|
|
condition = "B.OPDATE>='" + startMonth + "' AND B.OPDATE<='" + endMonth + "' ";
|
|
startMonthStr = startMonth.ToString();
|
|
endMonthStr = endMonth.ToString();
|
|
break;
|
|
case "thWeek":
|
|
dateCondition = DateTime.Now;
|
|
DateTime startWeek = dateCondition.AddDays(1 - Convert.ToInt32(dateCondition.DayOfWeek.ToString("d")));//本周周一
|
|
DateTime endWeek = startWeek.AddDays(6);//本周周日
|
|
condition = "B.OPDATE>='" + startWeek + "' AND B.OPDATE<='" + endWeek + "' ";
|
|
startMonthStr = startWeek.ToString();
|
|
endMonthStr = endWeek.ToString();
|
|
break;
|
|
case "prMonth":
|
|
dateCondition = DateTime.Now;
|
|
DateTime prStartMonth = dateCondition.AddDays(1 - dateCondition.Day).AddMonths(-1);//上月月初
|
|
DateTime prEndMonth = dateCondition.AddDays(1 - dateCondition.Day).AddDays(-1);//上月月末
|
|
condition = "B.OPDATE>='" + prStartMonth + "' AND B.OPDATE<='" + prEndMonth + "' ";
|
|
startMonthStr = prStartMonth.ToString();
|
|
endMonthStr = prEndMonth.ToString();
|
|
break;
|
|
case "thYear":
|
|
dateCondition = DateTime.Now;
|
|
DateTime startYear = new DateTime(dateCondition.Year, 1, 1);//本年年初
|
|
DateTime endYear = new DateTime(dateCondition.Year, 12, 31);//本年年末
|
|
condition = "B.OPDATE>='" + startYear + "' AND B.OPDATE<='" + endYear + "' ";
|
|
startMonthStr = startYear.ToString();
|
|
endMonthStr = endYear.ToString();
|
|
break;
|
|
case "thYearToPrMonth":
|
|
dateCondition = DateTime.Now;
|
|
DateTime startDateTime = new DateTime(dateCondition.Year, 1, 1);//本年年初
|
|
DateTime endDateTime = dateCondition.AddDays(1 - dateCondition.Day).AddDays(-1);//上月月末
|
|
condition = "B.OPDATE>='" + startDateTime + "' AND B.OPDATE<='" + endDateTime + "' ";
|
|
startMonthStr = startDateTime.ToString();
|
|
endMonthStr = endDateTime.ToString();
|
|
break;
|
|
}
|
|
startMonthStr = Transform(startMonthStr);
|
|
endMonthStr = Transform(endMonthStr);
|
|
switch (objname)
|
|
{
|
|
case "bssource":
|
|
objname = "B.BSSOURCE";
|
|
break;
|
|
case "line":
|
|
objname = "B.LANE";
|
|
break;
|
|
case "sale":
|
|
objname = "B.SALE";
|
|
break;
|
|
case "way":
|
|
objname = "B.BSTYPE";
|
|
break;
|
|
case "customer":
|
|
objname = "B.CUSTOMERNAME";
|
|
break;
|
|
case "carrier":
|
|
objname = "B.CARRIER";
|
|
break;
|
|
}
|
|
switch (sumfieldtype)
|
|
{
|
|
case "profit":
|
|
sumfieldtype = "利润";
|
|
break;
|
|
case "arrearage":
|
|
sumfieldtype = "欠费";
|
|
break;
|
|
case "teu":
|
|
sumfieldtype = "TEU";
|
|
break;
|
|
}
|
|
|
|
var strDa = GetRangDAStr("index", Session["USERID"].ToString(), Session["CODENAME"].ToString(), Session["COMPANYID"].ToString());
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and " + strDa;
|
|
}
|
|
else
|
|
{
|
|
condition = strDa;
|
|
}
|
|
}
|
|
|
|
|
|
var RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
}
|
|
else
|
|
{
|
|
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
if (objname == "ALL")
|
|
{
|
|
strSql.Append("SELECT '合计' AS OBJNAME ");
|
|
}
|
|
else
|
|
strSql.Append("SELECT distinct " + objname + " AS OBJNAME ");
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(",SUM(G.TTLDR-G.TTLCR) AS OBJNUM ");
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(",SUM(G.TTLDR-G.STLTTLDR) AS OBJNUM ");
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(",SUM(B.TEU) AS OBJNUM ");
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(",SUM(B.KGS) AS OBJNUM ");
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(",SUM(B.FEEKGS) AS OBJNUM ");
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" AND " + condition);
|
|
}
|
|
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(" AND (G.TTLDR-G.TTLCR)<>0 ");
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(" AND (G.TTLDR-G.STLTTLDR)<>0 ");
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(" AND (B.TEU)<>0 ");
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(" AND (B.KGS)<>0 ");
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(" AND (B.FEEKGS)<>0 ");
|
|
|
|
if (objname == "ALL")
|
|
{
|
|
|
|
}
|
|
else
|
|
strSql.Append(" GROUP BY " + objname);
|
|
|
|
|
|
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(" order by SUM(G.TTLDR-G.TTLCR) DESC ");
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(" order by SUM(G.TTLDR-G.STLTTLDR) DESC ");
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(" ORDER BY SUM(B.TEU) DESC ");
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(" ORDER BY SUM(B.KGS) DESC ");
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(" ORDER BY SUM(B.FEEKGS) DESC ");
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
var evList = new List<MsMonthSumDataSet>();
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
int i = 0;
|
|
while (reader.Read())
|
|
{
|
|
var evData = new MsMonthSumDataSet();
|
|
evData.OBJNAME = "Z" + Convert.ToString(reader["OBJNAME"]).Replace(" ", "");//
|
|
evData.OBJNUM = i;// Convert.ToDecimal(reader["OBJNUM"]);
|
|
evList.Add(evData);
|
|
i++;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
|
|
/*var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
var json = RptHelper.GetRptJsonResult(0, 2000, dbRptResult, "Result_Set", true);
|
|
json = json.Substring(json.IndexOf("[") - 1);
|
|
json = json.Substring(0, json.Length - 3);
|
|
json = json.Replace("\r", "");
|
|
json = json.Replace("\n", "");
|
|
return new ContentResult() { Content = json };*/
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = evList.Count, data = evList.ToList() });
|
|
/*json = json.Substring(json.IndexOf("[") - 1);
|
|
json = json.Substring(0, json.Length - 3);
|
|
json = json.Replace("\r", "");
|
|
json = json.Replace("\n", "");*/
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
public ContentResult DataListForTable(string condition, string objname, string sumfieldtype)
|
|
{
|
|
//解析condition,objname,sumfieldtype
|
|
string startMonthStr = "";
|
|
string endMonthStr = "";
|
|
switch (condition)
|
|
{
|
|
case "thMonth":
|
|
DateTime dateCondition = DateTime.Now;
|
|
DateTime startMonth = dateCondition.AddDays(1 - dateCondition.Day);//本月月初
|
|
DateTime endMonth = startMonth.AddMonths(1).AddDays(-1);//本月月末
|
|
condition = "B.OPDATE>='" + startMonth + "' AND B.OPDATE<='" + endMonth + "' ";
|
|
startMonthStr = startMonth.ToString();
|
|
endMonthStr = endMonth.ToString();
|
|
break;
|
|
case "thWeek":
|
|
dateCondition = DateTime.Now;
|
|
DateTime startWeek = dateCondition.AddDays(1 - Convert.ToInt32(dateCondition.DayOfWeek.ToString("d")));//本周周一
|
|
DateTime endWeek = startWeek.AddDays(6);//本周周日
|
|
condition = "B.OPDATE>='" + startWeek + "' AND B.OPDATE<='" + endWeek + "' ";
|
|
startMonthStr = startWeek.ToString();
|
|
endMonthStr = endWeek.ToString();
|
|
break;
|
|
case "prMonth":
|
|
dateCondition = DateTime.Now;
|
|
DateTime prStartMonth = dateCondition.AddDays(1 - dateCondition.Day).AddMonths(-1);//上月月初
|
|
DateTime prEndMonth = dateCondition.AddDays(1 - dateCondition.Day).AddDays(-1);//上月月末
|
|
condition = "B.OPDATE>='" + prStartMonth + "' AND B.OPDATE<='" + prEndMonth + "' ";
|
|
startMonthStr = prStartMonth.ToString();
|
|
endMonthStr = prEndMonth.ToString();
|
|
break;
|
|
case "thYear":
|
|
dateCondition = DateTime.Now;
|
|
DateTime startYear = new DateTime(dateCondition.Year, 1, 1);//本年年初
|
|
DateTime endYear = new DateTime(dateCondition.Year, 12, 31);//本年年末
|
|
condition = "B.OPDATE>='" + startYear + "' AND B.OPDATE<='" + endYear + "' ";
|
|
startMonthStr = startYear.ToString();
|
|
endMonthStr = endYear.ToString();
|
|
break;
|
|
case "thYearToPrMonth":
|
|
dateCondition = DateTime.Now;
|
|
DateTime startDateTime = new DateTime(dateCondition.Year, 1, 1);//本年年初
|
|
DateTime endDateTime = dateCondition.AddDays(1 - dateCondition.Day).AddDays(-1);//上月月末
|
|
condition = "B.OPDATE>='" + startDateTime + "' AND B.OPDATE<='" + endDateTime + "' ";
|
|
startMonthStr = startDateTime.ToString();
|
|
endMonthStr = endDateTime.ToString();
|
|
break;
|
|
}
|
|
startMonthStr = Transform(startMonthStr);
|
|
endMonthStr = Transform(endMonthStr);
|
|
switch (objname)
|
|
{
|
|
case "bssource":
|
|
objname = "B.BSSOURCE";
|
|
break;
|
|
case "line":
|
|
objname = "B.LANE";
|
|
break;
|
|
case "sale":
|
|
objname = "B.SALE";
|
|
break;
|
|
case "way":
|
|
objname = "B.BSTYPE";
|
|
break;
|
|
case "customer":
|
|
objname = "B.CUSTOMERNAME";
|
|
break;
|
|
case "carrier":
|
|
objname = "B.CARRIER";
|
|
break;
|
|
}
|
|
switch (sumfieldtype)
|
|
{
|
|
case "profit":
|
|
sumfieldtype = "利润";
|
|
break;
|
|
case "arrearage":
|
|
sumfieldtype = "欠费";
|
|
break;
|
|
case "teu":
|
|
sumfieldtype = "TEU";
|
|
break;
|
|
}
|
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and " + strDa;
|
|
}
|
|
else
|
|
{
|
|
condition = strDa;
|
|
}
|
|
}
|
|
|
|
|
|
var RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
}
|
|
else
|
|
{
|
|
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
}
|
|
|
|
}
|
|
|
|
var monthlist = GetMonthList(startMonthStr, endMonthStr);
|
|
var objlist = GetObjList(condition, objname, sumfieldtype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7) MONTHNAME");
|
|
foreach (var enumValue in objlist)
|
|
{
|
|
|
|
if (objname == "ALL")
|
|
{
|
|
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(",SUM(G.TTLDR-G.TTLCR) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(",SUM(G.TTLDR-G.STLTTLDR) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(",SUM(B.TEU) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(",SUM(B.KGS) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(",SUM(B.FEEKGS) AS Z" + enumValue.MONTHNAME);
|
|
}
|
|
else
|
|
{
|
|
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(",SUM(ISNULL(case when " + objname + "='" + enumValue.MONTHNAME + "' then G.TTLDR-G.TTLCR else 0 end,0)) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(",SUM(ISNULL(case when " + objname + "='" + enumValue.MONTHNAME + "' then G.TTLDR-G.STLTTLDR else 0 end,0)) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(",SUM(ISNULL(case when " + objname + "='" + enumValue.MONTHNAME + "' then B.TEU else 0 end,0)) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(",SUM(ISNULL(case when " + objname + "='" + enumValue.MONTHNAME + "' then B.KGS else 0 end,0)) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(",SUM(ISNULL(case when " + objname + "='" + enumValue.MONTHNAME + "' then B.FEEKGS else 0 end,0)) AS Z" + enumValue.MONTHNAME);
|
|
}
|
|
}
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
if (objname == "ALL")
|
|
{
|
|
strSql.Append(" WHERE 1=1 ");
|
|
}
|
|
else
|
|
strSql.Append(" WHERE 1=1 and "+objname+"<>'' and "+objname+" is not null");
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" AND " + condition);
|
|
}
|
|
|
|
//if (sumfieldtype == "利润")
|
|
// strSql.Append(" AND (G.TTLDR-G.TTLCR)<>0 ");
|
|
//if (sumfieldtype == "欠费")
|
|
// strSql.Append(" AND (G.TTLDR-G.STLTTLDR)<>0 ");
|
|
//if (sumfieldtype == "TEU")
|
|
// strSql.Append(" AND (B.TEU)<>0 ");
|
|
|
|
|
|
strSql.Append(" Group by SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7) ");
|
|
|
|
strSql.Append(" order by SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7) ");
|
|
|
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
paramps_sSQL.DbType = DbType.String;
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
var json = RptHelper.GetRptJsonResult(0, 2000, dbRptResult, "Result_Set", true);
|
|
|
|
|
|
/*var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
var json = RptHelper.GetRptJsonResult(0, 2000, dbRptResult, "Result_Set", true);
|
|
json = json.Substring(json.IndexOf("[") - 1);
|
|
json = json.Substring(0, json.Length - 3);
|
|
json = json.Replace("\r", "");
|
|
json = json.Replace("\n", "");
|
|
return new ContentResult() { Content = json };*/
|
|
//var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = evList.Count, data = evList.ToList() });
|
|
json = json.Substring(json.IndexOf("[") - 1);
|
|
json = json.Substring(0, json.Length - 3);
|
|
json = json.Replace("\r", "");
|
|
json = json.Replace("\n", "");
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
#endregion
|
|
|
|
private string Transform(string monthStr)
|
|
{
|
|
if (monthStr.IndexOf("/") != -1) { monthStr = monthStr.Replace("/", "-"); }
|
|
if (monthStr.IndexOf(" ") != -1) { monthStr = monthStr.Substring(0, monthStr.IndexOf(" ")); }
|
|
if (monthStr.IndexOf(" ") != -1) { monthStr = monthStr.Replace(" ", ""); }
|
|
string[] monthArr = monthStr.Split('-');
|
|
if (monthArr[1].Length == 1) { monthArr[1] = "0" + monthArr[1]; }
|
|
if (monthArr[2].Length == 1) { monthArr[2] = "0" + monthArr[2]; }
|
|
monthStr = monthArr[0] + "-" + monthArr[1] + "-" + monthArr[2];
|
|
return monthStr;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetRangDAStrWeb(string tb, string userid, string usercode, string companyid)
|
|
{
|
|
string str = "";
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
|
|
strSql.Append(" from VW_User_Authority ");
|
|
strSql.Append(" where [NAME]='modProfitCompareRange' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
string visiblerange = "4";
|
|
string operaterange = "4";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
|
|
while (reader.Read())
|
|
{
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
break;
|
|
}
|
|
reader.Close();
|
|
}
|
|
if (visiblerange == "4")
|
|
{
|
|
str = "1=2";
|
|
}
|
|
else if (visiblerange == "3")
|
|
{
|
|
|
|
str = " (A.OP='" + usercode + "' OR A.SALE='" + usercode + "')";
|
|
|
|
}
|
|
else if (visiblerange == "2")
|
|
{
|
|
if (tb == "index")
|
|
{
|
|
var rangeDa = new RangeDA();
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
var userstr = new StringBuilder();
|
|
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
{
|
|
str = "";
|
|
while (reader.Read())
|
|
{
|
|
if (str == "")
|
|
{
|
|
str = " (A.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR A.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
}
|
|
else
|
|
{
|
|
str = str + " or A.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR A.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
};
|
|
}
|
|
str = str + ")";
|
|
reader.Close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
str = " UPPER(A.Corpid)='" + companyid + "'";
|
|
}
|
|
|
|
}
|
|
else if (visiblerange == "1")
|
|
{
|
|
str = " UPPER(A.Corpid)='" + companyid + "'";
|
|
}
|
|
|
|
return str;
|
|
}
|
|
public static string GetRangDAStrTEUWeb(string tb, string userid, string usercode, string companyid)
|
|
{
|
|
string str = "";
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
|
|
strSql.Append(" from VW_User_Authority ");
|
|
strSql.Append(" where [NAME]='modProfitCompareRange' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
string visiblerange = "4";
|
|
string operaterange = "4";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
|
|
while (reader.Read())
|
|
{
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
break;
|
|
}
|
|
reader.Close();
|
|
}
|
|
if (visiblerange == "4")
|
|
{
|
|
str = "1=2";
|
|
}
|
|
else if (visiblerange == "3")
|
|
{
|
|
|
|
str = " (OP='" + usercode + "' OR SALE='" + usercode + "')";
|
|
|
|
}
|
|
else if (visiblerange == "2")
|
|
{
|
|
if (tb == "index")
|
|
{
|
|
var rangeDa = new RangeDA();
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
var userstr = new StringBuilder();
|
|
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
{
|
|
str = "";
|
|
while (reader.Read())
|
|
{
|
|
if (str == "")
|
|
{
|
|
str = " (OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
}
|
|
else
|
|
{
|
|
str = str + " or OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
};
|
|
}
|
|
str = str + ")";
|
|
reader.Close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
str = " UPPER(Corpid)='" + companyid + "'";
|
|
}
|
|
|
|
}
|
|
else if (visiblerange == "1")
|
|
{
|
|
str = " UPPER(Corpid)='" + companyid + "'";
|
|
}
|
|
|
|
return str;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 业务来源 利润
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareSourceGainInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareSourceGainInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareSourceGainInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.RMBCR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where A1.BSSOURCE is not NULL and A1.BSSOURCE<>'' and B1.RMBDR is not NULL and B1.RMBCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A1.BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A1.OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.USDCR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where A2.BSSOURCE is not NULL and A2.BSSOURCE<>'' and B2.USDDR is not NULL and B2.USDCR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A2.BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A2.OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.OTCR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where A4.BSSOURCE is not NULL and A4.BSSOURCE<>'' and B4.OTDR is not NULL and B4.OTCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A4.BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A4.OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.TTLCR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where A3.BSSOURCE is not NULL and A3.BSSOURCE<>'' and B3.TTLDR is not NULL and B3.TTLCR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A3.BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A3.OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where A.BSSOURCE is not NULL and A.BSSOURCE<>'' ");// and A.LANE <> ''
|
|
strSql.AppendLine("and B.TTLDR is not NULL and B.TTLCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A.BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A.OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 业务来源 欠费
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareSourceArrearageInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareSourceArrearageInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareSourceArrearageInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where A1.BSSOURCE is not NULL and A1.BSSOURCE<>'' and B1.RMBDR is not NULL and B1.STLRMBDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A1.BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A1.OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.STLUSDDR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where A2.BSSOURCE is not NULL and A2.BSSOURCE<>'' and B2.USDDR is not NULL and B2.STLUSDDR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A2.BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A2.OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.STLOTDR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where A4.BSSOURCE is not NULL and A4.BSSOURCE<>'' and B4.OTDR is not NULL and B4.STLOTDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
//if (strOP != "" && strOP != "undefined" && strOP != "null") { strSql.AppendLine("and A4.OP='" + strOP + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A4.BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A4.OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.STLTTLDR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where A3.BSSOURCE is not NULL and A3.BSSOURCE<>'' and B3.TTLDR is not NULL and B3.STLTTLDR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A3.BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A3.OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where A.BSSOURCE is not NULL and A.BSSOURCE<>'' ");// and A.LANE <> ''
|
|
strSql.AppendLine("and B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR>0 ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A.BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A.OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 业务来源 TEU
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareSourceTEUInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareSourceTEUInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareSourceTEUInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrTEUWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, ");
|
|
strSql.AppendLine("CUSTOMERNAME, ");
|
|
strSql.AppendLine("CNTRTOTAL, ");
|
|
strSql.AppendLine("PORTDISCHARGE, ");
|
|
strSql.AppendLine("OP, ");
|
|
strSql.AppendLine("SALE, ");
|
|
strSql.AppendLine("BSSOURCE, ");
|
|
strSql.AppendLine("BSTYPE, ");
|
|
strSql.AppendLine("LANE, ");
|
|
strSql.AppendLine("TEU, ");
|
|
strSql.AppendLine("INPUTBY, ");
|
|
strSql.AppendLine("(select SUM(TEU) from v_op_bill ");
|
|
strSql.AppendLine("where BSSOURCE is not NULL and BSSOURCE<>'' ");
|
|
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as TEUAMOUNT ");
|
|
strSql.AppendLine("from v_op_bill ");
|
|
strSql.AppendLine("where BSSOURCE is not NULL and BSSOURCE<>'' ");// and LANE <> ''
|
|
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and BSSOURCE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and OPDATE='" + strParam + "' "); }
|
|
else if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10),TEU ");
|
|
|
|
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"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\",TEUAMOUNT:\"" + Convert.ToString(reader["TEUAMOUNT"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 揽货人 利润
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareSaleGainInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareSaleGainInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareSaleGainInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.RMBCR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where A1.SALE is not NULL and A1.SALE<>'' and B1.RMBDR is not NULL and B1.RMBCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A1.SALE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A1.OPDATE='" + strParam + "' "); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.USDCR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where A2.SALE is not NULL and A2.SALE<>'' and B2.USDDR is not NULL and B2.USDCR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A2.SALE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A2.OPDATE='" + strParam + "' "); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.OTCR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where A4.SALE is not NULL and A4.SALE<>'' and B4.OTDR is not NULL and B4.OTCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A4.SALE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A4.OPDATE='" + strParam + "' "); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.TTLCR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where A3.SALE is not NULL and A3.SALE<>'' and B3.TTLDR is not NULL and B3.TTLCR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A3.SALE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A3.OPDATE='" + strParam + "' "); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where A.SALE is not NULL and A.SALE<>'' ");// and A.LANE <> ''
|
|
strSql.AppendLine("and B.TTLDR is not NULL and B.TTLCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A.SALE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A.OPDATE='" + strParam + "' "); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 揽货人 欠费
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareSaleArrearageInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareSaleArrearageInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareSaleArrearageInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where A1.SALE is not NULL and A1.SALE<>'' and B1.RMBDR is not NULL and B1.STLRMBDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A1.SALE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A1.OPDATE='" + strParam + "' "); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.STLUSDDR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where A2.SALE is not NULL and A2.SALE<>'' and B2.USDDR is not NULL and B2.STLUSDDR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A2.SALE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A2.OPDATE='" + strParam + "' "); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.STLOTDR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where A4.SALE is not NULL and A4.SALE<>'' and B4.OTDR is not NULL and B4.STLOTDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A4.SALE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A4.OPDATE='" + strParam + "' "); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.STLTTLDR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where A3.SALE is not NULL and A3.SALE<>'' and B3.TTLDR is not NULL and B3.STLTTLDR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A3.SALE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A3.OPDATE='" + strParam + "' "); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where A.SALE is not NULL and A.SALE<>'' ");// and A.LANE <> ''
|
|
strSql.AppendLine("and B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR>0 ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A.SALE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A.OPDATE='" + strParam + "' "); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 揽货人 TEU
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareSaleTEUInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareSaleTEUInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareSaleTEUInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrTEUWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, ");
|
|
strSql.AppendLine("CUSTOMERNAME, ");
|
|
strSql.AppendLine("CNTRTOTAL, ");
|
|
strSql.AppendLine("PORTDISCHARGE, ");
|
|
strSql.AppendLine("OP, ");
|
|
strSql.AppendLine("SALE, ");
|
|
strSql.AppendLine("BSSOURCE, ");
|
|
strSql.AppendLine("BSTYPE, ");
|
|
strSql.AppendLine("LANE, ");
|
|
strSql.AppendLine("TEU, ");
|
|
strSql.AppendLine("INPUTBY, ");
|
|
strSql.AppendLine("(select SUM(TEU) from v_op_bill ");
|
|
strSql.AppendLine("where SALE is not NULL and SALE<>'' ");
|
|
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and SALE='" + strParam + "'"); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as TEUAMOUNT ");
|
|
strSql.AppendLine("from v_op_bill ");
|
|
strSql.AppendLine("where SALE is not NULL and SALE<>'' ");// and LANE <> ''
|
|
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and SALE='" + strParam + "'"); }
|
|
else if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10),TEU ");
|
|
|
|
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"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\",TEUAMOUNT:\"" + Convert.ToString(reader["TEUAMOUNT"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 运输方式 利润
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareBsTypeGainInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareBsTypeGainInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareBsTypeGainInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.RMBCR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where A1.BSTYPE is not NULL and A1.BSTYPE<>'' and B1.RMBDR is not NULL and B1.RMBCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A1.BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A1.OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.USDCR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where A2.BSTYPE is not NULL and A2.BSTYPE<>'' and B2.USDDR is not NULL and B2.USDCR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A2.BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A2.OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.OTCR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where A4.BSTYPE is not NULL and A4.BSTYPE<>'' and B4.OTDR is not NULL and B4.OTCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A4.BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A4.OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.TTLCR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where A3.BSTYPE is not NULL and A3.BSTYPE<>'' and B3.TTLDR is not NULL and B3.TTLCR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A3.BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A3.OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where A.BSTYPE is not NULL and A.BSTYPE<>'' ");// and A.LANE <> ''
|
|
strSql.AppendLine("and B.TTLDR is not NULL and B.TTLCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A.BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A.OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 运输方式 欠费
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareBsTypeArrearageInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareBsTypeArrearageInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareBsTypeArrearageInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where A1.BSTYPE is not NULL and A1.BSTYPE<>'' and B1.RMBDR is not NULL and B1.STLRMBDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A1.BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A1.OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.STLUSDDR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where A2.BSTYPE is not NULL and A2.BSTYPE<>'' and B2.USDDR is not NULL and B2.STLUSDDR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A2.BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A2.OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.STLOTDR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where A4.BSTYPE is not NULL and A4.BSTYPE<>'' and B4.OTDR is not NULL and B4.STLOTDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A4.BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A4.OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.STLTTLDR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where A3.BSTYPE is not NULL and A3.BSTYPE<>'' and B3.TTLDR is not NULL and B3.STLTTLDR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A3.BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A3.OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where A.BSTYPE is not NULL and A.BSTYPE<>'' ");// and A.LANE <> ''
|
|
strSql.AppendLine("and B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR>0 ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A.BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A.OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 运输方式 TEU
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareBsTypeTEUInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareBsTypeTEUInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareBsTypeTEUInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrTEUWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, ");
|
|
strSql.AppendLine("CUSTOMERNAME, ");
|
|
strSql.AppendLine("CNTRTOTAL, ");
|
|
strSql.AppendLine("PORTDISCHARGE, ");
|
|
strSql.AppendLine("OP, ");
|
|
strSql.AppendLine("SALE, ");
|
|
strSql.AppendLine("BSSOURCE, ");
|
|
strSql.AppendLine("BSTYPE, ");
|
|
strSql.AppendLine("LANE, ");
|
|
strSql.AppendLine("TEU, ");
|
|
strSql.AppendLine("INPUTBY, ");
|
|
strSql.AppendLine("(select SUM(TEU) from v_op_bill ");
|
|
strSql.AppendLine("where BSTYPE is not NULL and BSTYPE<>'' ");
|
|
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and BSTYPE='" + strParam + "'"); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as TEUAMOUNT ");
|
|
strSql.AppendLine("from v_op_bill ");
|
|
strSql.AppendLine("where BSTYPE is not NULL and BSTYPE<>'' ");// and LANE <> ''
|
|
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and BSTYPE='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and OPDATE='" + strParam + "' "); }
|
|
else if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10),TEU ");
|
|
|
|
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"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\",TEUAMOUNT:\"" + Convert.ToString(reader["TEUAMOUNT"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 委托单位 利润
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareCustomerGainInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareCustomerGainInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareCustomerGainInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.RMBCR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where A1.CUSTOMERNAME is not NULL and A1.CUSTOMERNAME<>'' and B1.RMBDR is not NULL and B1.RMBCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A1.OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.USDCR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where A2.CUSTOMERNAME is not NULL and A2.CUSTOMERNAME<>'' and B2.USDDR is not NULL and B2.USDCR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A2.OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.OTCR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where A4.CUSTOMERNAME is not NULL and A4.CUSTOMERNAME<>'' and B4.OTDR is not NULL and B4.OTCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A4.OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.TTLCR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where A3.CUSTOMERNAME is not NULL and A3.CUSTOMERNAME<>'' and B3.TTLDR is not NULL and B3.TTLCR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A3.OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where A.CUSTOMERNAME is not NULL and A.CUSTOMERNAME<>'' ");// and A.LANE <> ''
|
|
strSql.AppendLine("and B.TTLDR is not NULL and B.TTLCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A.CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A.OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 委托单位 欠费
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareCustomerArrearageInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareCustomerArrearageInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareCustomerArrearageInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where A1.CUSTOMERNAME is not NULL and A1.CUSTOMERNAME<>'' and B1.RMBDR is not NULL and B1.STLRMBDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A1.OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.STLUSDDR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where A2.CUSTOMERNAME is not NULL and A2.CUSTOMERNAME<>'' and B2.USDDR is not NULL and B2.STLUSDDR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A2.OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.STLOTDR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where A4.CUSTOMERNAME is not NULL and A4.CUSTOMERNAME<>'' and B4.OTDR is not NULL and B4.STLOTDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A4.OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.STLTTLDR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where A3.CUSTOMERNAME is not NULL and A3.CUSTOMERNAME<>'' and B3.TTLDR is not NULL and B3.STLTTLDR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A3.OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where A.CUSTOMERNAME is not NULL and A.CUSTOMERNAME<>'' ");// and A.LANE <> ''
|
|
strSql.AppendLine("and B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR>0 ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A.CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A.OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 委托单位 TEU
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareCustomerTEUInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareCustomerTEUInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareCustomerTEUInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrTEUWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, ");
|
|
strSql.AppendLine("CUSTOMERNAME, ");
|
|
strSql.AppendLine("CNTRTOTAL, ");
|
|
strSql.AppendLine("PORTDISCHARGE, ");
|
|
strSql.AppendLine("OP, ");
|
|
strSql.AppendLine("SALE, ");
|
|
strSql.AppendLine("BSSOURCE, ");
|
|
strSql.AppendLine("BSTYPE, ");
|
|
strSql.AppendLine("LANE, ");
|
|
strSql.AppendLine("TEU, ");
|
|
strSql.AppendLine("INPUTBY, ");
|
|
strSql.AppendLine("(select SUM(TEU) from v_op_bill ");
|
|
strSql.AppendLine("where CUSTOMERNAME is not NULL and CUSTOMERNAME<>'' ");
|
|
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as TEUAMOUNT ");
|
|
strSql.AppendLine("from v_op_bill ");
|
|
strSql.AppendLine("where CUSTOMERNAME is not NULL and CUSTOMERNAME<>'' ");// and LANE <> ''
|
|
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and CUSTOMERNAME='" + strParam + "'"); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and OPDATE='" + strParam + "' "); }
|
|
else if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10),TEU ");
|
|
|
|
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"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\",TEUAMOUNT:\"" + Convert.ToString(reader["TEUAMOUNT"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 合计 利润
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareAmountGainInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareAmountGainInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareAmountGainInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.RMBCR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where B1.RMBDR is not NULL and B1.RMBCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.USDCR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where B2.USDDR is not NULL and B2.USDCR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.OTCR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where B4.OTDR is not NULL and B4.OTCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.TTLCR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where B3.TTLDR is not NULL and B3.TTLCR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where ");//A.LANE is not NULL AND A.LANE <> ''
|
|
strSql.AppendLine("B.TTLDR is not NULL and B.TTLCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 合计 欠费
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareAmountArrearageInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareAmountArrearageInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareAmountArrearageInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where B1.RMBDR is not NULL and B1.STLRMBDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.STLUSDDR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where B2.USDDR is not NULL and B2.STLUSDDR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.STLOTDR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where B4.OTDR is not NULL and B4.STLOTDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.STLTTLDR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where B3.TTLDR is not NULL and B3.STLTTLDR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where ");//A.LANE and is not NULL and A.LANE <> ''
|
|
strSql.AppendLine("B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR>0 ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 合计 TEU
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareAmountTEUInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareAmountTEUInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareAmountTEUInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrTEUWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, ");
|
|
strSql.AppendLine("CUSTOMERNAME, ");
|
|
strSql.AppendLine("CNTRTOTAL, ");
|
|
strSql.AppendLine("PORTDISCHARGE, ");
|
|
strSql.AppendLine("OP, ");
|
|
strSql.AppendLine("SALE, ");
|
|
strSql.AppendLine("BSSOURCE, ");
|
|
strSql.AppendLine("BSTYPE, ");
|
|
strSql.AppendLine("LANE, ");
|
|
strSql.AppendLine("TEU, ");
|
|
strSql.AppendLine("INPUTBY, ");
|
|
strSql.AppendLine("(select SUM(TEU) from v_op_bill ");
|
|
strSql.AppendLine("where ");
|
|
strSql.AppendLine("TEU is not NULL and TEU<>'' ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as TEUAMOUNT ");
|
|
strSql.AppendLine("from v_op_bill ");
|
|
strSql.AppendLine("where ");//LANE is not NULL and LANE <> ''
|
|
strSql.AppendLine("TEU is not NULL and TEU<>'' ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10),TEU ");
|
|
|
|
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"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\",TEUAMOUNT:\"" + Convert.ToString(reader["TEUAMOUNT"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 航线 利润
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareLaneGainInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareLaneGainInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareLaneGainInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.RMBCR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where A1.LANE is not NULL and A1.LANE<>'' and B1.RMBDR is not NULL and B1.RMBCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A1.LANE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.USDCR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where A2.LANE is not NULL and A2.LANE<>'' and B2.USDDR is not NULL and B2.USDCR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A2.LANE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.OTCR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where A4.LANE is not NULL and A4.LANE<>'' and B4.OTDR is not NULL and B4.OTCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A4.LANE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.TTLCR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where A3.LANE is not NULL and A3.LANE<>'' and B3.TTLDR is not NULL and B3.TTLCR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A3.LANE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where A.LANE is not NULL and A.LANE<>'' ");// and A.LANE <> ''
|
|
strSql.AppendLine("and B.TTLDR is not NULL and B.TTLCR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A.LANE='" + strParam + "' "); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A.OPDATE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 航线 欠费
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareLaneArrearageInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareLaneArrearageInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareLaneArrearageInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, ");
|
|
strSql.AppendLine("A.CUSTOMERNAME, ");
|
|
strSql.AppendLine("A.CNTRTOTAL, ");
|
|
strSql.AppendLine("A.PORTDISCHARGE, ");
|
|
strSql.AppendLine("A.OP, ");
|
|
strSql.AppendLine("A.SALE, ");
|
|
strSql.AppendLine("A.BSSOURCE, ");
|
|
strSql.AppendLine("A.BSTYPE, ");
|
|
strSql.AppendLine("A.LANE, ");
|
|
|
|
strSql.AppendLine("(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, ");
|
|
//RMB欠费合计
|
|
strSql.AppendLine("(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO ");
|
|
strSql.AppendLine("where A1.LANE is not NULL and A1.LANE<>'' and B1.RMBDR is not NULL and B1.STLRMBDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A1.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A1.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A1.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A1.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A1.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A1.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A1.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A1.LANE='" + strParam + "' "); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A1.OPDATE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A1.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A1.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMRMBAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.USDDR-B.STLUSDDR) AS USDAMOUNT, ");
|
|
//USD欠费合计
|
|
strSql.AppendLine("(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO ");
|
|
strSql.AppendLine("where A2.LANE is not NULL and A2.LANE<>'' and B2.USDDR is not NULL and B2.STLUSDDR is not NULL ");//and A2.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A2.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A2.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A2.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A2.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A2.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A2.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A2.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A2.LANE='" + strParam + "' "); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A2.OPDATE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A2.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A2.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMUSDAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.OTDR-B.STLOTDR) OTAMOUNT, ");
|
|
//OT欠费合计
|
|
strSql.AppendLine("(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO ");
|
|
strSql.AppendLine("where A4.LANE is not NULL and A4.LANE<>'' and B4.OTDR is not NULL and B4.STLOTDR is not NULL ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A4.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A4.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A4.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A4.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A4.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A4.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A4.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A4.LANE='" + strParam + "' "); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A4.OPDATE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A4.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A4.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMOTAMOUNT, ");
|
|
|
|
strSql.AppendLine("(B.TTLDR-B.STLTTLDR) TTLAMOUNT, ");
|
|
//TTL欠费合计
|
|
strSql.AppendLine("(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO ");
|
|
strSql.AppendLine("where A3.LANE is not NULL and A3.LANE<>'' and B3.TTLDR is not NULL and B3.STLTTLDR is not NULL ");//and A3.LANE=''");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A3.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A3.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A3.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A3.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A3.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A3.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A3.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A3.LANE='" + strParam + "' "); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A3.OPDATE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A3.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A3.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as SUMTTLAMOUNT, ");
|
|
|
|
strSql.AppendLine("A.INPUTBY ");
|
|
strSql.AppendLine("from v_op_bill as A ");
|
|
strSql.AppendLine("left join v_op_gain_sum as B on A.BSNO=B.BSNO ");
|
|
strSql.AppendLine("where A.LANE is not NULL and A.LANE<>'' ");// and A.LANE <> ''
|
|
strSql.AppendLine("and B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR>0 ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and A.SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and A.OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and A.LANE='" + strParam + "' "); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and A.OPDATE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and A.LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT ");
|
|
|
|
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"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 航线 TEU
|
|
/// </summary>
|
|
/// <param name="strYear"></param>
|
|
/// <param name="strMonth"></param>
|
|
/// <returns></returns>
|
|
public string GetCompareLaneTEUInfo(string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
string dataList = GetCompareLaneTEUInfoList(Convert.ToString(Session["COMPANYID"]), strOPYear, strOPMonth, strParam, strBSSOURCE, strSALE, strBSTYPE, strCUSTOMERNAME, strLANE, strOPLBNAME, strACCDATEBGN, strACCDATEEND);
|
|
return dataList;
|
|
}
|
|
private string GetCompareLaneTEUInfoList(string companyID, string strOPYear, string strOPMonth, string strParam, string strBSSOURCE, string strSALE, string strBSTYPE, string strCUSTOMERNAME, string strLANE, string strOPLBNAME, string strACCDATEBGN, string strACCDATEEND)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
var strDa = GetRangDAStrTEUWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
strSql.AppendLine("select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, ");
|
|
strSql.AppendLine("CUSTOMERNAME, ");
|
|
strSql.AppendLine("CNTRTOTAL, ");
|
|
strSql.AppendLine("PORTDISCHARGE, ");
|
|
strSql.AppendLine("OP, ");
|
|
strSql.AppendLine("SALE, ");
|
|
strSql.AppendLine("BSSOURCE, ");
|
|
strSql.AppendLine("BSTYPE, ");
|
|
strSql.AppendLine("LANE, ");
|
|
strSql.AppendLine("TEU, ");
|
|
strSql.AppendLine("INPUTBY, ");
|
|
strSql.AppendLine("(select SUM(TEU) from v_op_bill ");
|
|
strSql.AppendLine("where LANE is not NULL and LANE<>'' ");
|
|
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and LANE='" + strParam + "' "); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and OPDATE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
strSql.AppendLine(") as TEUAMOUNT ");
|
|
strSql.AppendLine("from v_op_bill ");
|
|
strSql.AppendLine("where LANE is not NULL and LANE<>'' ");// and LANE <> ''
|
|
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
|
|
if (strOPYear != "" && strOPYear != "undefined" && strOPYear != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strOPYear + "' "); }// SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "'
|
|
if (strOPMonth != "" && strOPMonth != "undefined" && strOPMonth != "null") { strSql.AppendLine("and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strOPMonth + "' "); }
|
|
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and OPDATE>='" + strACCDATEBGN + "'"); }
|
|
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and OPDATE<='" + strACCDATEEND + " 23:59:59'"); }
|
|
if (strCUSTOMERNAME != "" && strCUSTOMERNAME != "undefined" && strCUSTOMERNAME != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMERNAME + "'"); }
|
|
if (strSALE != "" && strSALE != "undefined" && strSALE != "null") { strSql.AppendLine("and SALE='" + strSALE + "'"); }
|
|
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
|
|
if (strOPLBNAME != "" && strOPLBNAME != "undefined" && strOPLBNAME != "null") { strSql.AppendLine("and OPLB='" + strOPLBNAME + "'"); }
|
|
if (strParam != "undefined" && strParam != null && strParam != "null" && strParam != "") { strSql.AppendLine("and LANE='" + strParam + "' "); }
|
|
else if (strParam.IndexOf("/") != -1) { strSql.AppendLine("and OPDATE='" + strParam + "' "); }
|
|
else if (strLANE != "undefined" && strLANE != null && strLANE != "null" && strLANE != "") { strSql.AppendLine("and LANE='" + strLANE + "' "); }
|
|
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
strSql.AppendLine("and " + strDa);
|
|
}
|
|
|
|
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
|
|
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10),TEU ");
|
|
|
|
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"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\",TEUAMOUNT:\"" + Convert.ToString(reader["TEUAMOUNT"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ContentResult SumListData(string condition, string sort, string printstr, string objname, string sumfieldtype, string startmonth, string endmonth)
|
|
{
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and " + strDa;
|
|
}
|
|
else
|
|
{
|
|
condition = strDa;
|
|
}
|
|
}
|
|
|
|
|
|
var RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
}
|
|
else
|
|
{
|
|
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
}
|
|
|
|
}
|
|
|
|
var monthlist = GetMonthList(startmonth, endmonth);
|
|
var objlist = GetObjList(condition, objname, sumfieldtype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7) MONTHNAME");
|
|
foreach (var enumValue in objlist)
|
|
{
|
|
|
|
if (objname == "ALL")
|
|
{
|
|
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(",SUM(G.TTLDR-G.TTLCR) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(",SUM(G.TTLDR-G.STLTTLDR) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.FEEKGS ELSE 0 END) AS Z" + enumValue.MONTHNAME);
|
|
}
|
|
else
|
|
{
|
|
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(",SUM(ISNULL(case when " + objname + "='" + enumValue.MONTHNAME + "' then G.TTLDR-G.TTLCR else 0 end,0)) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(",SUM(ISNULL(case when " + objname + "='" + enumValue.MONTHNAME + "' then G.TTLDR-G.STLTTLDR else 0 end,0)) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(",SUM(ISNULL(case when B.OPTYPE='普通货' AND " + objname + "='" + enumValue.MONTHNAME + "' then B.TEU else 0 end,0)) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(",SUM(ISNULL(case when B.OPTYPE='普通货' AND " + objname + "='" + enumValue.MONTHNAME + "' then B.KGS else 0 end,0)) AS Z" + enumValue.MONTHNAME);
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(",SUM(ISNULL(case when B.OPTYPE='普通货' AND " + objname + "='" + enumValue.MONTHNAME + "' then B.FEEKGS else 0 end,0)) AS Z" + enumValue.MONTHNAME);
|
|
}
|
|
}
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
if (objname == "ALL")
|
|
{
|
|
strSql.Append(" WHERE 1=1 ");
|
|
}
|
|
else
|
|
strSql.Append(" WHERE 1=1 and "+objname+"<>'' and "+objname+" is not null");
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" AND " + condition);
|
|
}
|
|
|
|
//if (sumfieldtype == "利润")
|
|
// strSql.Append(" AND (G.TTLDR-G.TTLCR)<>0 ");
|
|
//if (sumfieldtype == "欠费")
|
|
// strSql.Append(" AND (G.TTLDR-G.STLTTLDR)<>0 ");
|
|
//if (sumfieldtype == "TEU")
|
|
// strSql.Append(" AND (B.TEU)<>0 ");
|
|
|
|
|
|
strSql.Append(" Group by SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7) ");
|
|
|
|
strSql.Append(" order by SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 7) ");
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
{
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = true,
|
|
Message = "完成",
|
|
Data = strSql.ToString()
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
else
|
|
{
|
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
paramps_sSQL.DbType = DbType.String;
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
var json = RptHelper.GetRptJsonResult(0, 2000, dbRptResult, "Result_Set", true);
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetRangDAStr(string tb, string userid, string usercode, string companyid)
|
|
{
|
|
string str = "";
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL ");
|
|
strSql.Append(" from VW_User_Authority ");
|
|
strSql.Append(" where [NAME]='modProfitCompareRange' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
string visiblerange = "4";
|
|
string operaterange = "4";
|
|
string AUTHORITYID = "";
|
|
string VSSQL = "";
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
|
|
while (reader.Read())
|
|
{
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
|
|
VSSQL = Convert.ToString(reader["VSSQL"]);
|
|
break;
|
|
}
|
|
reader.Close();
|
|
}
|
|
if (visiblerange == "4")
|
|
{
|
|
str = "1=2";
|
|
}
|
|
else if (visiblerange == "3")
|
|
{
|
|
|
|
str = " (B.OP='" + usercode + "' OR B.SALE='" + usercode + "')";
|
|
|
|
}
|
|
else if (visiblerange == "2")
|
|
{
|
|
if (tb == "index")
|
|
{
|
|
var rangeDa = new RangeDA();
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
var userstr = new StringBuilder();
|
|
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
{
|
|
str = "";
|
|
while (reader.Read())
|
|
{
|
|
if (str == "")
|
|
{
|
|
str = " (B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
}
|
|
else
|
|
{
|
|
str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
};
|
|
}
|
|
str =str+ ")";
|
|
reader.Close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
str = " UPPER(B.Corpid)='" + companyid + "'";
|
|
}
|
|
|
|
}
|
|
else if (visiblerange == "5")
|
|
{
|
|
|
|
var userstr = new StringBuilder();
|
|
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
{
|
|
str = "";
|
|
while (reader.Read())
|
|
{
|
|
if (str == "")
|
|
{
|
|
str = " (B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "' ";
|
|
}
|
|
else
|
|
{
|
|
str = str + " or B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or B.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "'";
|
|
};
|
|
}
|
|
str = str + ")";
|
|
reader.Close();
|
|
}
|
|
|
|
|
|
}
|
|
else if (visiblerange == "6")
|
|
{
|
|
|
|
|
|
str = " EXISTS (select 1 from user_authority_range_op P left join [user] u on (u.GID=P.OPID) where (B.OP=U.SHOWNAME OR B.SALE=U.SHOWNAME OR B.CUSTSERVICE=U.SHOWNAME) AND P.userid='" + userid + "' and P.AUTHORITYID='" + AUTHORITYID + "' and P.VISIBLERANGE=1) ";
|
|
|
|
|
|
}
|
|
else if (visiblerange == "1")
|
|
{
|
|
str = " UPPER(B.Corpid)='" + companyid + "'";
|
|
}
|
|
VSSQL = VSSQL.Trim();
|
|
if (!string.IsNullOrEmpty(VSSQL))
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(str))
|
|
{
|
|
str = str + " and (" + VSSQL + ") ";
|
|
}
|
|
else
|
|
{
|
|
str = " (" + VSSQL + ") ";
|
|
}
|
|
|
|
}
|
|
return str;
|
|
}
|
|
|
|
#region 月度数
|
|
|
|
public ContentResult GetMonthsData(string startmonth, string endmonth)
|
|
{
|
|
|
|
var dataList = GetMonthList(startmonth, endmonth);
|
|
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
|
|
}
|
|
|
|
static public List<MonthDataSet> GetMonthList(string startmonth, string endmonth)
|
|
{
|
|
var startdate = startmonth.Split('-');
|
|
var enddate = endmonth.Split('-');
|
|
|
|
int monthstart = Convert.ToInt16(startdate[0]) * 12 + Convert.ToInt16(startdate[1]);
|
|
int monthend = Convert.ToInt16(enddate[0]) * 12 + Convert.ToInt16(enddate[1]);
|
|
|
|
var betweenmonth = monthend - monthstart + 1;
|
|
|
|
DateTime dt = DateTime.ParseExact(startmonth, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);
|
|
|
|
var evList = new List<MonthDataSet>();
|
|
var month = "";
|
|
|
|
for (int i = 0; i < betweenmonth; i++)
|
|
{
|
|
var evData = new MonthDataSet();
|
|
evData.MONTHNAME = dt.ToString("yyyy年MM月");
|
|
evData.MONTHNO = i;
|
|
month = dt.Month.ToString();
|
|
if (month.Length == 1) month = "0" + month;
|
|
evData.MONTHFIELDNAME = dt.Year.ToString() + "/" + month;
|
|
evList.Add(evData);
|
|
dt = dt.AddMonths(1);
|
|
}
|
|
|
|
|
|
return evList;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
public ContentResult GetObjListData(string condition,string objname,string sumfieldtype,string topnum="10")
|
|
{
|
|
|
|
var dataList = GetObjList(condition, objname, sumfieldtype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), topnum);
|
|
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
|
|
}
|
|
|
|
|
|
static public List<MonthDataSet> GetObjList(string condition, string objname, string sumfieldtype, string userid, string username, string companyid, string topnum = "10")
|
|
{
|
|
var strDa = GetRangDAStr("index",userid,username,companyid);
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and " + strDa;
|
|
}
|
|
else
|
|
{
|
|
condition = strDa;
|
|
}
|
|
}
|
|
|
|
|
|
var RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
}
|
|
else
|
|
{
|
|
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
if (objname == "ALL") {
|
|
strSql.Append("SELECT '合计' AS OBJNAME ");
|
|
} else
|
|
strSql.Append("SELECT distinct " + objname + " AS OBJNAME ");
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(",SUM(G.TTLDR-G.TTLCR) ");
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(",SUM(G.TTLDR-G.STLTTLDR) ");
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) ");
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) ");
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.FEEKGS ELSE 0 END) ");
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" AND " + condition);
|
|
}
|
|
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(" AND (G.TTLDR-G.TTLCR)<>0 ");
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(" AND (G.TTLDR-G.STLTTLDR)<>0 ");
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(" AND (B.TEU)<>0 ");
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(" AND (B.KGS)<>0 ");
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(" AND (B.FEEKGS)<>0 ");
|
|
|
|
if (objname == "ALL")
|
|
{
|
|
|
|
}
|
|
else
|
|
strSql.Append(" GROUP BY " + objname);
|
|
|
|
|
|
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(" order by SUM(G.TTLDR-G.TTLCR) DESC ");
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(" order by SUM(G.TTLDR-G.STLTTLDR) DESC ");
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(" ORDER BY SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) DESC ");
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(" ORDER BY SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) DESC ");
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(" ORDER BY SUM(CASE WHEN B.OPTYPE='普通货' THEN B.FEEKGS ELSE 0 END) DESC ");
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
var evList = new List<MonthDataSet>();
|
|
var topcount = Convert.ToInt32(topnum) + 1;
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
var i = 1;
|
|
while (reader.Read() && i< topcount)
|
|
{
|
|
var evData = new MonthDataSet();
|
|
evData.MONTHNAME = Convert.ToString(reader["OBJNAME"]).Replace(" ","");
|
|
evData.MONTHNO = i;
|
|
evList.Add(evData);
|
|
i = i + 1;
|
|
|
|
}
|
|
reader.Close();
|
|
}
|
|
return evList;
|
|
|
|
}
|
|
|
|
|
|
#region 年度对比
|
|
|
|
public ContentResult SumYearListData(string condition, string sort, string printstr, string objname, string sumfieldtype, string startyear, string endyear)
|
|
{
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and " + strDa;
|
|
}
|
|
else
|
|
{
|
|
condition = strDa;
|
|
}
|
|
}
|
|
|
|
|
|
var RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
}
|
|
else
|
|
{
|
|
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) ";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
var yearsqlstr = "";
|
|
if (objname == "会计期间")
|
|
{
|
|
strSql.Append("SELECT SUBSTRING(B.ACCDATE, 6, 2) MONTHNAME");
|
|
yearsqlstr = " SUBSTRING(B.ACCDATE, 1, 4) ";
|
|
}
|
|
else
|
|
{
|
|
strSql.Append("SELECT SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 6, 2) MONTHNAME");
|
|
yearsqlstr = " SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 1, 4) ";
|
|
|
|
}
|
|
|
|
for (int i = Convert.ToInt32(startyear); i <= Convert.ToInt32(endyear); i++)
|
|
{
|
|
|
|
if (sumfieldtype == "利润")
|
|
strSql.Append(",SUM(ISNULL(case when " + yearsqlstr + "='" + i.ToString() + "' then G.TTLDR-G.TTLCR else 0 end,0)) AS Z" + i.ToString());
|
|
if (sumfieldtype == "欠费")
|
|
strSql.Append(",SUM(ISNULL(case when " + yearsqlstr + "='" + i.ToString() + "' then G.TTLDR-G.STLTTLDR else 0 end,0)) AS Z" + i.ToString());
|
|
if (sumfieldtype == "TEU")
|
|
strSql.Append(",SUM(ISNULL(case when B.OPTYPE='普通货' AND " + yearsqlstr + "='" + i.ToString() + "' then B.TEU else 0 end,0)) AS Z" + i.ToString());
|
|
if (sumfieldtype == "毛重")
|
|
strSql.Append(",SUM(ISNULL(case when B.OPTYPE='普通货' AND " + yearsqlstr + "='" + i.ToString() + "' then B.KGS else 0 end,0)) AS Z" + i.ToString());
|
|
if (sumfieldtype == "计费重")
|
|
strSql.Append(",SUM(ISNULL(case when B.OPTYPE='普通货' AND " + yearsqlstr + "='" + i.ToString() + "' then B.FEEKGS else 0 end,0)) AS Z" + i.ToString());
|
|
}
|
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
if (objname == "会计期间")
|
|
{
|
|
strSql.Append(" WHERE 1=1 and B.ACCDATE>='"+startyear+"-01' AND B.ACCDATE<='"+endyear+"-12'");
|
|
}
|
|
else {
|
|
strSql.Append(" WHERE 1=1 and B.OPDATE>='" + startyear + "-01-01' AND B.OPDATE<='" + endyear + "-12-31'");
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" AND " + condition);
|
|
}
|
|
|
|
|
|
if (objname == "会计期间")
|
|
{
|
|
strSql.Append("Group by SUBSTRING(B.ACCDATE, 6, 2) ");
|
|
strSql.Append("order by SUBSTRING(B.ACCDATE, 6, 2) ");
|
|
}
|
|
else
|
|
{
|
|
strSql.Append("Group by SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 6, 2)");
|
|
strSql.Append("order by SUBSTRING(CONVERT(char(15), B.OPDATE, 111), 6, 2)");
|
|
}
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
{
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = true,
|
|
Message = "完成",
|
|
Data = strSql.ToString()
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
else
|
|
{
|
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
paramps_sSQL.DbType = DbType.String;
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
var json = RptHelper.GetRptJsonResult(0, 2000, dbRptResult, "Result_Set", true);
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 参照部分
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|