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/RptMng/Controllers/MsRptDjTransController.cs

105 lines
4.1 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.Areas.RptMng.Models;
using DSWeb.TruckMng.Helper;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using DSWeb.SoftMng.Filter;
namespace DSWeb.Areas.RptMng.Controllers
{
/// <summary>
/// 单车运输明细
/// </summary>
public class MsRptDjTransController : Controller
{
//
// GET: /RptMng/MsRptBulkTrans/
public ActionResult Index()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = GetDataList(condition,sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
private static List<MsRptBulkTrans> GetDataList(string strCondition,string sort=null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT p.TruckNo,sum(p.FuelQty) as FuelQty, sum(M.RealMil) as RealMil ");
strSql.Append(",sum(M.OverLoadMil) as OverLoadMil,sum(M.NoLoadMil) as NoLoadMil ");
strSql.Append(",sum(M.LoadCount) as LoadCount,sum(M.Weight) as Weight");
strSql.Append(",sum(M.RatedFuel) as RatedFuel,sum(M.TonMil) as TonMil,sum(f.Amount) as TransTotal from ");
strSql.Append("(SELECT b.BillNo,sum(b.OverLoadMil+b.NoLoadMil) as RealMil ");
strSql.Append(",sum(b.OverLoadMil) as OverLoadMil,sum(b.NoLoadMil) as NoLoadMil");
strSql.Append(",sum(b.LoadCount) as LoadCount,sum(b.Weight) as Weight");
strSql.Append(",sum(b.RatedFuel) as RatedFuel,sum(b.TonMil) as TonMil ");
strSql.Append(" from tMsWlDjPound b group by b.BillNo) as M left join tMsWlPcHead p on (p.Gid=M.BillNo)");
strSql.Append(" left join vPcFeeSum f on (f.BillNo=M.BillNo) ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" group by p.TruckNo ");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
return SetData(strSql);
}
private static List<MsRptBulkTrans> SetData(StringBuilder strSql)
{
var headList = new List<MsRptBulkTrans>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsRptBulkTrans();
#region Set DB data to Object
data.TruckNo = Convert.ToString(reader["TruckNo"]);
// data.ExpDate = Convert.ToString(reader["ExpDate"]);
data.RealMil = Convert.ToDecimal(reader["RealMil"]);
data.OverLoadMil = Convert.ToDecimal(reader["OverLoadMil"]);
data.NoLoadMil = Convert.ToDecimal(reader["NoLoadMil"]);
data.RatedFuel = Convert.ToDecimal(reader["RatedFuel"]);
if (reader["FuelQty"] != DBNull.Value)
data.FuelQty = Convert.ToDecimal(reader["FuelQty"]);
data.LoadCount = Convert.ToDecimal(reader["LoadCount"]);
data.Weight = Convert.ToDecimal(reader["Weight"]);
data.TonMil = Convert.ToDecimal(reader["TonMil"]);
if (reader["TransTotal"] != DBNull.Value)
data.TransTotal = Convert.ToDecimal(reader["TransTotal"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
}
}