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/MvcContainer/Controllers/MsOpCtnBsCardController.cs

1386 lines
57 KiB
C#

3 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcContainer.Models.MsOpCtnBsCard;
using DSWeb.MvcContainer.DAL.MsOpCtnBsCard;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.RptMng.Comm;
using System.Text;
using DSWeb.Areas.CommMng.Models;
using System.Data;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using System.IO;
using DSWeb.EntityDA;
using DSWeb.MvcShipping.Models.MsChFee;
namespace DSWeb.MvcContainer.Controllers
{
[JsonRequestBehavior]
public class MsOpCtnBsCardController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ActionResult CtnStatusIndex()
{
return View();
}
public ActionResult CtnStatusEdit()
{
return View();
}
public ActionResult RptCtnStatus()
{
return View();
}
public ActionResult ProfitIndex()
{
return View();
}
public ActionResult RepairAudit()
{
return View();
}
public ActionResult ClearingAudit()
{
return View();
}
public ActionResult CtnStatusDetail()
{
return View();
}
public ActionResult ReturnAudit()
{
return View();
}
public ActionResult ChfeeAudit()
{
return View();
}
public ActionResult CtnStatusFee()
{
return View();
}
public ActionResult RptRepair()
{
return View();
}
public ActionResult RptCtnTurnOver()
{
return View();
}
public ActionResult ZipView()
{
return View();
}
//
// GET
public ContentResult GetDataList(int start, int limit, string sort, string condition, string pricetype)
{
int total = 0;
var dataList = MsOpCtnBsCardDAL.GetDataList(start,limit,out total,condition, pricetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = total, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataListStr(string sort, string condition, string pricetype)
{
var dataListStr = MsOpCtnBsCardDAL.GetDataListStr(condition, pricetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult GetDataFeeList(int start, int limit, string sort, string condition, string datetype)
{
var dataList = MsOpCtnBsCardDAL.GetDataFeeList(condition, datetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), 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 };
}
public ContentResult GetDataFeeListStr(string sort, string condition, string datetype)
{
var dataListStr = MsOpCtnBsCardDAL.GetDataFeeListStr(condition, datetype, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult GetRptCtnStatusData(int start, int limit,string condition, string sort, string printstr = "false")
{
var strSql = new StringBuilder();
//strSql.Append(" select * into #top_opctnbscard from v_top_opctnbscard ");
//strSql.Append(" SELECT VDESTPORT DESTPORT,VCOUNTRY COUNTRY,(CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE AGENTNAME END) AGENTNAME,SUM(CASE WHEN (VETA IS NOT NULL AND VDEST_RTCNT_TIME IS NOT NULL) OR (PORTLOAD_CNT_TIME IS NULL AND ETD IS NULL) THEN 1 ELSE 0 END) AS YARDCTN,");
//strSql.Append("SUM(CASE WHEN VDEST_RTCNT_TIME IS NOT NULL THEN 1 ELSE 0 END) AS CANUSEYARDCTN, ");//在场可用箱
//strSql.Append("SUM(CASE WHEN (ISNULL(IS_RETURE_EMPTY,0)=1 AND VETA IS NULL AND I_PORTLOAD_CNT_TIME IS NOT NULL) OR (isnull(EMPTYCTNALLOCATION, 0) = 1 AND VETA IS NULL AND PORTLOAD_CNT_TIME IS NOT NULL) THEN 1 ELSE 0 END) AS CANUSEONTHEWAYCTN,");//在途可用箱
//strSql.Append("SUM(CASE WHEN (ISNULL(IS_RETURE_EMPTY,0)=1 AND VETA IS NULL AND I_PORTLOAD_CNT_TIME IS NOT NULL) OR (isnull(EMPTYCTNALLOCATION, 0) = 1 AND VETA IS NULL AND PORTLOAD_CNT_TIME IS NOT NULL) THEN 1 ELSE 0 END)+SUM(CASE WHEN VDEST_RTCNT_TIME IS NOT NULL THEN 1 ELSE 0 END) AS CANUSETOTALCTN,");//全部可用箱
//strSql.Append("SUM(CASE WHEN PORTLOAD_CNT_TIME IS NULL AND ETD IS NULL THEN 1 ELSE 0 END) AS PLANUSEYARDCTN,");
//strSql.Append("(SELECT SUM(CTNNUM) FROM op_ctnapply WHERE MNGAUDITSTATUS='审核通过' and BSSTATUS<>'配箱完成' AND ADDCTNSTATUS<>'配箱完成' and PORTDISCHARGE=b.VDESTPORT and AGENTNAME=(CASE WHEN ISNULL(b.IS_RETURE_EMPTY,0)=1 THEN '' ELSE b.AGENTNAME END)) AS PLANUSECTN,");
//strSql.Append(" SUM(CASE WHEN VDEST_RTCNT_TIME IS NULL AND VETA IS NOT NULL THEN 1 ELSE 0 END) AS ARRIVALCTN,");
//strSql.Append("SUM(CASE WHEN VETA IS NULL AND PORTLOAD_CNT_TIME IS NOT NULL THEN 1 ELSE 0 END) AS TRANSCTN,");
//strSql.Append("SUM(CASE WHEN VDEST_RTCNT_TIME IS NOT NULL AND CTNSTATUS='可用' and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())>7 and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())<=15 THEN 1 ELSE 0 END) AS CANUSEYARDCTN7, ");
//strSql.Append("SUM(CASE WHEN VDEST_RTCNT_TIME IS NOT NULL AND CTNSTATUS='可用' and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())>15 and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())<=30 THEN 1 ELSE 0 END) AS CANUSEYARDCTN15, ");
//strSql.Append("SUM(CASE WHEN VDEST_RTCNT_TIME IS NOT NULL AND CTNSTATUS='可用' and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())>30 THEN 1 ELSE 0 END) AS CANUSEYARDCTN30 ");
//strSql.Append(" FROM #top_opctnbscard b ");
//if (!string.IsNullOrEmpty(condition))
//{
// strSql.Append(" Where " + condition);
//}
//strSql.Append(" GROUP BY VDESTPORT,VCOUNTRY,(CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE AGENTNAME END) ");
//var sortstring = DatasetSort.Getsortstring(sort);
//if (!string.IsNullOrEmpty(sortstring))
//{
// strSql.Append(" order by " + sortstring + " ");
//}
//else
//{
// strSql.Append(" order by b.VDESTPORT ");
//}
//strSql.Append(" drop table #top_opctnbscard ");
strSql.Append(" select * into #top_opctnbscard from v_top_opctnbscard ");
strSql.Append(" where CTNNO NOT IN (SELECT CTNNO FROM op_ctnapplyctnitems WHERE LINKGID IN (SELECT GID FROM op_ctnapply WHERE MNGAUDITSTATUS='审核通过' and BSSTATUS<>'配箱完成' AND ADDCTNSTATUS<>'配箱完成')) ");
strSql.Append(" SELECT DESTPORT,COUNTRY,AGENTNAME,SUM(YARDCTN+PLANUSECTN) YARDCTN,SUM(CANUSEYARDCTN) CANUSEYARDCTN,SUM(CANUSEONTHEWAYCTN) CANUSEONTHEWAYCTN,SUM(CANUSETOTALCTN) CANUSETOTALCTN");
strSql.Append(" ,SUM(PLANUSEYARDCTN) PLANUSEYARDCTN,SUM(PLANUSECTN) PLANUSECTN,SUM(ARRIVALCTN) ARRIVALCTN,SUM(TRANSCTN) TRANSCTN,SUM(CANUSEYARDCTN7) CANUSEYARDCTN7");
strSql.Append(" ,SUM(CANUSEYARDCTN15) CANUSEYARDCTN15,SUM(CANUSEYARDCTN30) CANUSEYARDCTN30 FROM (");
strSql.Append(" SELECT VDESTPORT DESTPORT,isnull(VCOUNTRY,'') COUNTRY,(CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE AGENTNAME END) AGENTNAME,");
strSql.Append("SUM(CASE WHEN (VETA IS NOT NULL AND VDEST_RTCNT_TIME IS NOT NULL) OR (IS_RETURE_EMPTY=1 and I_PORTLOAD_CNT_TIME IS NULL AND I_ETD IS NULL AND DEST_RTCNT_TIME IS NOT NULL) OR (IS_DB=1 and D_PORTLOAD_CNT_TIME IS NULL AND D_ETD IS NULL AND I_DEST_RTCNT_TIME IS NOT NULL) THEN 1 ELSE 0 END) AS YARDCTN ");//在场可用箱
strSql.Append(",SUM(CASE WHEN (VDEST_RTCNT_TIME IS NOT NULL) OR (IS_RETURE_EMPTY=1 and I_PORTLOAD_CNT_TIME IS NULL AND I_ETD IS NULL AND DEST_RTCNT_TIME IS NOT NULL) OR (IS_DB=1 and D_PORTLOAD_CNT_TIME IS NULL AND D_ETD IS NULL AND I_DEST_RTCNT_TIME IS NOT NULL) THEN 1 ELSE 0 END) AS CANUSEYARDCTN, SUM(CASE WHEN (ISNULL(IS_RETURE_EMPTY,0)=1 AND VETA IS NULL AND I_PORTLOAD_CNT_TIME IS NOT NULL) OR (isnull(EMPTYCTNALLOCATION, 0) = 1 AND VETA IS NULL AND PORTLOAD_CNT_TIME IS NOT NULL) THEN 1 ELSE 0 END) AS CANUSEONTHEWAYCTN,");
strSql.Append( "SUM(CASE WHEN (ISNULL(IS_RETURE_EMPTY,0)=1 AND VETA IS NULL AND I_PORTLOAD_CNT_TIME IS NOT NULL) OR (isnull(EMPTYCTNALLOCATION, 0) = 1 AND VETA IS NULL AND PORTLOAD_CNT_TIME IS NOT NULL) THEN 1 ELSE 0 END)+SUM(CASE WHEN (VDEST_RTCNT_TIME IS NOT NULL) OR (IS_DB=1 and D_PORTLOAD_CNT_TIME IS NULL AND D_ETD IS NULL AND I_DEST_RTCNT_TIME IS NOT NULL) OR (IS_RETURE_EMPTY=1 and I_PORTLOAD_CNT_TIME IS NULL AND I_ETD IS NULL AND DEST_RTCNT_TIME IS NOT NULL) THEN 1 ELSE 0 END) AS CANUSETOTALCTN,SUM(CASE WHEN PORTLOAD_CNT_TIME IS NULL AND ETD IS NULL THEN 1 ELSE 0 END) AS PLANUSEYARDCTN");//在途可用箱
strSql.Append(",0 AS PLANUSECTN, SUM(CASE WHEN VDEST_RTCNT_TIME IS NULL AND VETA IS NOT NULL THEN 1 ELSE 0 END) AS ARRIVALCTN,SUM(CASE WHEN VETA IS NULL AND VPORTLOAD_CNT_TIME IS NOT NULL THEN 1 ELSE 0 END) AS TRANSCTN");//全部可用箱
strSql.Append(",SUM(CASE WHEN VDEST_RTCNT_TIME IS NOT NULL AND CTNSTATUS='可用' and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())>7 and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())<=15 THEN 1 ELSE 0 END) AS CANUSEYARDCTN7, SUM(CASE WHEN VDEST_RTCNT_TIME IS NOT NULL AND CTNSTATUS='可用' and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())>15 and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())<=30 THEN 1 ELSE 0 END) AS CANUSEYARDCTN15, SUM(CASE WHEN VDEST_RTCNT_TIME IS NOT NULL AND CTNSTATUS='可用' and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())>30 THEN 1 ELSE 0 END) AS CANUSEYARDCTN30");
strSql.Append("FROM #top_opctnbscard b ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append("GROUP BY VDESTPORT,VCOUNTRY,(CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE AGENTNAME END)");
strSql.Append("union");
strSql.Append("SELECT isnull(PORTDISCHARGE,'') DESTPORT,isnull((SELECT TOP 1 COUNTRY FROM code_disport WHERE [PORT]=isnull(PORTDISCHARGE,'')),''),isnull(AGENTNAME,''),0,0,0,0,0,SUM(CTNNUM),0,0,0,0,0 from op_ctnapply p left join code_ctntk b on (p.ctnno=b.ctnno) ");
strSql.Append("WHERE p.MNGAUDITSTATUS='审核通过' and p.BSSTATUS<>'配箱完成' AND p.ADDCTNSTATUS<>'配箱完成'");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" and " + condition);
}
strSql.Append("GROUP BY isnull(PORTDISCHARGE,''),isnull(AGENTNAME,'') ) AS B");
strSql.Append("GROUP BY DESTPORT,COUNTRY,AGENTNAME ");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring + " ");
}
else
{
strSql.Append(" order by DESTPORT ");
}
strSql.Append(" drop table #top_opctnbscard ");
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(start, limit, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
}
public ContentResult GetRptCtnStatusList(int start, int limit, string sort, string condition)
{
var dataList = MsOpCtnBsCardDAL.GetRptCtnStatusList(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 };
}
public ContentResult GetData(string handle, string condition)
{
OpCtnBsCard head = null;
if (handle == "edit")
{
head = MsOpCtnBsCardDAL.GetData(condition, Convert.ToString(Session["USERID"]));
}
if (head == null)
{
head = new OpCtnBsCard();
head.COMPANYID = Convert.ToString(Session["COMPANYID"]);
head.OP = Convert.ToString(Session["SHOWNAME"]);
head.INPUTBYREF = Convert.ToString(Session["SHOWNAME"]);
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string data2, string data3, string data4, bool iscreatefee = false, string feetype = "2")
{
var headData = JsonConvert.Deserialize<OpCtnBsCard>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", "").Replace("}", ",") + data4.Replace("{", ""));
var errorstr = "";
var isPost = true;
var ct = MsOpCtnBsCardDAL.GetRdCount("GID<>'" + headData.GID + "' AND BSNO='" + headData.BSNO + "'");
if (ct != 0)
{
isPost = false;
errorstr = "业务编号重复!";
}
if (headData.BSNO==""){
isPost = false;
errorstr = "业务编号不能为空!";
}
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.COMPANYID = Convert.ToString(Session["COMPANYID"]);
headData.INPUTBY = Convert.ToString(Session["USERID"]);
headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='罐箱业务卡'", Convert.ToString(Session["COMPANYID"]));
//if (billnoset.BILLTYPE != "")
// headData.BSNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.INPUTTIME.ToString().Trim(), headData.INPUTTIME.ToString().Trim());
//else
//{
// errorstr = "编号规则未设置,请先设置编号生成规则!";
// isPost = false;
//}
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
headData.MODIFYUSER= Convert.ToString(Session["USERID"]);
headData.MODIFYTIME= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
var GID = headData.GID;
var PREHEAD= MsOpCtnBsCardDAL.GetData(" BSNO IN (SELECT TOP 1 BSNO FROM op_ctnbscard WHERE CTNNO='"+headData.CTNNO+ "' AND GID<>'"+headData.GID+"' AND (PORTLOAD_CNT_TIME<'"+headData.PORTLOAD_CNT_TIME+ "' or ETD<'" + headData.ETD + "') ORDER BY ETD,PORTLOAD_CNT_TIME ) ", Convert.ToString(Session["USERID"]));
if (headData.PORTLOAD_CNT_TIME == "")
{
if (headData.ETD != "")
{
errorstr = "开船日期不能小于提箱日期";
isPost = false;
}
}
else
{
if (headData.ETD != "" && (Convert.ToDateTime(headData.ETD) < Convert.ToDateTime(headData.PORTLOAD_CNT_TIME)))
{
errorstr = "开船日期不能小于提箱日期";
isPost = false;
}
if (PREHEAD.BSNO != ""&& PREHEAD.BSNO != null)
{
if ((PREHEAD.IS_DB && PREHEAD.D_DEST_RTCNT_TIME == "")||(PREHEAD.IS_RETURE_EMPTY && PREHEAD.I_DEST_RTCNT_TIME == ""))
{
errorstr = "前一循环,返空目的港还箱日期未填";
isPost = false;
}
else
if (PREHEAD.DEST_RTCNT_TIME == "")
{
errorstr = "前一循环,目的港还箱日期未填";
isPost = false;
}
}
}
if (headData.ETD == "")
{
if (headData.ETA != "")
{
errorstr = "开船日期不能为空!";
isPost = false;
}
}
else
{
if (headData.ETA != "" && (Convert.ToDateTime(headData.ETA) < Convert.ToDateTime(headData.ETD)))
{
errorstr = "到港日期不能小于开船日期";
isPost = false;
}
}
if (headData.ETA == "")
{
if (headData.DEST_CNT_TIME != "")
{
errorstr = "到港日期不能为空!";
isPost = false;
}
}
else
{
if (headData.DEST_CNT_TIME != "" && (Convert.ToDateTime(headData.DEST_CNT_TIME) < Convert.ToDateTime(headData.ETA)))
{
errorstr = "提箱日期不能小于到港日期";
isPost = false;
}
}
if (headData.DEST_CNT_TIME == "")
{
if (headData.DEST_RTCNT_TIME != "")
{
errorstr = "目的港提箱日期不能为空!";
isPost = false;
}
}
else
{
if (headData.DEST_RTCNT_TIME != "" && (Convert.ToDateTime(headData.DEST_RTCNT_TIME) < Convert.ToDateTime(headData.DEST_CNT_TIME)))
{
errorstr = "目的港还箱日期不能小于目的港提箱日期";
isPost = false;
}
}
if (headData.DEST_RTCNT_TIME == "")
{
if (headData.I_PORTLOAD_CNT_TIME != "")
{
errorstr = "目的港还箱日期不能为空!";
isPost = false;
}
}
else
{
if (headData.I_PORTLOAD_CNT_TIME != "" && (Convert.ToDateTime(headData.I_PORTLOAD_CNT_TIME) < Convert.ToDateTime(headData.DEST_RTCNT_TIME)))
{
errorstr = "空返提箱日期不能小于目的港还箱日期";
isPost = false;
}
if (headData.D_PORTLOAD_CNT_TIME != "" && (Convert.ToDateTime(headData.D_PORTLOAD_CNT_TIME) < Convert.ToDateTime(headData.I_DEST_RTCNT_TIME)))
{
errorstr = "调拨提箱日期不能小于空返目的港还箱日期";
isPost = false;
}
}
if (headData.I_PORTLOAD_CNT_TIME == "")
{
if (headData.I_ETD != "")
{
errorstr = "空返开船日期不能小于提箱日期";
isPost = false;
}
}
else
{
if (headData.I_ETD != "" && (Convert.ToDateTime(headData.I_ETD) < Convert.ToDateTime(headData.I_PORTLOAD_CNT_TIME)))
{
errorstr = "空返开船日期不能小于提箱日期";
isPost = false;
}
}
if (headData.I_ETD == "")
{
if (headData.I_ETA != "")
{
errorstr = "空返开船日期不能为空!";
isPost = false;
}
}
else
{
if (headData.I_ETA != "" && (Convert.ToDateTime(headData.I_ETA) < Convert.ToDateTime(headData.I_ETD)))
{
errorstr = "空返到港日期不能小于开船日期";
isPost = false;
}
}
if (headData.I_ETA == "")
{
if (headData.I_DEST_CNT_TIME != "")
{
errorstr = "空返到港日期不能为空!";
isPost = false;
}
}
else
{
if (headData.I_DEST_CNT_TIME != "" && (Convert.ToDateTime(headData.I_DEST_CNT_TIME) < Convert.ToDateTime(headData.I_ETA)))
{
errorstr = "空返提箱日期不能小于到港日期";
isPost = false;
}
}
if (headData.I_DEST_CNT_TIME == "")
{
if (headData.I_DEST_RTCNT_TIME != "")
{
errorstr = "空返目的港提箱日期不能为空!";
isPost = false;
}
}
else
{
if (headData.I_DEST_RTCNT_TIME != "" && (Convert.ToDateTime(headData.I_DEST_RTCNT_TIME) < Convert.ToDateTime(headData.I_DEST_CNT_TIME)))
{
errorstr = "空返目的港还箱日期不能小于目的港提箱日期";
isPost = false;
}
}
if (headData.D_PORTLOAD_CNT_TIME == "")
{
if (headData.D_ETD != "")
{
errorstr = "调拨开船日期不能小于调拨提箱日期";
isPost = false;
}
}
else
{
if (headData.D_ETD != "" && (Convert.ToDateTime(headData.D_ETD) < Convert.ToDateTime(headData.D_PORTLOAD_CNT_TIME)))
{
errorstr = "调拨开船日期不能小于调拨提箱日期";
isPost = false;
}
}
if (headData.D_ETD == "")
{
if (headData.D_ETA != "")
{
errorstr = "调拨开船日期不能为空!";
isPost = false;
}
}
else
{
if (headData.D_ETA != "" && (Convert.ToDateTime(headData.D_ETA) < Convert.ToDateTime(headData.D_ETD)))
{
errorstr = "调拨到港日期不能小于开船日期";
isPost = false;
}
}
if (headData.D_ETA == "")
{
if (headData.D_DEST_CNT_TIME != "")
{
errorstr = "调拨到港日期不能为空!";
isPost = false;
}
}
else
{
if (headData.D_DEST_CNT_TIME != "" && (Convert.ToDateTime(headData.D_DEST_CNT_TIME) < Convert.ToDateTime(headData.D_ETA)))
{
errorstr = "调拨提箱日期不能小于到港日期";
isPost = false;
}
}
if (headData.D_DEST_CNT_TIME == "")
{
if (headData.D_DEST_RTCNT_TIME != "")
{
errorstr = "调拨目的港提箱日期不能为空!";
isPost = false;
}
}
else
{
if (headData.D_DEST_RTCNT_TIME != "" && (Convert.ToDateTime(headData.D_DEST_RTCNT_TIME) < Convert.ToDateTime(headData.D_DEST_CNT_TIME)))
{
errorstr = "调拨目的港还箱日期不能小于目的港提箱日期";
isPost = false;
}
}
if (headData.IS_DB == true)
{
if (headData.D_DEST_RTCNT_TIME != "" && (Convert.ToDateTime(headData.D_DEST_RTCNT_TIME) <= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))))
{
var vct = MsOpCtnBsCardDAL.GetRdCount("CTNNO='" + headData.CTNNO + "' and GID<>'" + headData.GID + "' AND (PORTLOAD_CNT_TIME>='" + headData.D_DEST_RTCNT_TIME + "' OR PORTLOAD_CNT_TIME IS NULL)");
if (vct == 0)
{
MsOpCtnBsCardDAL.UpCtnStatus(headData.CTNNO);
}
}
}
else
{
if (headData.IS_RETURE_EMPTY == true)
{
if (headData.I_DEST_RTCNT_TIME != "" && (Convert.ToDateTime(headData.I_DEST_RTCNT_TIME) <= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))))
{
var vct = MsOpCtnBsCardDAL.GetRdCount("CTNNO='" + headData.CTNNO + "' and GID<>'" + headData.GID + "' AND (PORTLOAD_CNT_TIME>='" + headData.I_DEST_RTCNT_TIME + "' OR PORTLOAD_CNT_TIME IS NULL)");
if (vct == 0)
{
MsOpCtnBsCardDAL.UpCtnStatus(headData.CTNNO);
}
}
}
else
{
if (headData.DEST_RTCNT_TIME != "" && (Convert.ToDateTime(headData.DEST_RTCNT_TIME) <= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))))
{
var vct = MsOpCtnBsCardDAL.GetRdCount("CTNNO='" + headData.CTNNO + "' and GID<>'" + headData.GID + "' AND (PORTLOAD_CNT_TIME>='" + headData.DEST_RTCNT_TIME + "' OR PORTLOAD_CNT_TIME IS NULL)");
if (vct == 0)
{
MsOpCtnBsCardDAL.UpCtnStatus(headData.CTNNO);
}
}
}
}
if (headData.IS_RETURE_EMPTY == false) {
headData.I_ETD = null;
headData.I_ETA = null;
headData.I_ARRIVALDATE = null;
headData.I_DEST_CNT_TIME = null;
headData.I_DEST_RTCNT_TIME = null;
headData.I_PORTLOAD_CNT_TIME = null;
}
if (headData.IS_DB == false)
{
headData.D_ETD = null;
headData.D_ETA = null;
headData.D_ARRIVALDATE = null;
headData.D_DEST_CNT_TIME = null;
headData.D_DEST_RTCNT_TIME = null;
headData.D_PORTLOAD_CNT_TIME = null;
}
if (headData.ETD == "") headData.ETD = null;
if (headData.ETA == "") headData.ETA = null;
if (headData.PREETA == "") headData.PREETA = null;
if (headData.I_ETD == "") headData.I_ETD = null;
if (headData.I_ETA == "") headData.I_ETA = null;
if (headData.PREI_ETA == "") headData.PREI_ETA = null;
if (headData.PORTLOADDATE == "") headData.PORTLOADDATE = null;
if (headData.I_ARRIVALDATE == "") headData.I_ARRIVALDATE = null;
if (headData.I_DEST_CNT_TIME == "") headData.I_DEST_CNT_TIME = null;
if (headData.I_DEST_RTCNT_TIME == "") headData.I_DEST_RTCNT_TIME = null;
if (headData.I_PORTLOAD_CNT_TIME == "") headData.I_PORTLOAD_CNT_TIME = null;
if (headData.PORTLOAD_CNT_TIME == "") headData.PORTLOAD_CNT_TIME = null;
if (headData.ARRIVALDATE == "") headData.ARRIVALDATE = null;
if (headData.DEST_CNT_TIME == "") headData.DEST_CNT_TIME = null;
if (headData.DEST_RTCNT_TIME == "") headData.DEST_RTCNT_TIME = null;
if (headData.PRE_CNT_TIME == "") headData.PRE_CNT_TIME = null;
if (headData.D_ETD == "") headData.D_ETD = null;
if (headData.D_ETA == "") headData.D_ETA = null;
if (headData.PRED_ETA == "") headData.PRED_ETA = null;
if (headData.D_ARRIVALDATE == "") headData.D_ARRIVALDATE = null;
if (headData.D_DEST_CNT_TIME == "") headData.D_DEST_CNT_TIME = null;
if (headData.D_DEST_RTCNT_TIME == "") headData.D_DEST_RTCNT_TIME = null;
if (headData.D_PORTLOAD_CNT_TIME == "") headData.D_PORTLOAD_CNT_TIME = null;
if (isPost)
{
var modb = new ModelObjectDB();
var result = modb.Save(headData);
if (iscreatefee && result.Success) {
MsOpCtnBsCardDAL.SaveFeeDR(headData, Convert.ToString(Session["USERID"]),feetype);
//202000727 保存后 如果DEST_RTCNT_TIME不为空 尝试更新op_seai.DEST_RTCNT_TIME
MsOpCtnBsCardDAL.UpdOpseaiDEST_RTCNT_TIME(headData);
MsOpCtnBsCardDAL.UpBsCtn(headData);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpCtnBsCardDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
var jsonRespose = new JsonResponse { Success = false, Message = errorstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult ShenReturn(string opstatus, string data, string data2, string data3, string data4, string type, string reason="")
{
var headData = JsonConvert.Deserialize<OpCtnBsCard>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", "").Replace("}", ",") + data4.Replace("{", ""));
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var GID = headData.GID;
if (type == "1")
{
var remarks = headData.REMARKS + " 申请返空信息: " + reason;
string blUpSQL = "update op_ctnbscard set AUDITSTATUS='申请返空',SHENTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',REMARKS='" + remarks + "' where GID='" + headData.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
else if (type == "0")
{
string blUpSQL = "update op_ctnbscard set AUDITSTATUS='未申请',SHENTIME=NULL where GID='" + headData.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
} else if (type == "3")
{
var remarks = headData.REMARKS + " 申请调拨信息: " + reason;
string blUpSQL = "update op_ctnbscard set AUDITSTATUS='申请调拨',SHENTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',REMARKS='" + remarks + "' where GID='" + headData.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
else if (type == "2")
{
string blUpSQL = "update op_ctnbscard set AUDITSTATUS='未申请',SHENTIME=NULL where GID='" + headData.GID + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var jsonRespose = new JsonResponse
{
Success =true,
Message ="申请成功!",
Data = MsOpCtnBsCardDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AuditReturn(string data, string type)
{
var headData = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = MsOpCtnBsCardDAL.AuditReturn(headData, type, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = null;
var errstr = "";
if (headData != null)
{
foreach (var enumValue in headData)
{
var isfee = MsOpCtnBsCardDAL.GetFeeCount(enumValue.GID);
if (isfee)
{
if (errstr == "")
errstr = enumValue.BSNO;
else
errstr = errstr + "," + enumValue.BSNO;
}
else {
result=MsOpCtnBsCardDAL.DeleteOpCtnBsCard(headData);
}
}
}
if (errstr != "")
{
var jsonRespose = new JsonResponse { Success =false, Message ="业务编号:"+errstr+" 存在操作引入费用,不允许删除!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult SubmitAudit(string bill,string type)
{
DBResult result = MsOpCtnBsCardDAL.SubmitAudit(bill, type);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult Audit(string bill, string type)
{
DBResult result = MsOpCtnBsCardDAL.Audit(bill, type);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult AuditPutCtn(string data, string type)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = MsOpCtnBsCardDAL.AuditPutCtn(bodyList, type, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult PutCtn(string data, string PutDate)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = MsOpCtnBsCardDAL.PutCtn(bodyList,"1", PutDate);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult CancelPutCtn(string data)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = MsOpCtnBsCardDAL.PutCtn(bodyList, "0","");
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult LockBs(string data)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = MsOpCtnBsCardDAL.LockBs(bodyList, "1");
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult CancelLockBs(string data)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = MsOpCtnBsCardDAL.LockBs(bodyList, "0");
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetOpCtnClearingList(int start, int limit, string condition, string sort)
{
var dataList = MsOpCtnBsCardDAL.GetOpCtnClearingList(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 };
}
public ContentResult GetOpCtnClearingListStr(string condition, string sort)
{
var dataListStr = MsOpCtnBsCardDAL.GetOpCtnClearingListStr(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult GetOpCtnDeliveryList(string condition, string sort)
{
var dataList = MsOpCtnBsCardDAL.GetOpCtnDeliveryList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetOpCtnRepairList(int start, int limit,string condition, string sort)
{
var dataList = MsOpCtnBsCardDAL.GetOpCtnRepairList(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 };
}
public ContentResult GetOpCtnRepairListStr(string condition, string sort)
{
var dataListStr = MsOpCtnBsCardDAL.GetOpCtnRepairListStr(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult GetOpCtnRepairListImg(string condition, string sort)
{
var dataList = MsOpCtnBsCardDAL.GetOpCtnRepairListImg(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult SaveOpCtnClearing(string body, string PID)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnClearing>>(body);
DBResult result = MsOpCtnBsCardDAL.SaveOpCtnClearing(bodyList, PID, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveOpCtnRepair(string body, string PID)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnRepair>>(body);
DBResult result = MsOpCtnBsCardDAL.SaveOpCtnRepair(bodyList, PID, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveOpCtnRepairImg(string body, string PID)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnRepairImg>>(body);
DBResult result = MsOpCtnBsCardDAL.SaveOpCtnRepairImg(bodyList, PID, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
[HttpPost]
public ContentResult UploadFile()
{
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["LoadFile"];
var GID = Request.Form["GID"];
var BSNO = Request.Form["BSNO"];
var type = Request.Form["type"];
if (file == null)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var path = Server.MapPath("../../UploadFiles/MsOpFiles/" + BSNO);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var size = file.ContentLength;
var name = Path.GetFileName(file.FileName);
var usercode = Convert.ToString(Session["USERCODE"]);
var partname = usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
string filename = path + "\\" + partname;
string filenameURL = "../../UploadFiles/MsOpFiles/" + BSNO + "/" + partname;
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 = "上传文件发生未知错误,请重新上传";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
try
{
var message = string.Empty;
DBResult isSucess = null;
if (type == "1" || type == "2")
isSucess = MsOpCtnBsCardDAL.UpdateRepairFileData(filenameURL, name, GID,type);
else if (type == "3" || type == "4"|| type == "5"|| type == "6")
isSucess = MsOpCtnBsCardDAL.UpdateClearingFileData(filenameURL, name, GID, type);
var json = JsonConvert.Serialize(new { success = isSucess.Success, Message = isSucess.Message, data = filename });
return new ContentResult() { Content = json };
}
catch (Exception)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传文件出错,请确认文件正确性";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult SaveOpCtnDelivery(string body, string PID)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnDelivery>>(body);
DBResult result = MsOpCtnBsCardDAL.SaveOpCtnDelivery(bodyList, PID, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteOpCtnClearing(string data)
{
var headData = JsonConvert.Deserialize<List<OpCtnClearing>>(data);
DBResult result = MsOpCtnBsCardDAL.DeleteOpCtnClearing(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteOpCtnDelivery(string data)
{
var headData = JsonConvert.Deserialize<List<OpCtnDelivery>>(data);
DBResult result = MsOpCtnBsCardDAL.DeleteOpCtnDelivery(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteOpCtnRepair(string data)
{
var headData = JsonConvert.Deserialize<List<OpCtnRepair>>(data);
DBResult result = MsOpCtnBsCardDAL.DeleteOpCtnRepair(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteOpCtnRepairImg(string data)
{
var headData = JsonConvert.Deserialize<List<OpCtnRepairImg>>(data);
DBResult result = MsOpCtnBsCardDAL.DeleteOpCtnRepairImg(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AuditOpCtnClearing(string data,string type)
{
var headData = JsonConvert.Deserialize<List<OpCtnClearing>>(data);
DBResult result = MsOpCtnBsCardDAL.AuditOpCtnClearing(headData, type, Convert.ToString(Session["SHOWNAME"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AuditOpCtnRepair(string data, string type)
{
var headData = JsonConvert.Deserialize<List<OpCtnRepair>>(data);
DBResult result = MsOpCtnBsCardDAL.AuditOpCtnRepair(headData, type, Convert.ToString(Session["SHOWNAME"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetBsList(string bsno)
{
var dataList = MsOpCtnBsCardDAL.GetBsList(bsno);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult CreateOpCtnRepairFromFee(string data)
{
var FeeList = JsonConvert.Deserialize<List<MsChFee>>(data);
DBResult result = MsOpCtnBsCardDAL.CreateOpCtnRepairFromFee(FeeList, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetYardRemark(string bsno)
{
DBResult result = MsOpCtnBsCardDAL.GetYardRemark(bsno, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message,Data=result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 周转率
public ContentResult GetRptCtnTurnOverData(int start, int limit, string condition,string startdate,string enddate,string sort, string printstr = "false")
{
var strSql = new StringBuilder();
strSql.Append(" SELECT CTNNO,SUM(DATEDIFF([day],STARTDATE,ENDDATE)) AS NOEMPTYDAY,DATEDIFF([day],'" + startdate + "','" + enddate + "') as ALLDAY,");
strSql.Append(" convert(decimal(10,2),convert(decimal(10,2),SUM(DATEDIFF([day],STARTDATE,ENDDATE)))/convert(decimal(10,2),DATEDIFF([day],'" + startdate + "','" + enddate + "'))*100) as TURNOVERRATE ");
strSql.Append(" from (SELECT CTNNO,CASE WHEN b.PORTLOAD_CNT_TIME<'" + startdate + "' THEN DATEADD(DAY,-1,'" + startdate + "') ELSE DATEADD(DAY,-8,b.PORTLOAD_CNT_TIME) END AS STARTDATE,");
strSql.Append(" CASE WHEN b.DEST_RTCNT_TIME>'" + enddate + "' THEN '" + enddate + "' ELSE b.DEST_RTCNT_TIME END AS ENDDATE ");
strSql.Append(" FROM op_ctnbscard b ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" ) X GROUP BY CTNNO ");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring + " ");
}
else
{
strSql.Append(" order by CTNNO ");
}
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(start, limit, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
}
#endregion
#region 字段锁定
public ContentResult GetLockField(string condition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT GID,FIELDNAME");
strSql.Append(" FROM op_ctnapply_lock ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" order by FIELDNAME");
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, 1000, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
public ContentResult UpdateFieldDate(string GID, string fieldname,string update)
{
var strupdate = update;
if (strupdate == "") strupdate = "null";
if (strupdate != "null") strupdate = "'" + strupdate + "'";
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var opList = GID.Split(',');
foreach (var opstr in opList)
{
var Currdata = MsOpCtnBsCardDAL.GetData("b.GID='" + opstr + "'", Session["USERID"].ToString());
Currdata.SetPropertyValue(fieldname, strupdate);
var msg = Currdata.CheckUPDDate();
if (!string.IsNullOrWhiteSpace(msg))
{
var jsonRespose1 = new JsonResponse
{
Success = false,
Message = msg,
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
}
string blUpSQL = " update op_ctnbscard set " + fieldname + "=" + strupdate + ",MODIFYTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',MODIFYUSER='" + Convert.ToString(Session["USERID"]) + "' where GID='" + opstr + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
var headData = MsOpCtnBsCardDAL.GetData("GID='" + opstr + "'", Convert.ToString(Session["USERID"]));
if (fieldname == "I_DEST_RTCNT_TIME" || fieldname == "DEST_RTCNT_TIME")
{
if (headData.IS_RETURE_EMPTY == true)
{
if (fieldname == "I_DEST_RTCNT_TIME" && update != "" && (Convert.ToDateTime(update) <= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))))
{
var vct = MsOpCtnBsCardDAL.GetRdCount("CTNNO='" + headData.CTNNO + "' and GID<>'" + headData.GID + "' AND (PORTLOAD_CNT_TIME>='" + update + "' OR PORTLOAD_CNT_TIME IS NULL)");
if (vct == 0)
{
MsOpCtnBsCardDAL.UpCtnStatus(headData.CTNNO);
}
}
}
else
{
if (fieldname == "DEST_RTCNT_TIME" && update != "" && (Convert.ToDateTime(update) <= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))))
{
var vct = MsOpCtnBsCardDAL.GetRdCount("CTNNO='" + headData.CTNNO + "' and GID<>'" + headData.GID + "' AND (PORTLOAD_CNT_TIME>='" + update + "' OR PORTLOAD_CNT_TIME IS NULL)");
if (vct == 0)
{
MsOpCtnBsCardDAL.UpCtnStatus(headData.CTNNO);
}
}
}
if (fieldname == "DEST_RTCNT_TIME")
{
MsOpCtnBsCardDAL.UpdOpseaiDEST_RTCNT_TIME(headData);
MsOpCtnBsCardDAL.UpBsCtn(headData,"2");
}
}
if (fieldname == "PORTLOAD_CNT_TIME")
{
MsOpCtnBsCardDAL.UpBsCtn(headData, "1");
}
}
var jsonRespose = new JsonResponse
{
Success = true,
Message = "提交成功!",
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult LockField(string GID, string fieldname)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var opList = GID.Split(',');
foreach (var opstr in opList)
{
string blUpSQL = "insert into op_ctnapply_lock(GID,BSNO,FIELDNAME) VALUES(NEWID(),'" + opstr + "','" + fieldname + "')";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var jsonRespose = new JsonResponse
{
Success = true,
Message = "提交成功!",
Data =""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult UnLockField(string GID, string fieldname)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var opList = GID.Split(',');
foreach (var opstr in opList)
{
string blUpSQL = "delete from op_ctnapply_lock where bsno='" + opstr + "' and FIELDNAME='" + fieldname + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var jsonRespose = new JsonResponse
{
Success = true,
Message = "提交成功!",
Data =""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 参照部分
#endregion
}
}