|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Data.OleDb;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Web.Mvc;
|
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.MvcShipping.Helper.Repository;
|
|
|
using DSWeb.MvcShipping.Models.MsOpCtnStatus;
|
|
|
using DSWeb.Areas.MvcShipping.DAL;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using DSWeb.Areas.RptMng.Comm;
|
|
|
using HcUtility.Comm;
|
|
|
using HcUtility.Core;
|
|
|
using WebSqlHelper;
|
|
|
using DSWeb.Areas.MvcShipping.DAL.MsOpCtnRentBuy;
|
|
|
using DSWeb.SoftMng.Filter;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
{
|
|
|
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsOpCtnStatusController : Controller
|
|
|
{
|
|
|
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
public ActionResult Edit()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
public ActionResult CtnIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
public ActionResult CtnEdit()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
public ActionResult PiliangEdit()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult RptCtnStatus()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult RptCtnVessel()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult RptCtnPort()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult RptCtnDue()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
#region 集装箱动态
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetListData(int start, int limit, string sort, string condition)
|
|
|
{
|
|
|
var dataList = MsOpCtnStatusDAL.GetDataStatusList(condition);
|
|
|
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 };
|
|
|
}
|
|
|
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
|
{
|
|
|
MsCtnStatus head = null;
|
|
|
if (handle == "edit")
|
|
|
{
|
|
|
var list = MsOpCtnStatusDAL.GetDataStatusList(condition);
|
|
|
if (list.Count > 0)
|
|
|
head = list[0];
|
|
|
}
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new MsCtnStatus();
|
|
|
}
|
|
|
var json = JsonConvert.Serialize(
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
public ContentResult Save(string opstatus, string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<MsCtnStatus>(data);
|
|
|
|
|
|
if (opstatus == "add")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
}
|
|
|
else if (opstatus == "edit")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
|
headData.ModelUIStatus = "E";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
|
}
|
|
|
|
|
|
var cntrno = headData.box_no;
|
|
|
var vessel = headData.vessel;
|
|
|
var voyage = headData.voyage;
|
|
|
if (headData.reachtime == "") headData.reachtime = null;
|
|
|
var modb = new ModelObjectDB();
|
|
|
var str = MsOpCtnStatusDAL.importBox(headData,Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success =true,
|
|
|
Message = str,
|
|
|
Data = MsOpCtnStatusDAL.GetStatusData("box_no='" + cntrno + "' and vessel='" + vessel + "' and voyage='" + voyage + "'")
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public ContentResult SavePL(string opstatus, string data)
|
|
|
{
|
|
|
|
|
|
var headData = JsonConvert.Deserialize<MsCtnStatus>(data);
|
|
|
|
|
|
var message = string.Empty;
|
|
|
|
|
|
var strmsg = business.importBox(headData.vessel, headData.voyage, headData.etd, headData.position, "", headData.reachtime, headData.fobport,headData.Remarks, Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { success = true, Message = strmsg, data = "" });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
public ContentResult Delete(string data)
|
|
|
{
|
|
|
var bodyList = JsonConvert.Deserialize<List<MsCtnStatus>>(data);
|
|
|
var result = new DBResult();
|
|
|
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
result = MsOpCtnStatusDAL.DeleteStatus(bodyList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
#region 锁定业务
|
|
|
public ContentResult sdywc(string data,string type)
|
|
|
{
|
|
|
var bodyList = JsonConvert.Deserialize<List<MsCtnStatus>>(data);
|
|
|
var result = new DBResult();
|
|
|
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
result = MsOpCtnStatusDAL.sdyw(bodyList,type);
|
|
|
}
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
};
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
public ContentResult modify(string data, string modifydata)
|
|
|
{
|
|
|
var bodyList = JsonConvert.Deserialize<List<MsCtnStatus>>(data);
|
|
|
var amodifydata = JsonConvert.Deserialize<MsCtnStatus>(modifydata);
|
|
|
var result = new DBResult();
|
|
|
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
result = MsOpCtnStatusDAL.ModifyStatus(bodyList,amodifydata);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 集装箱资料
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetCtnListData(int start, int limit, string sort, string condition)
|
|
|
{
|
|
|
var dataList = MsOpCtnStatusDAL.GetCtnList(condition);
|
|
|
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 };
|
|
|
}
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetCtnData(string handle, string condition)
|
|
|
{
|
|
|
MsCtn head = null;
|
|
|
if (handle == "edit")
|
|
|
{
|
|
|
var list = MsOpCtnStatusDAL.GetCtnList(condition);
|
|
|
if (list.Count > 0)
|
|
|
head = list[0];
|
|
|
}
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new MsCtn();
|
|
|
}
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = head });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
public ContentResult SaveCtn(string opstatus, string data)
|
|
|
{
|
|
|
|
|
|
var headData = JsonConvert.Deserialize<MsCtn>(data);
|
|
|
|
|
|
if (opstatus == "add")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
}
|
|
|
else if (opstatus == "edit")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
|
headData.ModelUIStatus = "E";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
|
}
|
|
|
|
|
|
var cntrno = headData.cntrno;
|
|
|
if (headData.rent_begintime == "") headData.rent_begintime = null;
|
|
|
if (headData.rent_endtime == "") headData.rent_endtime = null;
|
|
|
if (headData.buytime == "") headData.buytime = null;
|
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
DBResult result = MsOpCtnStatusDAL.SaveCtn(headData);
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
Data = MsOpCtnStatusDAL.GetData("cntrno='" + cntrno + "'")
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public ContentResult DeleteCtn(string data)
|
|
|
{
|
|
|
var bodyList = JsonConvert.Deserialize<List<MsCtn>>(data);
|
|
|
var result = new DBResult();
|
|
|
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
result = MsOpCtnStatusDAL.DeleteCtn(bodyList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
public ContentResult modifyCtn(string data, string modifydata)
|
|
|
{
|
|
|
var bodyList = JsonConvert.Deserialize<List<MsCtn>>(data);
|
|
|
var amodifydata = JsonConvert.Deserialize<MsCtn>(modifydata);
|
|
|
var result = new DBResult();
|
|
|
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
result = MsOpCtnStatusDAL.ModifyCtn(bodyList, amodifydata);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetCtnNoData(string condition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT cntrno as CTNNO from container_info where status=1 or status=2");
|
|
|
|
|
|
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, 100000, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
[HttpPost]
|
|
|
public ContentResult ImportCtn()
|
|
|
{
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "" };
|
|
|
|
|
|
if (Request.Files.Count != 1)
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "请选择上传的文件";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
var file = Request.Files["LoadExcel"];
|
|
|
if (file == null)
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
string ext = Path.GetExtension(file.FileName).ToLower();
|
|
|
if (ext == ".asp" || ext == ".aspx")
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "不允许上传ASP或ASPX文件";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/BulkDetail");
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
{
|
|
|
Directory.CreateDirectory(path);
|
|
|
}
|
|
|
|
|
|
var size = file.ContentLength;
|
|
|
var name = Path.GetFileName(file.FileName);
|
|
|
var data = Request.Form["data"];
|
|
|
var usercode = CookieConfig.GetCookie_UserCode(Request);
|
|
|
string filename = path + "\\" + usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
|
|
|
|
|
|
if (System.IO.File.Exists(filename))
|
|
|
{
|
|
|
System.IO.File.Delete(filename);
|
|
|
}
|
|
|
file.SaveAs(filename);
|
|
|
|
|
|
if (!System.IO.File.Exists(filename))
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "上传的Excel不包含数据01";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
List<string> sheets = ExcelSheetName(filename);
|
|
|
if (sheets.Count == 0)
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "上传的Excel不包含数据02";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
try
|
|
|
{
|
|
|
var sheetname = sheets[0];
|
|
|
string excelConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename +
|
|
|
";Extended Properties=Excel 8.0;";
|
|
|
if (filename.ToLower().IndexOf(".xlsx") > 0)
|
|
|
{
|
|
|
excelConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename +
|
|
|
";Extended Properties=\"Excel 12.0 Xml;HDR=Yes\"";
|
|
|
|
|
|
}
|
|
|
OleDbDataAdapter oada = new OleDbDataAdapter("select * from [" + sheetname + "A1:N]", excelConn);
|
|
|
DataSet ds = new DataSet();
|
|
|
oada.Fill(ds);
|
|
|
|
|
|
if (ds.Tables.Count == 0)
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "上传的Excel不包含数据03";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
var table = ds.Tables[0];
|
|
|
if (table.Rows.Count == 0 )
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "上传的Excel不包含数据04";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
var message = string.Empty;
|
|
|
List<MsCtnStatus> headList;
|
|
|
string userid = Convert.ToString(Session["USERID"]);
|
|
|
DBResult result = MsOpCtnStatusDAL.ImportCtnDetailData(data, Request, table, out message, out headList, userid);
|
|
|
if (result.Success==false)
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = result.Message;
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
var json = JsonConvert.Serialize(new { success = true, Message = result.Message, data = headList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "读取Excel文件出错,请确认文件正确性";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public List<string> ExcelSheetName(string filepath)
|
|
|
{
|
|
|
var al = new List<string>();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
string strConn;
|
|
|
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties=Excel 8.0;";
|
|
|
if (filepath.ToLower().IndexOf(".xlsx") > 0)
|
|
|
{
|
|
|
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath +
|
|
|
";Extended Properties=\"Excel 12.0 Xml;HDR=Yes\"";
|
|
|
|
|
|
}
|
|
|
OleDbConnection conn = new OleDbConnection(strConn);
|
|
|
conn.Open();
|
|
|
DataTable sheetNames = conn.GetOleDbSchemaTable
|
|
|
(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
|
|
|
conn.Close();
|
|
|
|
|
|
foreach (DataRow dr in sheetNames.Rows)
|
|
|
{
|
|
|
al.Add(dr[2].ToString());
|
|
|
}
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return new List<string>();
|
|
|
}
|
|
|
|
|
|
return al;
|
|
|
}
|
|
|
|
|
|
#region 报表 集装箱到期报表
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetRptCtnDueData(int start, int limit, string condition, string sort)
|
|
|
{
|
|
|
|
|
|
string rday = "";
|
|
|
try
|
|
|
{
|
|
|
rday = BaseClass.db.GetSqlStrScalar("select deadline2 from sys_remind").ToString();
|
|
|
}
|
|
|
catch { }
|
|
|
if (!string.IsNullOrEmpty(rday) && rday != "0")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select dd.box_no,e.cntrid,e.cntrno,e.cntrowner,e.cntype,e.cnsource,convert(varchar(10),e.buytime,120) as buytime,convert(varchar(10),e.rent_begintime,120) as rent_begintime,convert(varchar(10),e.rent_endtime,120) as rent_endtime,(case when e.status=1 then '可用' when e.status=2 then '已用' when e.status=3 then '维修' when e.status=4 then '停用' end) as statusref,(select cname from code_disport where portid=dd.position) as positionname ");
|
|
|
strSql.Append(",datediff(dd,opertime,'" + DateTime.Now.ToString() + "') as dueday from container_info e right join (select * from (select b.* from (select max(b_id)b_id from container_business group by Box_No) a left join container_business b on a.b_id=b.b_id)cc where (Oneway is null or oneway='') and datediff(dd,opertime,'" + DateTime.Now.ToString() + "')>=" + rday + ")dd on e.cntrno=dd.box_no Where e.status!=4 and e.status!=5 and e.status!=6 and e.status!=7 ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and" + condition);
|
|
|
}
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by e.cntrowner desc,e.cntrno ");
|
|
|
|
|
|
}
|
|
|
|
|
|
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(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
else {
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "" };
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "未设置提醒天数";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 报表 集装箱航次使用报表
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetRptCtnVesselData(int start, int limit, string condition, string sort)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" declare @sql NVARCHAR(max) declare @sumsql NVARCHAR(max) ");
|
|
|
strSql.Append(" set @sql='select b.vessel,b.voyage' ");
|
|
|
strSql.Append(" select @sql=@sql+',sum(case c.cntype when '''+t.ctn+''' then 1 else 0 end) as C'+t.ctn from (select ctn from code_ctn) as t");
|
|
|
strSql.Append(" set @sumsql='select ''合计'' vessel,'''' voyage' ");
|
|
|
strSql.Append(" select @sumsql=@sumsql+',sum(case c.cntype when '''+t.ctn+''' then 1 else 0 end) as C'+t.ctn from (select ctn from code_ctn) as t");
|
|
|
strSql.Append(" set @sql=@sql+' from container_business b ");
|
|
|
strSql.Append(" left join container_info c on (c.cntrno=b.box_no) ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" group by b.vessel,b.voyage union all '+@sumsql+' from container_business b ");
|
|
|
strSql.Append("left join container_info c on (c.cntrno=b.box_no)'");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" exec(@sql) ");
|
|
|
|
|
|
|
|
|
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(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 报表 集装箱港口报表
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetRptCtnPortData(int start, int limit, string condition, string sort)
|
|
|
{
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" declare @sql NVARCHAR(max) declare @sumsql NVARCHAR(max) ");
|
|
|
strSql.Append(" set @sql='select b.position,p.port' ");
|
|
|
strSql.Append(" select @sql=@sql+',sum(case b.cntype when '''+t.ctn+''' then 1 else 0 end) as C'+t.ctn from (select ctn from code_ctn) as t");
|
|
|
strSql.Append(" set @sumsql='select '''' position,''合计'' port' ");
|
|
|
strSql.Append(" select @sumsql=@sumsql+',sum(case b.cntype when '''+t.ctn+''' then 1 else 0 end) as C'+t.ctn from (select ctn from code_ctn) as t");
|
|
|
strSql.Append(" set @sql=@sql+' from container_info b left join code_disport p on (p.PORTID=b.position) ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" group by b.position,p.port union all ' +@sumsql+' from container_info b ");
|
|
|
strSql.Append("left join code_disport p on (p.PORTID=b.position)' ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
strSql.Append(" exec(@sql) ");
|
|
|
|
|
|
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(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 报表 集装箱状态报表
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetRptCtnStatusData(int start, int limit, string condition, string sort)
|
|
|
{
|
|
|
|
|
|
string rday = "";
|
|
|
try
|
|
|
{
|
|
|
rday = BaseClass.db.GetSqlStrScalar("select deadline1 from sys_remind").ToString();
|
|
|
}
|
|
|
catch { }
|
|
|
if (!string.IsNullOrEmpty(rday) && rday != "0")
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select cntrid,cntrno,cntrowner,cntype,cnsource,convert(varchar(10),buytime,120) as buytime,convert(varchar(10),rent_begintime,120) as rent_begintime,convert(varchar(10),rent_endtime,120) as rent_endtime, ");
|
|
|
strSql.Append("(case when status=1 then '可用' when status=2 then '已用' when status=3 then '维修' when status=4 then '停用' end) as statusref,(select cname from code_disport where portid=position) as positionname from container_info where datediff(dd,rent_endtime,'" + DateTime.Now.ToString() + "')<=" + rday);
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
|
|
|
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(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "" };
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "未设置提醒天数";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
#endregion |