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.
DS7/DSWeb/Areas/MvcShipping/Controllers/MsRptOpProfitZouController.cs

260 lines
15 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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.Areas.MvcShipping.DAL.MsRptOpProfitZouDAL;
namespace DSWeb.MvcShipping.Controllers
{
/// <summary>
/// 业务走势图表分析
/// </summary>
[JsonRequestBehavior]
public class MsRptOpProfitZouController : Controller
{
//
// GET: /MvcShipping/MsRptOpProfit
public ActionResult Index()
{
return View();
}
//
// GET/RptMng/MsRptPcHeadQry/QryData
/// <summary>
/// 利润
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareGainInfo(string strYear, string strMonth, string strOPLB, string strBSTYPE, string strSALES, string strOP, string strCUSTOMER, string strBSSOURCE, string strBSSOURCEDETAIL, string strLane, string strACCDATEBGN, string strACCDATEEND)
{
string dataList = GetCompareGainInfoList(Convert.ToString(Session["COMPANYID"]), strYear, strMonth, strOPLB, strBSTYPE, strSALES, strOP, strCUSTOMER, strBSSOURCE, strBSSOURCEDETAIL, strLane, strACCDATEBGN, strACCDATEEND);
return dataList;
}
static private string GetCompareGainInfoList(string companyID, string strYear, string strMonth, string strOPLB, string strBSTYPE, string strSALES, string strOP, string strCUSTOMER, string strBSSOURCE, string strBSSOURCEDETAIL, string strLane, string strACCDATEBGN, string strACCDATEEND)
{
var strSql = new StringBuilder();
strSql.AppendLine("select SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 7) MONTHNAME,A.MBLNO, ");
strSql.AppendLine("B.TTLDR,B.TTLCR,(B.TTLDR-B.TTLCR) as TTLAMOUNT, ");
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 SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "' ");//OPDATE like '%" + strYear + "%' and OPDATE like '%" + strMonth + "%' ");
strSql.AppendLine("and B.TTLDR is not NULL and B.TTLCR is not NULL ");
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.ACCDATE>='" + strACCDATEBGN + "'"); }
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'"); }
if (strCUSTOMER != "" && strCUSTOMER != "undefined" && strCUSTOMER != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMER + "'"); }
if (strSALES != "" && strSALES != "undefined" && strSALES != "null") { strSql.AppendLine("and A.SALE='" + strSALES + "'"); }
if (strOP != "" && strOP != "undefined" && strOP != "null") { strSql.AppendLine("and A.OP='" + strOP + "'"); }
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
if (strOPLB != "" && strOPLB != "undefined" && strOPLB != "null") { strSql.AppendLine("and A.OPLB='" + strOPLB + "'"); }
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
if (strBSSOURCEDETAIL != "" && strBSSOURCEDETAIL != "undefined" && strBSSOURCEDETAIL != "null") { strSql.AppendLine("and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'"); }
if (strLane != "" && strLane != "undefined" && strLane != null) { strSql.AppendLine("and A.Lane='" + strLane + "'"); }
//strSql.AppendLine("GROUP BY A.MBLNO,A.BSSOURCE,A.INPUTBY,A.OPDATE,A.BSNO,B.TTLDR,B.TTLCR ");
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"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLCR:\"" + Convert.ToString(reader["TTLCR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 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 GetCompareArrearageInfo(string strYear, string strMonth, string strOPLB, string strBSTYPE, string strSALES, string strOP, string strCUSTOMER, string strBSSOURCE, string strBSSOURCEDETAIL, string strLane, string strACCDATEBGN, string strACCDATEEND)
{
string dataList = GetCompareArrearageInfoList(Convert.ToString(Session["COMPANYID"]), strYear, strMonth, strOPLB, strBSTYPE, strSALES, strOP, strCUSTOMER, strBSSOURCE, strBSSOURCEDETAIL, strLane, strACCDATEBGN, strACCDATEEND);
return dataList;
}
static private string GetCompareArrearageInfoList(string companyID, string strYear, string strMonth, string strOPLB, string strBSTYPE, string strSALES, string strOP, string strCUSTOMER, string strBSSOURCE, string strBSSOURCEDETAIL, string strLane, string strACCDATEBGN, string strACCDATEEND)
{
var strSql = new StringBuilder();
strSql.AppendLine("select SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 7) MONTHNAME,A.MBLNO, ");
strSql.AppendLine("B.TTLDR,B.STLTTLDR,(B.TTLDR-B.STLTTLDR) as TTLAMOUNT, ");
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 SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 6, 2)='" + strMonth + "' ");
strSql.AppendLine("and B.TTLDR is not NULL and B.STLTTLDR is not NULL ");
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and A.ACCDATE>='" + strACCDATEBGN + "'"); }
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'"); }
if (strCUSTOMER != "" && strCUSTOMER != "undefined" && strCUSTOMER != "null") { strSql.AppendLine("and A.CUSTOMERNAME='" + strCUSTOMER + "'"); }
if (strSALES != "" && strSALES != "undefined" && strSALES != "null") { strSql.AppendLine("and A.SALE='" + strSALES + "'"); }
if (strOP != "" && strOP != "undefined" && strOP != "null") { strSql.AppendLine("and A.OP='" + strOP + "'"); }
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and A.BSTYPE='" + strBSTYPE + "'"); }
if (strOPLB != "" && strOPLB != "undefined" && strOPLB != "null") { strSql.AppendLine("and A.OPLB='" + strOPLB + "'"); }
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and A.BSSOURCE='" + strBSSOURCE + "'"); }
if (strBSSOURCEDETAIL != "" && strBSSOURCEDETAIL != "undefined" && strBSSOURCEDETAIL != "null") { strSql.AppendLine("and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'"); }
if (strLane != "" && strLane != "undefined" && strLane != null) { strSql.AppendLine("and A.Lane='" + strLane + "'"); }
//strSql.AppendLine("GROUP BY A.MBLNO,A.BSSOURCE,A.INPUTBY,A.OPDATE,A.BSNO,B.TTLDR,B.STLTTLDR ");
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"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",STLTTLDR:\"" + Convert.ToString(reader["STLTTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 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 GetCompareTEUInfo(string strYear, string strMonth, string strOPLB, string strBSTYPE, string strSALES, string strOP, string strCUSTOMER, string strBSSOURCE, string strBSSOURCEDETAIL, string strLane, string strACCDATEBGN, string strACCDATEEND)
{
string dataList = GetCompareTEUInfoList(Convert.ToString(Session["COMPANYID"]), strYear, strMonth, strOPLB, strBSTYPE, strSALES, strOP, strCUSTOMER, strBSSOURCE, strBSSOURCEDETAIL, strLane, strACCDATEBGN, strACCDATEEND);
return dataList;
}
static private string GetCompareTEUInfoList(string companyID, string strYear, string strMonth, string strOPLB, string strBSTYPE, string strSALES, string strOP, string strCUSTOMER, string strBSSOURCE, string strBSSOURCEDETAIL, string strLane, string strACCDATEBGN, string strACCDATEEND)
{
var strSql = new StringBuilder();
strSql.AppendLine("select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, ");
strSql.AppendLine("TEU, ");
strSql.AppendLine("INPUTBY from v_op_bill ");
strSql.AppendLine("where SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 4)='" + strYear + "' and SUBSTRING(CONVERT(char(15), OPDATE, 111), 6, 2)='" + strMonth + "' ");
strSql.AppendLine("and TEU is not NULL and TEU<>'' ");
if (strACCDATEBGN != "" && strACCDATEBGN != "undefined" && strACCDATEBGN != "null") { strSql.AppendLine("and ACCDATE>='" + strACCDATEBGN + "'"); }
if (strACCDATEEND != "" && strACCDATEEND != "undefined" && strACCDATEEND != "null") { strSql.AppendLine("and ACCDATE<='" + strACCDATEEND + " 23:59:59'"); }
if (strCUSTOMER != "" && strCUSTOMER != "undefined" && strCUSTOMER != "null") { strSql.AppendLine("and CUSTOMERNAME='" + strCUSTOMER + "'"); }
if (strSALES != "" && strSALES != "undefined" && strSALES != "null") { strSql.AppendLine("and SALE='" + strSALES + "'"); }
if (strOP != "" && strOP != "undefined" && strOP != "null") { strSql.AppendLine("and OP='" + strOP + "'"); }
if (strBSTYPE != "" && strBSTYPE != "undefined" && strBSTYPE != "null") { strSql.AppendLine("and BSTYPE='" + strBSTYPE + "'"); }
if (strOPLB != "" && strOPLB != "undefined" && strOPLB != "null") { strSql.AppendLine("and OPLB='" + strOPLB + "'"); }
if (strBSSOURCE != "" && strBSSOURCE != "undefined" && strBSSOURCE != "null") { strSql.AppendLine("and BSSOURCE='" + strBSSOURCE + "'"); }
if (strBSSOURCEDETAIL != "" && strBSSOURCEDETAIL != "undefined" && strBSSOURCEDETAIL != "null") { strSql.AppendLine("and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'"); }
if (strLane != "" && strLane != "undefined" && strLane != "null") { strSql.AppendLine("and Lane='" + strLane + "'"); }
//strSql.AppendLine("GROUP BY MBLNO,BSSOURCE,TEU,INPUTBY,OPDATE,BSNO ");
strSql.AppendLine("order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 7),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"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
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 sumfieldtype, string startmonth, string endmonth, string objtype)
{
var dataList = MsRptOpProfitZouDAL.SumListData(condition, sort, sumfieldtype, startmonth, endmonth,objtype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#region 月度数
public ContentResult GetMonthsData(string startmonth, string endmonth)
{
var dataList = MsRptOpProfitZouDAL.GetMonthList(startmonth, endmonth);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#endregion
#region 参照部分
#endregion
}
}