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.

3958 lines
192 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.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;
using DSWeb.MvcShipping.DAL.MsInfoClientMailProject;
using DSWeb.MvcShipping.Models.MsOpMailSend;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using ICSharpCode.SharpZipLib.Zip;
using Microsoft.Office.Interop.Excel;
using DSWeb.MvcContainer.DAL.MsOpPrice;
using SevenZip;
using DSWeb.MvcContainer.DAL.MsCodeCtnTk;
using DSWeb.MvcShipping.DAL.MsChFeeDAL;
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 InsuranceIndex()
{
return View();
}
public ActionResult InsuranceEdit()
{
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 CtnStatusDetailDb()
{
return View();
}
public ActionResult ReturnAudit()
{
return View();
}
public ActionResult ChfeeAudit()
{
return View();
}
public ActionResult CtnStatusFee()
{
return View();
}
public ActionResult CtnStatusFee2()
{
return View();
}
public ActionResult RptRepair()
{
return View();
}
public ActionResult RptCtnTurnOver()
{
return View();
}
public ActionResult PiLiangFeeEdit()
{
return View();
}
public ActionResult PiLiangRepairClearing()
{
return View();
}
public ActionResult ChfeeEdit()
{
return View();
}
public ActionResult ZipView()
{
return View();
}
public ActionResult UpLoadFile()
{
return View();
}
public ActionResult UpLoadFileEdit()
{
return View();
}
public ActionResult LogView()
{
return View();
}
public ActionResult CqRptIndex()
{
return View();
}
public ActionResult FeeSumIndex()
{
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 GetAuditDataList(int start, int limit, string sort, string condition, string pricetype)
{
int total = 0;
var dataList = MsOpCtnBsCardDAL.GetAuditDataList(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 GetAuditDataListStr(string sort, string condition, string pricetype)
{
var dataListStr = MsOpCtnBsCardDAL.GetAuditDataListStr(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 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 GetCqDataList(int start, int limit, string sort, string condition, string objname)
{
int total = 1;
var dataList = MsOpCtnBsCardDAL.GetCqDataList( condition, objname, 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 GetCqDataListStr(string sort, string condition, string objname)
{
var dataListStr = MsOpCtnBsCardDAL.GetCqDataListStr(condition, objname, 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)
{
int total = 0;
var dataList = MsOpCtnBsCardDAL.GetDataFeeList(start, limit,out total,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 = total, data = dataList.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 GetDataFeeSumList(int start, int limit, int beforenum, int afternum, string condition, string datetype, string sort, string printstr = "false")
{
var strSql = new StringBuilder();
var datetimestr = DateTime.Now.ToString("yyyyMMddhhmmss");
int linenum = beforenum + afternum + 1;
strSql.Append(" select row_number() over (partition by CTNGID order by ROWNO DESC) as ROWNUM,*,PROFITINUSD-RENTPROFITINUSD OPPROFITINUSD into #opctnbscardfee_"+ datetimestr + " from ");
strSql.Append("(");
if (datetype=="CTN")
strSql.Append("SELECT F.*, F.CNTCYCLE_DAY CYCLE_DAY,CASE WHEN ISNULL(F.CNTCYCLE_DAY,0)=0 THEN 0 ELSE F.PROFITINUSD / F.CNTCYCLE_DAY END DAYPROFITINUSD, F.CNTCYCLE_DAY * (CASE WHEN ISNULL(F.CTNRENT, '') = '' THEN 0 ELSE cast(F.CTNRENT AS numeric(20, 2)) END) RENTPROFITINUSD FROM V_OP_BSCARD_FEE2 F");
else
strSql.Append("SELECT F.*,F.ETDCYCLE_DAY CYCLE_DAY,CASE WHEN ISNULL(F.ETDCYCLE_DAY,0)=0 THEN 0 ELSE F.PROFITINUSD / F.ETDCYCLE_DAY END DAYPROFITINUSD, F.ETDCYCLE_DAY * (CASE WHEN ISNULL(F.CTNRENT, '') = '' THEN 0 ELSE cast(F.CTNRENT AS numeric(20, 2)) END) RENTPROFITINUSD FROM V_OP_BSCARD_FEE2 F");
strSql.Append(" LEFT JOIN(SELECT * from v_op_ctnbscard B");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(") V ON(F.CTNGID= V.CTNGID AND ((V.ROWNO<= F.ROWNO + "+ afternum + " AND V.ROWNO >= F.ROWNO) OR(V.ROWNO >= F.ROWNO - "+ beforenum + " AND V.ROWNO <= F.ROWNO)))");
strSql.Append(" WHERE V.GID IS NOT NULL");
strSql.Append(") as v order by ctngid,ROWNO DESC");
strSql.Append(" SELECT CTNGID,MAX(CTNNO) CTNNO ");
for (int i = 1; i <= linenum; i++)
{
strSql.Append(" ,MAX(LINES" + i+") AS LINES"+i);
strSql.Append(",SUM(CTNNUM" + i + ") CTNNUM" + i);
strSql.Append(" ,SUM(GXFUSDDR" + i + " ) GXFUSDDR" + i);
strSql.Append(" ,SUM(XSFDRTTLINUSD" + i + ") XSFDRTTLINUSD" + i);
strSql.Append(" ,SUM(HDFDR" + i + ") HDFDR" + i);
strSql.Append(" ,SUM(OTDRTTLINUSD" + i + " ) OTDRTTLINUSD" + i);
strSql.Append(" ,SUM(TTLCRINUSD" + i + ") TTLCRINUSD" + i);
strSql.Append(" ,SUM(PROFITINUSD" + i + ") PROFITINUSD" + i);
strSql.Append(" ,SUM(CYCLE_DAY" + i + ") CYCLE_DAY" + i);
strSql.Append(" ,CASE WHEN SUM(CYCLE_DAY" + i + ")=0 THEN 0 ELSE SUM(PROFITINUSD" + i + ") /SUM(CYCLE_DAY" + i + ") END DAYPROFITINUSD" + i);
}
strSql.Append(" ,CASE WHEN SUM(TTLCYCLE_DAY)=0 THEN 0 ELSE SUM(TTLPROFITINUSD) /SUM(TTLCYCLE_DAY) END TTLDAYPROFITINUSD");
strSql.Append(" FROM (SELECT CTNGID,CTNNO ");
for (int i = 1; i <= linenum; i++)
{
strSql.Append(" ,CASE WHEN ROWNUM="+i+" THEN LINES ELSE '' END LINES"+i);
strSql.Append(",SUM(CASE WHEN ROWNUM=" + i + " THEN 1 ELSE 0 END) CTNNUM" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN GXFUSDDR ELSE 0 END) GXFUSDDR" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN XSFDRTTLINUSD ELSE 0 END) XSFDRTTLINUSD" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN HDFDR ELSE 0 END) HDFDR" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN OTDRTTLINUSD ELSE 0 END) OTDRTTLINUSD" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN TTLCRINUSD ELSE 0 END) TTLCRINUSD" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN PROFITINUSD ELSE 0 END) PROFITINUSD" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN CNTCYCLE_DAY ELSE 0 END) CYCLE_DAY" + i);
strSql.Append(" ,CASE WHEN SUM(CASE WHEN ROWNUM=" + i + " THEN CYCLE_DAY ELSE 0 END)=0 THEN 0 " );
strSql.Append("ELSE SUM(CASE WHEN ROWNUM=" + i + " THEN PROFITINUSD ELSE 0 END)/SUM(CASE WHEN ROWNUM="+i+" THEN CYCLE_DAY ELSE 0 END) END DAYPROFITINUSD" + i);
}
strSql.Append(" ,SUM(CNTCYCLE_DAY) TTLCYCLE_DAY");
strSql.Append(" ,SUM(PROFITINUSD) TTLPROFITINUSD");
strSql.Append(" FROM #opctnbscardfee_" + datetimestr);
strSql.Append(" GROUP BY CTNGID,CTNNO,LINES,ROWNUM ");
strSql.Append(") AS V ");
strSql.Append(" GROUP BY CTNGID ");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring + " ");
}
else
{
strSql.Append(" order by CTNGID ");
}
strSql.Append(" drop table #opctnbscardfee_" + datetimestr);
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 GetDataFeeSum(int beforenum, int afternum, string condition, string datetype, string sort, string printstr = "false")
{
var strSql = new StringBuilder();
var datetimestr = DateTime.Now.ToString("yyyyMMddhhmmss");
int linenum = beforenum + afternum + 1;
strSql.Append(" select row_number() over (partition by CTNGID order by ROWNO DESC) as ROWNUM,*,PROFITINUSD-RENTPROFITINUSD OPPROFITINUSD into #opctnbscardfee_" + datetimestr + " from ");
strSql.Append("(");
if (datetype == "CTN")
strSql.Append("SELECT F.*, F.CNTCYCLE_DAY CYCLE_DAY,CASE WHEN ISNULL(F.CNTCYCLE_DAY,0)=0 THEN 0 ELSE F.PROFITINUSD / F.CNTCYCLE_DAY END DAYPROFITINUSD, F.CNTCYCLE_DAY * (CASE WHEN ISNULL(F.CTNRENT, '') = '' THEN 0 ELSE cast(F.CTNRENT AS numeric(20, 2)) END) RENTPROFITINUSD FROM V_OP_BSCARD_FEE2 F");
else
strSql.Append("SELECT F.*,F.ETDCYCLE_DAY CYCLE_DAY,CASE WHEN F.ETDCYCLE_DAY=0 THEN 0 ELSE F.PROFITINUSD / F.ETDCYCLE_DAY END DAYPROFITINUSD, F.ETDCYCLE_DAY * (CASE WHEN ISNULL(F.CTNRENT, '') = '' THEN 0 ELSE cast(F.CTNRENT AS numeric(20, 2)) END) RENTPROFITINUSD FROM V_OP_BSCARD_FEE2 F");
strSql.Append(" LEFT JOIN(SELECT* from v_op_ctnbscard B");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(") V ON(F.CTNGID= V.CTNGID AND ((V.ROWNO<= F.ROWNO + " + afternum + " AND V.ROWNO >= F.ROWNO) OR(V.ROWNO >= F.ROWNO - " + beforenum + " AND V.ROWNO <= F.ROWNO)))");
strSql.Append(" WHERE V.GID IS NOT NULL");
strSql.Append(") as v order by ctngid,ROWNO DESC");
strSql.Append(" SELECT ");
for (int i = 1; i <= linenum; i++)
{
if (i == 1)
strSql.Append(" LINES" + i);
else
strSql.Append(",LINES" + i);
strSql.Append(",SUM(CTNNUM" + i + ") CTNNUM" + i);
strSql.Append(" ,SUM(GXFUSDDR" + i + " ) GXFUSDDR" + i);
strSql.Append(" ,SUM(XSFDRTTLINUSD" + i + ") XSFDRTTLINUSD" + i);
strSql.Append(" ,SUM(HDFDR" + i + ") HDFDR" + i);
strSql.Append(" ,SUM(OTDRTTLINUSD" + i + " ) OTDRTTLINUSD" + i);
strSql.Append(" ,SUM(TTLCRINUSD" + i + ") TTLCRINUSD" + i);
strSql.Append(" ,SUM(PROFITINUSD" + i + ") PROFITINUSD" + i);
strSql.Append(" ,SUM(CYCLE_DAY" + i + ") CYCLE_DAY" + i);
strSql.Append(" ,CASE WHEN SUM(CYCLE_DAY" + i + ")=0 THEN 0 ELSE SUM(PROFITINUSD" + i + ") /SUM(CYCLE_DAY" + i + ") END DAYPROFITINUSD" + i);
}
strSql.Append(" ,CASE WHEN SUM(TTLCYCLE_DAY)=0 THEN 0 ELSE SUM(TTLPROFITINUSD) /SUM(TTLCYCLE_DAY) END TTLDAYPROFITINUSD");
strSql.Append(" FROM ( ");
strSql.Append(" SELECT CTNGID,MAX(CTNNO) CTNNO ");
for (int i = 1; i <= linenum; i++)
{
strSql.Append(" ,MAX(LINES" + i + ") AS LINES" + i);
strSql.Append(",SUM(CTNNUM" + i + ") CTNNUM" + i);
strSql.Append(" ,SUM(GXFUSDDR" + i + " ) GXFUSDDR" + i);
strSql.Append(" ,SUM(XSFDRTTLINUSD" + i + ") XSFDRTTLINUSD" + i);
strSql.Append(" ,SUM(HDFDR" + i + ") HDFDR" + i);
strSql.Append(" ,SUM(OTDRTTLINUSD" + i + " ) OTDRTTLINUSD" + i);
strSql.Append(" ,SUM(TTLCRINUSD" + i + ") TTLCRINUSD" + i);
strSql.Append(" ,SUM(PROFITINUSD" + i + ") PROFITINUSD" + i);
strSql.Append(" ,SUM(CYCLE_DAY" + i + ") CYCLE_DAY" + i);
strSql.Append(" ,CASE WHEN SUM(CYCLE_DAY" + i + ")=0 THEN 0 ELSE SUM(PROFITINUSD" + i + ") /SUM(CYCLE_DAY" + i + ") END DAYPROFITINUSD" + i);
}
strSql.Append(" ,SUM(TTLCYCLE_DAY) TTLCYCLE_DAY");
strSql.Append(" ,SUM(TTLPROFITINUSD) TTLPROFITINUSD");
strSql.Append(" FROM (SELECT CTNGID,CTNNO ");
for (int i = 1; i <= linenum; i++)
{
strSql.Append(" ,CASE WHEN ROWNUM=" + i + " THEN LINES ELSE '' END LINES" + i);
strSql.Append(",SUM(CASE WHEN ROWNUM=" + i + " THEN 1 ELSE 0 END) CTNNUM" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN GXFUSDDR ELSE 0 END) GXFUSDDR" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN XSFDRTTLINUSD ELSE 0 END) XSFDRTTLINUSD" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN HDFDR ELSE 0 END) HDFDR" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN OTDRTTLINUSD ELSE 0 END) OTDRTTLINUSD" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN TTLCRINUSD ELSE 0 END) TTLCRINUSD" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN PROFITINUSD ELSE 0 END) PROFITINUSD" + i);
strSql.Append(" ,SUM(CASE WHEN ROWNUM=" + i + " THEN CNTCYCLE_DAY ELSE 0 END) CYCLE_DAY" + i);
strSql.Append(" ,CASE WHEN SUM(CASE WHEN ROWNUM=" + i + " THEN CYCLE_DAY ELSE 0 END)=0 THEN 0 ");
strSql.Append("ELSE SUM(CASE WHEN ROWNUM=" + i + " THEN PROFITINUSD ELSE 0 END)/SUM(CASE WHEN ROWNUM=" + i + " THEN CYCLE_DAY ELSE 0 END) END DAYPROFITINUSD" + i);
}
strSql.Append(" ,SUM(CNTCYCLE_DAY) TTLCYCLE_DAY");
strSql.Append(" ,SUM(PROFITINUSD) TTLPROFITINUSD");
strSql.Append(" FROM #opctnbscardfee_" + datetimestr);
strSql.Append(" GROUP BY CTNGID,CTNNO,LINES,ROWNUM ");
strSql.Append(") AS V ");
strSql.Append(" GROUP BY CTNGID ");
strSql.Append(") AS Z GROUP BY ");
for (int i = 1; i <= linenum; i++)
{
if (i==1)
strSql.Append(" LINES" + i);
else
strSql.Append(" ,LINES" + i);
}
//var sortstring = DatasetSort.Getsortstring(sort);
//if (!string.IsNullOrEmpty(sortstring))
//{
// strSql.Append(" order by " + sortstring + " ");
//}
//else
//{
// strSql.Append(" order by CTNGID ");
//}
strSql.Append(" drop table #opctnbscardfee_" + datetimestr);
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, 1000000, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
}
#region 空返明细
public ContentResult GetRtDataList(int start, int limit, string sort, string condition, string pricetype)
{
var dataList = MsOpCtnBsCardDAL.GetRtDataList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetRtData(string handle, string condition)
{
OpCtnBsCardDetail head = null;
if (handle == "edit")
{
head = MsOpCtnBsCardDAL.GetRtData(condition, Convert.ToString(Session["USERID"]));
}
if (head == null)
{
head = new OpCtnBsCardDetail();
head.GID= Guid.NewGuid().ToString();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult SaveRt(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<OpCtnBsCardDetail>(data);
var errorstr = "";
var isPost = true;
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.CREATEUSER= Convert.ToString(Session["USERID"]);
headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
headData.MODIFIEDUSER= Convert.ToString(Session["USERID"]);
headData.MODIFIEDTIME = 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.ETD == "") headData.ETD = null;
if (headData.ETA == "") headData.ETA = null;
if (headData.PREETA == "") headData.PREETA = 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.CLEARNTIME == "") headData.CLEARNTIME = null;
if (headData.PREETD == "") headData.PREETD = null;
if (isPost)
{
if (opstatus == "edit")
{
var OLDHEAD = MsOpCtnBsCardDAL.GetRtData("GID='" + headData.GID + "'", Convert.ToString(Session["USERID"]));
if (OLDHEAD.DEST_CNT_TIME != headData.DEST_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "目的港提箱日期", OLDHEAD.DEST_CNT_TIME, headData.DEST_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.DEST_RTCNT_TIME != headData.DEST_RTCNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "目的港还箱日期", OLDHEAD.DEST_RTCNT_TIME, headData.DEST_RTCNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
var modb = new ModelObjectDB();
var result = modb.Save(headData);
if (result.Success)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
if (!string.IsNullOrEmpty(headData.PORTLOAD_CNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='PORTLOAD_CNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','PORTLOAD_CNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.ETD))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='ETD') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','ETD',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.ETA))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='ETA') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','ETA',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.DEST_CNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='DEST_CNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','DEST_CNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.DEST_RTCNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='DEST_RTCNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','DEST_RTCNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
else if (headData.IS_POD_CLEAN)
{
string blUpSQLC = "update op_ctnclearing set CURSTATOIN=B.I_DESTPORT_STATOIN,INSTATOINTIME=B.I_DEST_RTCNT_TIME FROM op_ctnclearing C LEFT JOIN op_ctnbscard B ON (B.GID=C.LINKGID) WHERE C.LINKGID='" + headData.GID + "'";
bool bl2C = T_ALL_DA.GetExecuteSqlCommand(blUpSQLC);
string blUpSQLC3 = "update op_ctnrepair set REPAIRTIME=CASE WHEN B.I_DEST_RTCNT_TIME='' THEN NULL ELSE B.I_DEST_RTCNT_TIME END,CURSTATOIN=B.I_DESTPORT_STATOIN FROM op_ctnrepair C LEFT JOIN op_ctnbscard B ON (B.GID=C.LINKGID) WHERE C.FEENAME IN (SELECT [NAME] from code_fee WHERE FEEGROUP='维修') AND C.LINKGID='" + headData.GID + "'";
bool bl23 = T_ALL_DA.GetExecuteSqlCommand(blUpSQLC3);
}
string blUpSQLC2 = "update op_ctnrepair set REPAIRTIME=CASE WHEN B.PORTLOAD_CNT_TIME='' THEN NULL ELSE B.PORTLOAD_CNT_TIME END,CURSTATOIN=B.PORTLOAD_STATOIN FROM op_ctnrepair C LEFT JOIN op_ctnbscard B ON (B.GID=C.LINKGID) WHERE C.FEENAME IN(SELECT[NAME] from code_fee WHERE FEEGROUP= '改装') AND C.LINKGID='" + headData.GID + "'";
bool bl22 = T_ALL_DA.GetExecuteSqlCommand(blUpSQLC2);
}
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) };
}
}
#endregion
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,DESTPORT VDESTPORT,COUNTRY,AGENTNAME,SUM(PLANUSEYARDCTN+CANUSEYARDCTN) YARDCTN,SUM(CANUSEYARDCTN) CANUSEYARDCTN,SUM(CANUSEONTHEWAYCTN) CANUSEONTHEWAYCTN,SUM(CANUSEONTHERETURE) CANUSEONTHERETURE,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,CASE WHEN SUM(CANUSEYARDCTN30)=0 THEN 0 ELSE SUM(CANUSEYARDCTN30DAY)/SUM(CANUSEYARDCTN30) END CANUSEYARDCTN30DAY FROM (");
strSql.Append(" SELECT VDESTPORT DESTPORT,isnull(VCOUNTRY,'') COUNTRY,(CASE WHEN PORTLOAD_CNT_TIME IS NULL AND ETD IS NULL THEN CUSTOMERNAME ELSE CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE AGENTNAME END 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");
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) 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(" , SUM(CASE WHEN (ISNULL(IS_RETURE_EMPTY,0)=1 AND DEST_RTCNT_TIME IS NOT NULL AND I_PORTLOAD_CNT_TIME IS NULL) THEN 1 ELSE 0 END) AS CANUSEONTHERETURE");
strSql.Append(",(SELECT SUM(CTNNUM) FROM op_ctnapply WHERE AUDITSTATUS='审核通过' AND OWNERCTN='恒成' AND GID NOT IN (SELECT LINKGID FROM op_ctnapplyctnitems) 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,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(",SUM(CASE WHEN VDEST_RTCNT_TIME IS NOT NULL AND CTNSTATUS='可用' and DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE())>30 THEN DATEDIFF (dd ,VDEST_RTCNT_TIME,GETDATE()) ELSE 0 END) AS CANUSEYARDCTN30DAY");
strSql.Append(" FROM #top_opctnbscard b ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" GROUP BY VDESTPORT,VCOUNTRY,(CASE WHEN PORTLOAD_CNT_TIME IS NULL AND ETD IS NULL THEN CUSTOMERNAME ELSE CASE WHEN ISNULL(IS_RETURE_EMPTY,0)=1 THEN '' ELSE AGENTNAME END END),IS_RETURE_EMPTY,AGENTNAME ");
strSql.Append(" ) 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 GetRptCtnStatusListStr(string sort, string condition)
{
var dataListStr = MsOpCtnBsCardDAL.GetRptCtnStatusListStr(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功",data = dataListStr });
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.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 && headData.IS_RETURE_EMPTY)
{
if ((!string.IsNullOrEmpty(headData.I_PORTLOAD_CNT_TIME)) && !string.IsNullOrEmpty(headData.D_PORTLOAD_CNT_TIME))
{
if (Convert.ToDateTime(headData.D_PORTLOAD_CNT_TIME) < Convert.ToDateTime(headData.I_PORTLOAD_CNT_TIME))
headData.IDTYPE = "调拨-空返";
}
else
{
}
if (headData.IDTYPE == "调拨-空返")
{
if ((!string.IsNullOrEmpty(headData.I_PORTLOAD_CNT_TIME)) && !string.IsNullOrEmpty(headData.D_DEST_RTCNT_TIME))
{
if (Convert.ToDateTime(headData.I_PORTLOAD_CNT_TIME) < Convert.ToDateTime(headData.D_DEST_RTCNT_TIME)) {
errorstr = "空返提箱日期不能小于调拨目的港返箱日期";
isPost = false;
}
}
}
else {
if ((!string.IsNullOrEmpty(headData.D_PORTLOAD_CNT_TIME)) && !string.IsNullOrEmpty(headData.I_DEST_RTCNT_TIME))
{
if (Convert.ToDateTime(headData.D_PORTLOAD_CNT_TIME) < Convert.ToDateTime(headData.I_DEST_RTCNT_TIME))
{
errorstr = "调拨提箱日期不能小于空返目的港返箱日期";
isPost = false;
}
}
}
}
else
{
}
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_PORTLOAD ="";
headData.I_DESTPORT ="";
headData.I_DESTPORT_STATOIN= "";
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.I_PREETD == "") headData.I_PREETD = 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 (headData.CLEARNTIME == "") headData.CLEARNTIME = null;
if (headData.I_CLEARNTIME == "") headData.I_CLEARNTIME = null;
if (headData.D_CLEARNTIME == "") headData.D_CLEARNTIME = null;
if (headData.PREETD == "") headData.PREETD = null;
if (headData.N_DELIVERYDATE == "") headData.N_DELIVERYDATE = null;
if (headData.RTCTNDATE == "") headData.RTCTNDATE = null;
if (isPost)
{
if (opstatus == "edit") {
var OLDHEAD = MsOpCtnBsCardDAL.GetData("GID='" + headData.GID + "'", Convert.ToString(Session["USERID"]));
if (OLDHEAD.DEST_CNT_TIME!=headData.DEST_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID,"OP_CTNBSCARD", "目的港提箱日期", OLDHEAD.DEST_CNT_TIME,headData.DEST_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.DEST_RTCNT_TIME != headData.DEST_RTCNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "目的港还箱日期", OLDHEAD.DEST_RTCNT_TIME, headData.DEST_RTCNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.I_DEST_CNT_TIME != headData.I_DEST_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "空返目的港提箱日期", OLDHEAD.I_DEST_CNT_TIME, headData.I_DEST_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.I_DEST_RTCNT_TIME != headData.I_DEST_RTCNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "空返目的港还箱日期", OLDHEAD.I_DEST_RTCNT_TIME, headData.I_DEST_RTCNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.D_DEST_CNT_TIME != headData.D_DEST_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "调拨目的港提箱日期", OLDHEAD.D_DEST_CNT_TIME, headData.D_DEST_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.D_DEST_RTCNT_TIME != headData.D_DEST_RTCNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "调拨目的港还箱日期", OLDHEAD.D_DEST_RTCNT_TIME, headData.D_DEST_RTCNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.PORTLOAD_CNT_TIME != headData.PORTLOAD_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "起运港提箱日期", OLDHEAD.PORTLOAD_CNT_TIME, headData.PORTLOAD_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.I_PORTLOAD_CNT_TIME != headData.I_PORTLOAD_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "空返起运港提箱日期", OLDHEAD.I_PORTLOAD_CNT_TIME, headData.I_PORTLOAD_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.D_PORTLOAD_CNT_TIME != headData.D_PORTLOAD_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "调拨起运港提箱日期", OLDHEAD.D_PORTLOAD_CNT_TIME, headData.D_PORTLOAD_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.ETD != headData.ETD)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "开船日期", OLDHEAD.ETD, headData.ETD, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.I_ETD != headData.I_ETD)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "空返开船日期", OLDHEAD.I_ETD, headData.I_ETD, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.D_ETD != headData.D_ETD)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "调拨开船日期", OLDHEAD.D_ETD, headData.D_ETD, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.ETA != headData.ETA)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "到港日期", OLDHEAD.ETA, headData.ETA, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.I_ETA != headData.I_ETA)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "空返到港日期", OLDHEAD.I_ETA, headData.I_ETA, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
if (OLDHEAD.D_ETA != headData.D_ETA)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "调拨到港日期", OLDHEAD.D_ETA, headData.D_ETA, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
var modb = new ModelObjectDB();
var result = modb.Save(headData);
if (result.Success) {
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
if (iscreatefee)
MsOpCtnBsCardDAL.SaveFeeDR(headData, Convert.ToString(Session["USERID"]),feetype);
if (!string.IsNullOrEmpty(headData.PORTLOADDATE))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='PORTLOADDATE') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','PORTLOADDATE',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.PORTLOAD_CNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='PORTLOAD_CNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','PORTLOAD_CNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.ETD))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='ETD') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','ETD',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.ETA))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='ETA') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','ETA',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.DEST_CNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='DEST_CNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','DEST_CNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.DEST_RTCNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='DEST_RTCNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','DEST_RTCNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.I_PORTLOAD_CNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='I_PORTLOAD_CNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','I_PORTLOAD_CNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.I_ETD))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='I_ETD') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','I_ETD',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.I_ETA))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='I_ETA') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','I_ETA',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.I_DEST_CNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='I_DEST_CNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','I_DEST_CNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.I_DEST_RTCNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='I_DEST_RTCNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','I_DEST_RTCNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.D_PORTLOAD_CNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='D_PORTLOAD_CNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','D_PORTLOAD_CNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.D_ETD))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='D_ETD') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','D_ETD',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.D_ETA))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='D_ETA') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','D_ETA',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.D_DEST_CNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='D_DEST_CNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','D_DEST_CNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
if (!string.IsNullOrEmpty(headData.D_DEST_RTCNT_TIME))
{
string blUpSQL2 = "if (select GID from op_ctnapply_lock where bsno='" + headData.GID + "' AND FIELDNAME='D_DEST_RTCNT_TIME') is null insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID(),'" + headData.GID + "','D_DEST_RTCNT_TIME',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
//202000727 保存后 如果DEST_RTCNT_TIME不为空 尝试更新op_seai.DEST_RTCNT_TIME
//MsOpCtnBsCardDAL.UpdOpseae(headData);
MsOpCtnBsCardDAL.UpdOpseaiDEST_RTCNT_TIME(headData);
MsOpCtnBsCardDAL.UpBsCtn(headData);
MsOpCtnBsCardDAL.UpBsCtnClearRepair(headData.GID);
var TOPGID = T_ALL_DA.GetStrSQL("GID", " select GID from v_top_opctnbscard WHERE CTNNO='"+ headData.CTNNO+ "' ");
if (!string.IsNullOrEmpty(TOPGID)) {
var EXSITSIPHONPIPE = "0";
if (headData.EXSITSIPHONPIPE) EXSITSIPHONPIPE = "1";
var EXSITPRESSUREGAUGE = "0";
if (headData.EXSITPRESSUREGAUGE) EXSITPRESSUREGAUGE = "1";
var EXSITTOPOVERFLOWBOX = "0";
if (headData.EXSITTOPOVERFLOWBOX) EXSITTOPOVERFLOWBOX = "1";
var EXSITINTOOVERFLOWBOX = "0";
if (headData.EXSITINTOOVERFLOWBOX) EXSITINTOOVERFLOWBOX = "1";
var EXSITBOTTONVALVEDUSTCOVER = "0";
if (headData.EXSITBOTTONVALVEDUSTCOVER) EXSITBOTTONVALVEDUSTCOVER = "1";
var IS3TO2VALVE = "0";
if (headData.IS3TO2VALVE) IS3TO2VALVE = "1";
string blUpSQL = "update code_ctntk set TOPVALVE='"+headData.TOPVALVE+ "',EXSITSIPHONPIPE="+ EXSITSIPHONPIPE + ",EXSITPRESSUREGAUGE=" + EXSITPRESSUREGAUGE + ",EXSITTOPOVERFLOWBOX=" +EXSITTOPOVERFLOWBOX + ",EXSITINTOOVERFLOWBOX=" +EXSITINTOOVERFLOWBOX + ",EXSITBOTTONVALVEDUSTCOVER=" +EXSITBOTTONVALVEDUSTCOVER + ",IS3TO2VALVE=" + IS3TO2VALVE + ",HANDRAIL='" + headData.HANDRAIL + "' where CTNNO='" + headData.CTNNO + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
//string blUpSQL3 = "update op_ctnapply set TRANSTYPE='" + headData.TRANSTYPE + "' where BSNO='" + headData.APPLYNO + "'";
//bool bl3= T_ALL_DA.GetExecuteSqlCommand(blUpSQL3);
if (headData.IS_DB&&headData.D_IS_POD_CLEAN)
{
string blUpSQLC = "update op_ctnclearing set CURSTATOIN=B.D_DESTPORT_STATOIN,INSTATOINTIME=B.D_DEST_RTCNT_TIME FROM op_ctnclearing C LEFT JOIN op_ctnbscard B ON (B.GID=C.LINKGID) WHERE C.LINKGID='" + headData.GID + "'";
bool bl2C = T_ALL_DA.GetExecuteSqlCommand(blUpSQLC);
string blUpSQLC3 = "update op_ctnrepair set REPAIRTIME=CASE WHEN B.D_DEST_RTCNT_TIME='' THEN NULL ELSE B.D_DEST_RTCNT_TIME END,CURSTATOIN=B.D_DESTPORT_STATOIN FROM op_ctnrepair C LEFT JOIN op_ctnbscard B ON (B.GID=C.LINKGID) WHERE C.FEENAME IN (SELECT [NAME] from code_fee WHERE FEEGROUP='维修') AND C.LINKGID='" + headData.GID + "'";
bool bl23 = T_ALL_DA.GetExecuteSqlCommand(blUpSQLC3);
}
else if (headData.IS_RETURE_EMPTY&& headData.I_IS_POD_CLEAN)
{
string blUpSQLC = "update op_ctnclearing set CURSTATOIN=B.I_DESTPORT_STATOIN,INSTATOINTIME=B.I_DEST_RTCNT_TIME FROM op_ctnclearing C LEFT JOIN op_ctnbscard B ON (B.GID=C.LINKGID) WHERE C.LINKGID='" + headData.GID + "'";
bool bl2C = T_ALL_DA.GetExecuteSqlCommand(blUpSQLC);
string blUpSQLC3 = "update op_ctnrepair set REPAIRTIME=CASE WHEN B.I_DEST_RTCNT_TIME='' THEN NULL ELSE B.I_DEST_RTCNT_TIME END,CURSTATOIN=B.I_DESTPORT_STATOIN FROM op_ctnrepair C LEFT JOIN op_ctnbscard B ON (B.GID=C.LINKGID) WHERE C.FEENAME IN (SELECT [NAME] from code_fee WHERE FEEGROUP='维修') AND C.LINKGID='" + headData.GID + "'";
bool bl23 = T_ALL_DA.GetExecuteSqlCommand(blUpSQLC3);
}
else
{
string blUpSQLC = "update op_ctnclearing set CURSTATOIN=B.DESTPORT_STATOIN,INSTATOINTIME=B.DEST_RTCNT_TIME FROM op_ctnclearing C LEFT JOIN op_ctnbscard B ON (B.GID=C.LINKGID) WHERE C.LINKGID='" + headData.GID + "'";
bool bl2C = T_ALL_DA.GetExecuteSqlCommand(blUpSQLC);
string blUpSQLC3 = "update op_ctnrepair set REPAIRTIME=CASE WHEN B.DEST_RTCNT_TIME='' THEN NULL ELSE B.DEST_RTCNT_TIME END,CURSTATOIN=B.D_DESTPORT_STATOIN FROM op_ctnrepair C LEFT JOIN op_ctnbscard B ON (B.GID=C.LINKGID) WHERE C.FEENAME IN (SELECT [NAME] from code_fee WHERE FEEGROUP='维修') AND C.LINKGID='" + headData.GID + "'";
bool bl23 = T_ALL_DA.GetExecuteSqlCommand(blUpSQLC3);
}
string blUpSQLC2 = "update op_ctnrepair set REPAIRTIME=CASE WHEN B.PORTLOAD_CNT_TIME='' THEN NULL ELSE B.PORTLOAD_CNT_TIME END,CURSTATOIN=B.PORTLOAD_STATOIN FROM op_ctnrepair C LEFT JOIN op_ctnbscard B ON (B.GID=C.LINKGID) WHERE C.FEENAME IN(SELECT[NAME] from code_fee WHERE FEEGROUP= '改装') AND C.LINKGID='" + headData.GID + "'";
bool bl22 = T_ALL_DA.GetExecuteSqlCommand(blUpSQLC2);
}
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 SaveDCFeeCR(string GID)
{
var headData = MsOpCtnBsCardDAL.GetData("GID='"+GID+"'","", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
DBResult result = MsOpCtnBsCardDAL.SaveDCFeeCR(headData, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveNLYFeeDR(string GID)
{
var headData = MsOpCtnBsCardDAL.GetData("GID='" + GID + "'", "", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
DBResult result = MsOpCtnBsCardDAL.SaveNLYFeeDR(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveNLYFeeDRPL(string data)
{
var headList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = new DBResult();
foreach (var headData in headList)
{
result = MsOpCtnBsCardDAL.SaveNLYFeeDR(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveDCFeeCRPL(string data)
{
var headList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = new DBResult();
foreach (var headData in headList)
{
result = MsOpCtnBsCardDAL.SaveDCFeeCR(headData, Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveFeeDRPL(string data,string feetype)
{
var headList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = new DBResult();
foreach (var headData in headList)
{
result = MsOpCtnBsCardDAL.SaveFeeDR(headData, Convert.ToString(Session["USERID"]), feetype);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetRtCtnFee(string handle, string condition)
{
OpCtnBsCardRtCtnFee head = null;
if (handle == "edit")
{
head = MsOpCtnBsCardDAL.GetRtCtnFee(condition);
}
if (head == null)
{
head = new OpCtnBsCardRtCtnFee();
head.GID = Guid.NewGuid().ToString();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult SaveGZFeeDRPL(string data, string closedate, string startdate)
{
var headList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = new DBResult();
foreach (var headData in headList)
{
result = MsOpCtnBsCardDAL.SaveGZFeeDR(headData, closedate, startdate,Convert.ToString(Session["USERID"]),Convert.ToString(Session["COMPANYID"]));
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveGZFeeDR(string gid, string closedate, string startdate)
{
var opctnbscard = MsOpCtnBsCardDAL.GetData("GID='"+gid+"'", Convert.ToString(Session["USERID"]));
DBResult result = new DBResult();
result = MsOpCtnBsCardDAL.SaveGZFeeDR(opctnbscard, closedate, startdate, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
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,IS_RETURE_EMPTY=0,IS_DB=0,REMARKS=SUBSTRING(REMARKS,1,charindex('申请返空信息:',REMARKS,0)-1) "
+ " ,I_CUSTNO='',I_MBLNO='',I_CUSTNAME='',I_CARRIER='',I_CONTRACT='',I_PORTLOAD='',I_DESTPORT_STATOIN='',I_DESTPORT=''"
+ " ,I_ETD=NULL,I_ETA=NULL,I_PORTLOAD_CNT_TIME=NULL,I_ARRIVALDATE=NULL,I_DEST_CNT_TIME=NULL,I_DEST_RTCNT_TIME=NULL,PREI_ETA=NULL"
+ " ,D_CUSTNO='',D_MBLNO='',D_CUSTNAME='',D_CARRIER='',D_CONTRACT='',D_PORTLOAD='',D_DESTPORT_STATOIN='',D_DESTPORT=''"
+ " ,D_ETD=NULL,D_ETA=NULL,D_PORTLOAD_CNT_TIME=NULL,D_ARRIVALDATE=NULL,D_DEST_CNT_TIME=NULL,D_DEST_RTCNT_TIME=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,IS_DB=0,REMARKS=SUBSTRING(REMARKS,1,charindex('申请调拨信息:',REMARKS,0)-1) "
+ " ,D_CUSTNO='',D_MBLNO='',D_CUSTNAME='',D_CARRIER='',D_CONTRACT='',D_PORTLOAD='',D_DESTPORT_STATOIN='',D_DESTPORT=''"
+ " ,D_ETD=NULL,D_ETA=NULL,D_PORTLOAD_CNT_TIME=NULL,D_ARRIVALDATE=NULL,D_DEST_CNT_TIME=NULL,D_DEST_RTCNT_TIME=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 ShenReturnPL(string data, string type, string reason = "")
{
var headData = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = MsOpCtnBsCardDAL.ShenReturn(headData, type, Convert.ToString(Session["USERID"]), reason);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
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 {
}
}
}
if (errstr != "")
{
var jsonRespose = new JsonResponse { Success =false, Message ="业务编号:"+errstr+" 存在操作引入费用,不允许删除!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
if (headData != null&&headData.Count>0)
{
result = MsOpCtnBsCardDAL.DeleteOpCtnBsCard(headData);
}
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 CancelBsLock(string data,string type)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
DBResult result = MsOpCtnBsCardDAL.LockBsData(bodyList, "0", type);
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) };
}
public ContentResult SavePLRepair(string bslist, string body)
{
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(bslist);
var OpCtnRepair = JsonConvert.Deserialize<OpCtnRepair>(body);
var result = new DBResult();
var OpCtnRepairList = new List<OpCtnRepair>();
if (bodyList != null && bodyList.Count != 0)
{
foreach (var item in bodyList)
{
OpCtnRepair NewOpCtnRepair = new OpCtnRepair();
NewOpCtnRepair.GID = "*";
NewOpCtnRepair.LINKGID = item.GID;
NewOpCtnRepair.REPAIRITEMS = OpCtnRepair.REPAIRITEMS;
NewOpCtnRepair.REPAIRTIME = OpCtnRepair.REPAIRTIME;
NewOpCtnRepair.CURSTATOIN = OpCtnRepair.CURSTATOIN;
NewOpCtnRepair.FEENAME = OpCtnRepair.FEENAME;
NewOpCtnRepair.CURRENCY = OpCtnRepair.CURRENCY;
NewOpCtnRepair.AMOUNT = OpCtnRepair.AMOUNT;
NewOpCtnRepair.REMARKS = OpCtnRepair.REMARKS;
NewOpCtnRepair.FEEID = OpCtnRepair.FEEID;
OpCtnRepairList.Add(NewOpCtnRepair);
}
}
if (OpCtnRepairList.Count != 0)
{
result = MsOpCtnBsCardDAL.InsertOpCtnRepair(OpCtnRepairList, Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
// Data = MsChFeeDAL.GetDataList(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SavePLClearing(string bslist, string body)
{
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(bslist);
var OpCtnClearing = JsonConvert.Deserialize<OpCtnClearing>(body);
var result = new DBResult();
var OpCtnClearingList = new List<OpCtnClearing>();
if (bodyList != null && bodyList.Count != 0) {
foreach (var item in bodyList) {
OpCtnClearing NewOpCtnClearing = new OpCtnClearing();
NewOpCtnClearing.GID = "*";
NewOpCtnClearing.LINKGID = item.GID;
NewOpCtnClearing.CURSTATOIN = OpCtnClearing.CURSTATOIN;
NewOpCtnClearing.INSTATOINTIME = OpCtnClearing.INSTATOINTIME;
NewOpCtnClearing.CLEARINGMODE = OpCtnClearing.CLEARINGMODE;
NewOpCtnClearing.PREGOODSNAME = OpCtnClearing.PREGOODSNAME;
NewOpCtnClearing.ISCLEAR_CERT = OpCtnClearing.ISCLEAR_CERT;
NewOpCtnClearing.CHECKGOV = OpCtnClearing.CHECKGOV;
NewOpCtnClearing.ISCLEAR_PLAN = OpCtnClearing.ISCLEAR_PLAN;
NewOpCtnClearing.CLEARTIME = OpCtnClearing.CLEARTIME;
NewOpCtnClearing.ISCOMPLETE = OpCtnClearing.ISCOMPLETE;
NewOpCtnClearing.FEENAME = OpCtnClearing.FEENAME;
NewOpCtnClearing.CURRENCY = OpCtnClearing.CURRENCY;
NewOpCtnClearing.AMOUNT = OpCtnClearing.AMOUNT;
NewOpCtnClearing.REMARKS = OpCtnClearing.REMARKS;
NewOpCtnClearing.FEEID = OpCtnClearing.FEEID;
if (NewOpCtnClearing.INSTATOINTIME == "") NewOpCtnClearing.INSTATOINTIME = null;
if (NewOpCtnClearing.CLEARTIME == "") NewOpCtnClearing.CLEARTIME = null;
if (NewOpCtnClearing.AUDITTIME == "") NewOpCtnClearing.AUDITTIME = null;
OpCtnClearingList.Add(NewOpCtnClearing);
}
}
if (OpCtnClearingList.Count != 0)
{
result=MsOpCtnBsCardDAL.InsertOpCtnClearing(OpCtnClearingList, Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
// Data = MsChFeeDAL.GetDataList(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request))
};
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 DESTPORT,CTNNO,SUM(DATEDIFF([day],STARTDATE,ENDDATE)) AS NOEMPTYDAY,SUM(YARDDAY) YARDDAY,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 DESTPORT,CTNNO,CASE WHEN b.PORTLOAD_CNT_TIME<'" + startdate + "' THEN DATEADD(DAY,-1,'" + startdate + "') ELSE DATEADD(DAY,-1,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(" ,CASE WHEN b.DEST_RTCNT_TIME IS NOT NULL THEN CASE WHEN b.NPORTLOAD_CNT_TIME IS NOT NULL THEN DATEDIFF([day],b.DEST_RTCNT_TIME,b.NPORTLOAD_CNT_TIME) ELSE DATEDIFF([day],b.DEST_RTCNT_TIME,GETDATE()) END ELSE 0 END YARDDAY");
strSql.Append(" FROM V_OP_CTNBSCARD_ALL b ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" ) X GROUP BY DESTPORT,CTNNO ");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring + " ");
}
else
{
strSql.Append(" order by DESTPORT,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 };
}
}
public ContentResult GetRptCtnTurnOverDataSum(int start, int limit, string condition, string startdate, string enddate, string sort, string printstr = "false")
{
var strSql = new StringBuilder();
strSql.Append(" SELECT *,convert(decimal(10,2),convert(decimal(10,2),NOEMPTYDAY)*100/convert(decimal(10,2),(NOEMPTYDAY+YARDDAY))) TURNOVERRATE from (");
strSql.Append(" SELECT DESTPORT,SUM(CTNNUM) CTNNUM,SUM(DATEDIFF([day],STARTDATE,ENDDATE)) AS NOEMPTYDAY,SUM(YARDDAY) YARDDAY,SUM(YARDDAY)/SUM(CTNNUM) AVGYARDDAY,DATEDIFF([day],'" + startdate + "','" + enddate + "') as ALLDAY");
strSql.Append(" from (SELECT DESTPORT,1 CTNNUM,CASE WHEN b.PORTLOAD_CNT_TIME<'" + startdate + "' THEN DATEADD(DAY,-1,'" + startdate + "') ELSE DATEADD(DAY,-1,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(" ,CASE WHEN b.DEST_RTCNT_TIME IS NOT NULL THEN CASE WHEN b.NPORTLOAD_CNT_TIME IS NOT NULL THEN DATEDIFF([day],b.DEST_RTCNT_TIME,b.NPORTLOAD_CNT_TIME) ELSE DATEDIFF([day],b.DEST_RTCNT_TIME,GETDATE()) END ELSE 0 END YARDDAY");
strSql.Append(" FROM V_OP_CTNBSCARD_ALL b ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" ) X GROUP BY DESTPORT ");
strSql.Append(" ) Z ");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring + " ");
}
else
{
strSql.Append(" order by DESTPORT ");
}
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 oldheaddata = MsOpCtnBsCardDAL.GetData("b.GID=" + opstr + "", Session["USERID"].ToString());
if (oldheaddata.ISBSLOCK) {
if (fieldname == "CUSTNO" || fieldname == "MBLNO" || fieldname == "GOODSNAME" || fieldname == "PREETD"
|| fieldname == "PORTLOADDATE" || fieldname == "PORTLOAD_CNT_TIME" || fieldname == "PORTLOAD_STATOIN"
|| fieldname == "PORTLOAD" || fieldname == "ETD" || fieldname == "DESTPORT") {
var jsonRespose1 = new JsonResponse
{
Success = false,
Message ="出口信息已锁定无法更新",
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
}
}
if (oldheaddata.ISSEAILOCK)
{
if (fieldname == "ETA" || fieldname == "AGENTNAME" || fieldname == "DESTPORT_STATOIN" || fieldname == "DEST_CNT_TIME"
|| fieldname == "DEST_RTCNT_TIME")
{
var jsonRespose1 = new JsonResponse
{
Success = false,
Message = "进口信息已锁定无法更新",
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
}
}
if (oldheaddata.ISRELOCK)
{
if (fieldname == "I_CUSTNO" || fieldname == "I_MBLNO" || fieldname == "I_PORTLOAD_CNT_TIME" || fieldname == "I_PORTLOAD"
|| fieldname == "I_ETD" || fieldname == "I_DESTPORT" || fieldname == "PREI_ETA" || fieldname == "I_PREETD"
|| fieldname == "I_ETA" || fieldname == "I_DESTPORT_STATOIN" || fieldname == "I_DEST_CNT_TIME"
|| fieldname == "I_DEST_RTCNT_TIME" || fieldname == "I_CLEARNTIME" || fieldname == "I_IS_POD_CLEAN")
{
var jsonRespose1 = new JsonResponse
{
Success = false,
Message = "空返信息已锁定无法更新",
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
}
}
if (oldheaddata.ISDBLOCK)
{
if (fieldname == "D_CUSTNO" || fieldname == "D_MBLNO" || fieldname == "D_PORTLOAD_CNT_TIME" || fieldname == "D_PORTLOAD"
|| fieldname == "D_ETD" || fieldname == "D_DESTPORT" || fieldname == "PRED_ETA"
|| fieldname == "D_ETA" || fieldname == "D_DESTPORT_STATOIN" || fieldname == "D_DEST_CNT_TIME"
|| fieldname == "D_DEST_RTCNT_TIME" || fieldname == "D_CLEARNTIME" || fieldname == "D_IS_POD_CLEAN")
{
var jsonRespose1 = new JsonResponse
{
Success = false,
Message = "调拨信息已锁定无法更新",
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
}
}
var Currdata = new OpCtnBsCard();
Currdata.PORTLOADDATE = oldheaddata.PORTLOADDATE;
Currdata.PORTLOAD_CNT_TIME = oldheaddata.PORTLOAD_CNT_TIME;
Currdata.ETD = oldheaddata.ETD;
Currdata.ETA = oldheaddata.ETA;
Currdata.DEST_CNT_TIME = oldheaddata.DEST_CNT_TIME;
Currdata.DEST_RTCNT_TIME = oldheaddata.DEST_RTCNT_TIME;
Currdata.I_PORTLOAD_CNT_TIME = oldheaddata.I_PORTLOAD_CNT_TIME;
Currdata.I_ETD = oldheaddata.I_ETD;
Currdata.I_ETA = oldheaddata.I_ETA;
Currdata.I_DEST_CNT_TIME = oldheaddata.I_DEST_CNT_TIME;
Currdata.I_DEST_RTCNT_TIME = oldheaddata.I_DEST_RTCNT_TIME;
Currdata.SetPropertyValue(fieldname, strupdate);
var IDTYPE = "";
if ((!string.IsNullOrEmpty(oldheaddata.I_PORTLOAD_CNT_TIME)) && !string.IsNullOrEmpty(oldheaddata.D_PORTLOAD_CNT_TIME))
{
if (Convert.ToDateTime(oldheaddata.D_PORTLOAD_CNT_TIME) < Convert.ToDateTime(oldheaddata.I_PORTLOAD_CNT_TIME))
IDTYPE = "调拨-空返";
}
else
{
}
var msg = Currdata.CheckUPDDate(IDTYPE);
if (!string.IsNullOrWhiteSpace(msg))
{
var jsonRespose1 = new JsonResponse
{
Success = false,
Message = msg,
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
}
if (IDTYPE == "调拨-空返")
{
string blUpSQL = " update op_ctnbscard set " + fieldname + "=" + strupdate + ",MODIFYTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',MODIFYUSER='" + Convert.ToString(Session["USERID"]) + "',IDTYPE='" + IDTYPE+"' where GID=" + opstr + "";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
else
{
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);
}
if (strupdate != "null")
{
string blUpSQL2 = "insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID()," + opstr + ",'" + fieldname + "',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
var headData = MsOpCtnBsCardDAL.GetData("GID=" + opstr, Convert.ToString(Session["USERID"]));
if (fieldname == "I_DEST_RTCNT_TIME" || fieldname == "DEST_RTCNT_TIME" || fieldname == "D_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 (headData.IS_DB == true)
{
if (fieldname == "D_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");
}
if (fieldname == "DEST_CNT_TIME")
{
if (oldheaddata.DEST_CNT_TIME != headData.DEST_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "目的港提箱日期", oldheaddata.DEST_CNT_TIME, headData.DEST_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "DEST_RTCNT_TIME")
{
if (oldheaddata.DEST_RTCNT_TIME != headData.DEST_RTCNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "目的港还箱日期", oldheaddata.DEST_RTCNT_TIME, headData.DEST_RTCNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "I_DEST_CNT_TIME")
{
if (oldheaddata.I_DEST_CNT_TIME != headData.I_DEST_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "空返目的港提箱日期", oldheaddata.I_DEST_CNT_TIME, headData.I_DEST_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "I_DEST_RTCNT_TIME")
{
if (oldheaddata.I_DEST_RTCNT_TIME != headData.I_DEST_RTCNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "空返目的港还箱日期", oldheaddata.I_DEST_RTCNT_TIME, headData.I_DEST_RTCNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "D_DEST_CNT_TIME")
{
if (oldheaddata.D_DEST_CNT_TIME != headData.D_DEST_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "调拨目的港提箱日期", oldheaddata.D_DEST_CNT_TIME, headData.D_DEST_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "D_DEST_RTCNT_TIME")
{
if (oldheaddata.D_DEST_RTCNT_TIME != headData.D_DEST_RTCNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "调拨目的港还箱日期", oldheaddata.D_DEST_RTCNT_TIME, headData.D_DEST_RTCNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "PORTLOAD_CNT_TIME")
{
if (oldheaddata.PORTLOAD_CNT_TIME != headData.PORTLOAD_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "起运港提箱日期", oldheaddata.PORTLOAD_CNT_TIME, headData.PORTLOAD_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "I_PORTLOAD_CNT_TIME")
{
if (oldheaddata.PORTLOAD_CNT_TIME != headData.PORTLOAD_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "空返起运港提箱日期", oldheaddata.I_PORTLOAD_CNT_TIME, headData.I_PORTLOAD_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "D_PORTLOAD_CNT_TIME")
{
if (oldheaddata.D_PORTLOAD_CNT_TIME != headData.D_PORTLOAD_CNT_TIME)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "调拨起运港提箱日期", oldheaddata.D_PORTLOAD_CNT_TIME, headData.D_PORTLOAD_CNT_TIME, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "ETD")
{
if (oldheaddata.ETD != headData.ETD)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "开船日期", oldheaddata.ETD, headData.ETD, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "I_ETD")
{
if (oldheaddata.I_ETD != headData.I_ETD)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "空返开船日期", oldheaddata.I_ETD, headData.I_ETD, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "D_ETD")
{
if (oldheaddata.D_ETD != headData.D_ETD)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "调拨开船日期", oldheaddata.D_ETD, headData.D_ETD, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "ETA")
{
if (oldheaddata.ETA != headData.ETA)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "到港日期", oldheaddata.ETA, headData.ETA, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "I_ETA")
{
if (oldheaddata.I_ETA != headData.I_ETA)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "空返到港日期", oldheaddata.I_ETA, headData.I_ETA, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
if (fieldname == "D_ETA")
{
if (oldheaddata.D_ETA != headData.D_ETA)
MsOpCtnBsCardDAL.InsertOpLog(headData.GID, "OP_CTNBSCARD", "调拨到港日期", oldheaddata.D_ETA, headData.D_ETA, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
}
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 blUpSQL2 = "insert into op_ctnapply_lock(GID,BSNO,FIELDNAME,INPUTTIME,INPUTBY) VALUES(NEWID()," + opstr + ",'" + fieldname + "',GETDATE(),'" + Convert.ToString(Session["USERID"]) + "')";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
}
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 批量修改窗体
public ContentResult modify(string data, string modifydata)
{
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
var amodifydata = JsonConvert.Deserialize<OpCtnBsCard>(modifydata);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpCtnBsCardDAL.Modify(bodyList, amodifydata, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult FXTZModify(string data, string modifydata)
{
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
var amodifydata = JsonConvert.Deserialize<OpCtnBsCard>(modifydata);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpCtnBsCardDAL.FXTZModify(bodyList, amodifydata, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult ImportBs(string data, string modifydata,string bstype)
{
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCard>>(data);
var amodifydata = JsonConvert.Deserialize<OpCtnBsCard>(modifydata);
var result = new DBResult();
if (bodyList != null)
{
foreach (var body in bodyList) {
var lockfieldlist = MsOpCtnBsCardDAL.GetOpLock("BSNO='"+body.GID+"'");
if (bstype == "1")
{
if (body.PORTLOAD_CNT_TIME == "")
{
if (amodifydata.ETD != "")
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "开船日期不能小于提箱日期",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
else
{
if (amodifydata.ETD != "" && (Convert.ToDateTime(amodifydata.ETD) < Convert.ToDateTime(body.PORTLOAD_CNT_TIME)))
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "开船日期不能小于提箱日期",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
var lockfield = lockfieldlist.Find(x => x.FIELDNAME == "ETD");
if (lockfield != null && lockfield.FIELDNAME == "ETD") {
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "开船日期已锁定,不允许更新!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
else if (bstype == "2")
{
if (body.I_PORTLOAD_CNT_TIME == "")
{
if (amodifydata.ETD != "")
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "空返开船日期不能小于提箱日期",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
else
{
if (amodifydata.ETD != "" && (Convert.ToDateTime(amodifydata.ETD) < Convert.ToDateTime(body.I_PORTLOAD_CNT_TIME)))
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "空返开船日期不能小于提箱日期",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
var lockfield = lockfieldlist.Find(x => x.FIELDNAME == "I_ETD");
if (lockfield != null && lockfield.FIELDNAME == "I_ETD")
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "返空开船日期已锁定,不允许更新!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
}
result = MsOpCtnBsCardDAL.ImportBs(bodyList, amodifydata, bstype, Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 保险索赔
public ContentResult GetInsuranceData(string handle, string condition)
{
OpCtnInsurance head = null;
if (handle == "edit")
{
head = MsOpCtnBsCardDAL.GetInsuranceData(condition,"");
}
if (head == null)
{
head = new OpCtnInsurance();
head.COMPANYID = Convert.ToString(Session["COMPANYID"]);
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult SaveInsurance(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<OpCtnInsurance>(data);
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");
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var GID = headData.GID;
if (headData.ETD == "") headData.ETD = null;
else
{
headData.ETD = Convert.ToDateTime(headData.ETD.Replace("GMT+0800 (中国标准时间)", "")).ToString("yyyy-MM-dd");
}
if (headData.INSURANCEDATE == "") headData.INSURANCEDATE = null;
else
{
headData.INSURANCEDATE = Convert.ToDateTime(headData.INSURANCEDATE.Replace("GMT+0800 (中国标准时间)", "")).ToString("yyyy-MM-dd");
}
if (headData.PRECLAIMSDATE == "") headData.PRECLAIMSDATE = null;
if (headData.INSURANCEBEGINDATE == "") headData.INSURANCEBEGINDATE = null;
if (headData.INSURANCEENDDATE == "") headData.INSURANCEENDDATE = null;
var CtnTkInsuranceList = MsCodeCtnTkDAL.GetCodeCtnTkInsuranceItemdata("BEGINDATE<='"+ headData.INSURANCEDATE + "' AND ENDDATE>='"+ headData.INSURANCEDATE + "' AND LINKGID IN (SELECT GID FROM code_ctntk WHERE CTNNO='"+headData.CTNNO+"')");
if (CtnTkInsuranceList != null && CtnTkInsuranceList.Count >= 1) {
headData.INSURANCENUM = CtnTkInsuranceList[0].BSNO;
headData.INSURANCEBEGINDATE = CtnTkInsuranceList[0].BEGINDATE;
headData.INSURANCEENDDATE = CtnTkInsuranceList[0].ENDDATE;
}
var modb = new ModelObjectDB();
var result = modb.Save(headData);
if (result.Success) {
if (opstatus == "add")
{
if (!string.IsNullOrEmpty(headData.FEEID)) {
var feelist = MsChFeeDAL.GetAllDataList("GID='"+headData.FEEID+"'");
if (feelist != null)
{
for (int _i = 0; _i < feelist.Count; _i++)
{
feelist[_i].BsNo = "*";
feelist[_i].WmsOutBsNo = headData.FEEID;
feelist[_i].INPUTMODE = "业务卡生成";
}
MsChFeeDAL.SaveFee(feelist, headData.GID, CookieConfig.GetCookie_UserId(Request));
}
}
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpCtnBsCardDAL.GetInsuranceData("GID='" + GID + "'", Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetOpCtnInsuranceList(int start, int limit, string condition, string sort)
{
var dataList = MsOpCtnBsCardDAL.GetOpCtnInsuranceList(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 GetOpCtnInsuranceListStr(string condition, string sort)
{
var dataListStr = MsOpCtnBsCardDAL.GetOpCtnInsuranceListStr(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult SaveOpCtnInsurance(string body, string PID)
{
//
var bodyList = JsonConvert.Deserialize<List<OpCtnInsurance>>(body);
DBResult result = MsOpCtnBsCardDAL.SaveOpCtnInsurance(bodyList,Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteOpCtnInsurance(string data)
{
var headData = JsonConvert.Deserialize<List<OpCtnInsurance>>(data);
DBResult result = MsOpCtnBsCardDAL.DeleteOpCtnInsurance(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
[HttpPost]
public ContentResult ImportYardData()
{
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) };
}
var path = Server.MapPath("../../UploadFiles/BulkDetail");
var path2 = Server.MapPath("../../UploadFiles/BulkDetail/");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var size = file.ContentLength;
var name = Path.GetFileName(file.FileName);
var bsno = Request.Form["bsno"];
name = name.Replace("%", "").Replace("&", "").Replace("@", "");
var usercode = CookieConfig.GetCookie_UserCode(Request);
string filenamepath = usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
string filename = path + "\\" + filenamepath;
string excelFilePath = path2 + filenamepath;
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) };
}
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
if (excel == null)
{
jsonRespose.Success = false;
jsonRespose.Message = "无法创建Excel对象,可能您的服务器计算机未安装Excel!";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
Workbook workbook = excel.Workbooks.Open(excelFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Worksheet mySheet = workbook.Sheets[1] as Worksheet;
try
{
var isuse = false;
var aaa = mySheet.Cells.get_Range("A2").Value2; //item
object v11new = aaa;
string strtmp = "";
string strtmp2 = "";
var YARD = v11new.ToString().Replace("FROM:", "").Trim();
var pricehead = MsOpPriceDAL.GetData("YARD='" + YARD + "'", Convert.ToString(Session["USERID"]));
var portdischarge = "";
if (pricehead.YARD != "") {
portdischarge = pricehead.PORTDISCHARGE;
if (portdischarge.IndexOf("(") > 0) {
portdischarge = portdischarge.Substring(portdischarge.IndexOf("(") + 1, portdischarge.Length - portdischarge.IndexOf("(") - 2);
}
}
var bodyList = new List<OpCtnBsCardYardData>();
var j = 4;
while (GetExcelValue(mySheet, "A" + j.ToString()) != "")
{
var CTNNO = GetExcelValue(mySheet, "A" + j.ToString());
var DATEIN = GetExcelValue(mySheet, "B" + j.ToString(),true);
var CLEARINGDATE = GetExcelValue(mySheet, "E" + j.ToString(),true);
var DATEOUT = GetExcelValue(mySheet, "J" + j.ToString(),true);
var sql = " CTNNO='" + CTNNO + "' and ISNULL(ISCLOSE,0)=0 AND ((ISNULL(IS_RETURE_EMPTY, 0) = 1 AND(I_DEST_RTCNT_TIME IS NULL OR I_DEST_RTCNT_TIME = '"+ DATEIN + "')) " +
"OR(ISNULL(IS_DB, 0) = 1 AND(D_DEST_RTCNT_TIME IS NULL OR D_DEST_RTCNT_TIME = '"+ DATEIN + "')) OR(DEST_RTCNT_TIME IS NULL OR DEST_RTCNT_TIME = '"+ DATEIN + "')) ";
if (portdischarge != "") {
sql = sql + " and (DESTPORT like '%" + portdischarge+ "%' or I_DESTPORT like '%" + portdischarge + "%' or D_DESTPORT like '%" + portdischarge + "%' ";
sql = sql + " OR PORTLOAD like '%" + portdischarge + "%' or I_PORTLOAD like '%" + portdischarge + "%' or D_PORTLOAD like '%" + portdischarge + "%') ";
}
var opctnbscardlist = MsOpCtnBsCardDAL.GetDataAllList(sql);
foreach (var opctnbscard in opctnbscardlist)
{
if (!string.IsNullOrEmpty(opctnbscard.CTNNO))
{
if (opctnbscard.DESTPORT.IndexOf(portdischarge) >= 0&&(Convert.ToDateTime(opctnbscard.PRE_CNT_TIME)<Convert.ToDateTime(DATEIN)))
{
if (string.IsNullOrEmpty(opctnbscard.DEST_RTCNT_TIME) || Convert.ToDateTime(opctnbscard.DEST_RTCNT_TIME) != Convert.ToDateTime(DATEIN))
{
OpCtnBsCardYardData data = new OpCtnBsCardYardData();
data.GID = opctnbscard.GID;
data.BSNO = opctnbscard.BSNO;
data.CTNNO = opctnbscard.CTNNO;
data.DATEIN = DATEIN;
data.DATEINFIELD = "DEST_RTCNT_TIME";
data.DATEINFIELDREF = "目的港还箱日期";
data.DATEINVALUE = opctnbscard.DEST_RTCNT_TIME;
bodyList.Add(data);
}
if (YARD!=opctnbscard.DESTPORT_STATOIN) {
OpCtnBsCardYardData data = new OpCtnBsCardYardData();
data.GID = opctnbscard.GID;
data.BSNO = opctnbscard.BSNO;
data.CTNNO = opctnbscard.CTNNO;
data.DATEIN = YARD;
data.DATEINFIELD = "DESTPORT_STATOIN";
data.DATEINFIELDREF = "目的港场站";
data.DATEINVALUE = opctnbscard.DESTPORT_STATOIN;
bodyList.Add(data);
}
}
if (opctnbscard.IS_RETURE_EMPTY && opctnbscard.I_DESTPORT.IndexOf(portdischarge) >= 0 && (Convert.ToDateTime(opctnbscard.PRE_CNT_TIME) < Convert.ToDateTime(DATEIN))
&&(string.IsNullOrEmpty(opctnbscard.I_PORTLOAD_CNT_TIME)|| (Convert.ToDateTime(opctnbscard.I_PORTLOAD_CNT_TIME) < Convert.ToDateTime(DATEIN))))
{
if (string.IsNullOrEmpty(opctnbscard.I_DEST_RTCNT_TIME) || Convert.ToDateTime(opctnbscard.I_DEST_RTCNT_TIME) != Convert.ToDateTime(DATEIN))
{
OpCtnBsCardYardData data = new OpCtnBsCardYardData();
data.GID = opctnbscard.GID;
data.BSNO = opctnbscard.BSNO;
data.CTNNO = opctnbscard.CTNNO;
data.DATEIN = DATEIN;
data.DATEINFIELD = "I_DEST_RTCNT_TIME";
data.DATEINFIELDREF = "空返目的港还箱日期";
data.DATEINVALUE = opctnbscard.I_DEST_RTCNT_TIME;
bodyList.Add(data);
}
if (YARD != opctnbscard.I_DESTPORT_STATOIN)
{
OpCtnBsCardYardData data = new OpCtnBsCardYardData();
data.GID = opctnbscard.GID;
data.BSNO = opctnbscard.BSNO;
data.CTNNO = opctnbscard.CTNNO;
data.DATEIN = YARD;
data.DATEINFIELD = "I_DESTPORT_STATOIN";
data.DATEINFIELDREF = "空返目的港场站";
data.DATEINVALUE = opctnbscard.I_DESTPORT_STATOIN;
bodyList.Add(data);
}
}
if (opctnbscard.IS_DB && opctnbscard.D_DESTPORT.IndexOf(portdischarge) >= 0 && (Convert.ToDateTime(opctnbscard.PRE_CNT_TIME) < Convert.ToDateTime(DATEIN))
&& (string.IsNullOrEmpty(opctnbscard.D_PORTLOAD_CNT_TIME) || (Convert.ToDateTime(opctnbscard.D_PORTLOAD_CNT_TIME) < Convert.ToDateTime(DATEIN))))
{
if (string.IsNullOrEmpty(opctnbscard.D_DEST_RTCNT_TIME) || Convert.ToDateTime(opctnbscard.D_DEST_RTCNT_TIME) != Convert.ToDateTime(DATEIN))
{
OpCtnBsCardYardData data = new OpCtnBsCardYardData();
data.GID = opctnbscard.GID;
data.BSNO = opctnbscard.BSNO;
data.CTNNO = opctnbscard.CTNNO;
data.DATEIN = DATEIN;
data.DATEINVALUE = opctnbscard.D_DEST_RTCNT_TIME;
data.DATEINFIELD = "D_DEST_RTCNT_TIME";
data.DATEINFIELDREF = "调拨目的港还箱日期";
bodyList.Add(data);
}
if (YARD != opctnbscard.D_DESTPORT_STATOIN)
{
OpCtnBsCardYardData data = new OpCtnBsCardYardData();
data.GID = opctnbscard.GID;
data.BSNO = opctnbscard.BSNO;
data.CTNNO = opctnbscard.CTNNO;
data.DATEIN = YARD;
data.DATEINFIELD = "D_DESTPORT_STATOIN";
data.DATEINVALUE = opctnbscard.D_DESTPORT_STATOIN;
data.DATEINFIELDREF = "调拨目的港场站";
bodyList.Add(data);
}
}
if (!string.IsNullOrEmpty(DATEOUT)) {
if (opctnbscard.PORTLOAD.IndexOf(portdischarge) >= 0 && ((Convert.ToDateTime(opctnbscard.PRE_CNT_TIME).AddDays(-5)) < Convert.ToDateTime(DATEOUT)))
{
if (string.IsNullOrEmpty(opctnbscard.PORTLOAD_CNT_TIME)||Convert.ToDateTime(opctnbscard.PORTLOAD_CNT_TIME) != Convert.ToDateTime(DATEIN))
{
OpCtnBsCardYardData data = new OpCtnBsCardYardData();
data.GID = opctnbscard.GID;
data.BSNO = opctnbscard.BSNO;
data.DATEIN = DATEOUT;
data.CTNNO = opctnbscard.CTNNO;
data.DATEINFIELD = "PORTLOAD_CNT_TIME";
data.DATEINVALUE = opctnbscard.PORTLOAD_CNT_TIME;
data.DATEINFIELDREF = "起运港提箱日期";
bodyList.Add(data);
}
if (YARD != opctnbscard.PORTLOAD_STATOIN)
{
OpCtnBsCardYardData data = new OpCtnBsCardYardData();
data.GID = opctnbscard.GID;
data.BSNO = opctnbscard.BSNO;
data.CTNNO = opctnbscard.CTNNO;
data.DATEIN = YARD;
data.DATEINFIELD = "PORTLOAD_STATOIN";
data.DATEINVALUE = opctnbscard.PORTLOAD_STATOIN;
data.DATEINFIELDREF = "起运港场站";
bodyList.Add(data);
}
}
if (opctnbscard.IS_RETURE_EMPTY&&opctnbscard.I_PORTLOAD.IndexOf(portdischarge) >= 0 && ((Convert.ToDateTime(opctnbscard.PRE_CNT_TIME).AddDays(-5)) < Convert.ToDateTime(DATEOUT)))
{
if (string.IsNullOrEmpty(opctnbscard.I_PORTLOAD_CNT_TIME) || Convert.ToDateTime(opctnbscard.I_PORTLOAD_CNT_TIME) != Convert.ToDateTime(DATEIN))
{
OpCtnBsCardYardData data = new OpCtnBsCardYardData();
data.GID = opctnbscard.GID;
data.BSNO = opctnbscard.BSNO;
data.CTNNO = opctnbscard.CTNNO;
data.DATEIN = DATEOUT;
data.DATEINFIELD = "I_PORTLOAD_CNT_TIME";
data.DATEINVALUE = opctnbscard.I_PORTLOAD_CNT_TIME;
data.DATEINFIELDREF = "空返起运港提箱日期";
bodyList.Add(data);
}
}
if (opctnbscard.IS_DB && opctnbscard.D_PORTLOAD.IndexOf(portdischarge) >= 0 && ((Convert.ToDateTime(opctnbscard.PRE_CNT_TIME).AddDays(-5)) < Convert.ToDateTime(DATEOUT)))
{
if (string.IsNullOrEmpty(opctnbscard.D_PORTLOAD_CNT_TIME) || Convert.ToDateTime(opctnbscard.D_PORTLOAD_CNT_TIME) != Convert.ToDateTime(DATEIN))
{
OpCtnBsCardYardData data = new OpCtnBsCardYardData();
data.GID = opctnbscard.GID;
data.BSNO = opctnbscard.BSNO;
data.CTNNO = opctnbscard.CTNNO;
data.DATEIN = DATEOUT;
data.DATEINFIELD = "D_PORTLOAD_CNT_TIME";
data.DATEINFIELDREF = "调拨起运港提箱日期";
data.DATEINVALUE = opctnbscard.D_PORTLOAD_CNT_TIME;
bodyList.Add(data);
}
}
}
}
}
j = j + 1;
}
//if (bodyList.Count > 0) MsOpSeaeDAL.InsertCtnData(bsno, bodyList);
workbook.Close(true, Type.Missing, Type.Missing);
workbook = null;
excel.Quit();
excel = null;
var json = JsonConvert.Serialize(new { success = true, Message = "上传成功",data=bodyList.ToList() });
return new ContentResult() { Content = json };
}
catch (Exception)
{
workbook.Close(true, Type.Missing, Type.Missing);
workbook = null;
excel.Quit();
excel = null;
jsonRespose.Success = false;
jsonRespose.Message = "读取Excel文件出错请确认文件正确性";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public static string GetExcelValue(Worksheet mySheet, string Local,bool b=false)
{
var result = "";
var aaa = mySheet.Cells.get_Range(Local).Value2; //item
var bbb = mySheet.Cells.get_Range(Local).Value; //item
object v11new = aaa;
if (b) v11new = bbb;
string strtmp = "";
if (v11new != null)
{
strtmp = v11new.ToString();
if (strtmp != "")
result = strtmp;
}
return result;
}
public ContentResult UpdateYardData(string data, string modifydata)
{
var bodyList = JsonConvert.Deserialize<List<OpCtnBsCardYardData>>(data);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpCtnBsCardDAL.UpdateYardData(bodyList,Convert.ToString(Session["COMPANYID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 生成邮件模板
public ContentResult CreateSendMail(string bsno, string mailproject, string bltype)
{
var opseae = MsOpCtnBsCardDAL.GetData("GID in ("+bsno+")", Convert.ToString(Session["USERID"]));
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var mailprojectList = MsInfoClientMailProjectDAL.GetBodyList("BLTYPE='" + bltype + "' and PROJECTID in (select GID FROM info_client_mailproject where CUSTNAME='" + opseae.CUSTOMERNAME + "') ");
if (mailprojectList.Count != 0)
{
var MAILSENDID = Guid.NewGuid().ToString();
var opmailsend = new OpMailSend();
opmailsend.GID = MAILSENDID;
opmailsend.PROJECTID = mailproject;
opmailsend.BLTYPE = bltype;
opmailsend.BSNO = opseae.BSNO;
opmailsend.MBLNO = opseae.MBLNO;
opmailsend.RECEIVER = mailprojectList[0].RECEIVER;
opmailsend.SUBJECT = mailprojectList[0].SUBJECT.Replace("[主提单号]", opseae.MBLNO).Replace("[委托编号]", opseae.CUSTNO).Replace("[委托单位]", opseae.CUSTOMERNAME).Replace("[箱号]", opseae.CTNNO).Replace("[放箱申请编号]", opseae.APPLYNO).Replace("[业务编号]", opseae.BSNO);
opmailsend.DESCRIPTION = mailprojectList[0].DESCRIPTION.Replace("[主提单号]", opseae.MBLNO).Replace("[委托编号]", opseae.CUSTNO).Replace("[委托单位]", opseae.CUSTOMERNAME).Replace("[箱号]", opseae.CTNNO).Replace("[放箱申请编号]", opseae.APPLYNO).Replace("[业务编号]", opseae.BSNO);
var mailsign = T_ALL_DA.GetStrSQL("mailsign", "select mailsign from user_baseinfo where USERID='" + Convert.ToString(Session["USERID"]) + "'");
var EMAIL1 = T_ALL_DA.GetStrSQL("EMAIL1", "select EMAIL1 from user_baseinfo where USERID='" + Convert.ToString(Session["USERID"]) + "'");
opmailsend.SIGNATURE = mailsign;
opmailsend.ATTACHMENT = mailprojectList[0].ATTACHMENT.Replace("[主提单号]", opseae.MBLNO).Replace("[委托编号]", opseae.CUSTNO).Replace("[委托单位]", opseae.CUSTOMERNAME).Replace("[箱号]", opseae.CTNNO).Replace("[放箱申请编号]", opseae.APPLYNO).Replace("[业务编号]", opseae.BSNO);
if (opmailsend.ATTACHMENT == "") opmailsend.ATTACHMENT = opseae.BSNO;
opmailsend.SENDER = EMAIL1;
var MAILTONAME = "admin@dongshengsoft.com";
var PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTONAME'");
if (PARAMVALUE.PARAMVALUE != "") MAILTONAME = PARAMVALUE.PARAMVALUE;
var MAILTOPASSWORD = "ds!@#)(*";
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPASSWORD'");
if (PARAMVALUE.PARAMVALUE != "") MAILTOPASSWORD = PARAMVALUE.PARAMVALUE;
var MAILTOSERVER = "smtpcom.263xmail.com";
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOSERVER'");
if (PARAMVALUE.PARAMVALUE != "") MAILTOSERVER = PARAMVALUE.PARAMVALUE;
var MAILTOPORT = "465";
PARAMVALUE = MsSysParamSetDAL.GetData("PARAMNAME='MAILTOPORT'");
if (PARAMVALUE.PARAMVALUE != "") MAILTOPORT = PARAMVALUE.PARAMVALUE;
opmailsend.SENDERUSERNAME = MAILTONAME;
opmailsend.SENDERPASSWORD = MAILTOPASSWORD;
opmailsend.SENDSERVICE = MAILTOSERVER;
opmailsend.SENDERPORT = MAILTOPORT;
var URLSTR = Request.Url.Authority + "/MvcShipping/MsOpMailLog/UpMailLog";
if (URLSTR.IndexOf("http://") < 0) URLSTR = "http://"+URLSTR;
opmailsend.HTTPURL = URLSTR;
opmailsend.DbOperationType = DbOperationType.DbotIns;
var modb = new ModelObjectDB();
var result=modb.Save(opmailsend);
if (result.Success)
{
string blUpSQL = "update op_ctnbscard set MAILID='"+ MAILSENDID + "',IS_PUTCTN=1,PUTCTNDATE=GETDATE(),PUTCTNAUDITSTATUS='已发送邮件' where GID IN (" + bsno + ") ";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", Data = MAILSENDID });
return new ContentResult() { Content = json };
}
else
{
var njson = JsonConvert.Serialize(
new { Success = false, Message = "无邮件方案,无法直发邮件!" });
return new ContentResult() { Content = njson };
}
}
#endregion
public ContentResult ZipViewFiles(string ZipFile)
{
var ZipFilePath = Server.MapPath(ZipFile);
if (!System.IO.File.Exists(ZipFilePath))
{
var json = JsonConvert.Serialize(
new { Success = false, Message = "不能预览"});
return new ContentResult() { Content = json };
}
FileInfo fileInfo = new FileInfo(ZipFilePath);
if (fileInfo.Extension != ".zip"&& fileInfo.Extension != ".rar") {
var zipfilelist2 = new List<ZipFileView>();
var zipfile = new ZipFileView();
zipfile.GID = Guid.NewGuid().ToString();
zipfile.ViewFileName = fileInfo.Name;
zipfile.ViewFilePath = ZipFile;
zipfilelist2.Add(zipfile);
var jsonRespose2 = new JsonResponse
{
Success = true,
Message = "提交成功!",
Data = zipfilelist2.ToList()
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var usercode = CookieConfig.GetCookie_UserCode(Request);
var pathstr = "../../UploadFiles/ViewTmp/" +usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var filePath = Server.MapPath(pathstr);
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
string[] files = Directory.GetFiles(filePath);
if (files.Length > 0)
{
foreach (string file in files)
{
System.IO.File.Delete(file);
}
}
if (fileInfo.Extension == ".rar")
{
if (IntPtr.Size == 4) //32位操作系统
{
var Zpathstr = "../../lib/7z.dll";
SevenZipCompressor.SetLibraryPath(Server.MapPath(Zpathstr));
}
else //64位操作系统
{
var Zpathstr = "../../lib/7z64.dll";
SevenZipCompressor.SetLibraryPath(Server.MapPath(Zpathstr));
// SevenZipCompressor.SetLibraryPath(AppDomain.CurrentDomain.BaseDirectory + @"\7z64.dll");
}
SevenZipExtractor se = new SevenZipExtractor(ZipFilePath);
se.ExtractArchive(filePath);
}
else
{
FastZip fastZip = new FastZip();
fastZip.ExtractZip(ZipFilePath, filePath, null);
}
var zipfilelist = new List<ZipFileView>();
files = Directory.GetFiles(filePath);
if (files.Length > 0)
{
foreach (string file in files)
{
FileInfo fileInfo2 = new FileInfo(file);
var zipfile = new ZipFileView();
zipfile.GID = Guid.NewGuid().ToString();
zipfile.ViewFileName = fileInfo2.Name;
zipfile.ViewFilePath = pathstr + "/" + fileInfo2.Name;
zipfilelist.Add(zipfile);
}
}
else {
var tmpfilepaths = Directory.GetDirectories(filePath);
foreach (string tmpfilepath in tmpfilepaths)
{
if (tmpfilepath.IndexOf("&") > 0) {
var newfilepath = tmpfilepath.Replace("&","_");
Directory.Move(tmpfilepath,newfilepath);
files = Directory.GetFiles(newfilepath);
} else
files = Directory.GetFiles(tmpfilepath);
foreach (string file in files)
{
FileInfo fileInfo2 = new FileInfo(file);
var zipfile = new ZipFileView();
zipfile.GID = Guid.NewGuid().ToString();
if (fileInfo2.Name.IndexOf("&") > 0) {
fileInfo2.MoveTo(fileInfo2.FullName.Replace("&","_"));
}
zipfile.ViewFileName = fileInfo2.Name;
zipfile.ViewFilePath = "../../"+urlconvertor(fileInfo2.FullName);
// zipfile.ViewFilePath = pathstr + "/" + fileInfo2.Name;
zipfilelist.Add(zipfile);
}
}
}
var jsonRespose = new JsonResponse
{
Success = true,
Message = "提交成功!",
Data = zipfilelist.ToList()
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
private string urlconvertor(string imagesurl1)
{
string tmpRootDir = Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString());//获取程序根目录
string imagesurl2 = imagesurl1.Replace(tmpRootDir, ""); //转换成相对路径
imagesurl2 = imagesurl2.Replace(@"\", @"/");
//imagesurl2 = imagesurl2.Replace(@"Aspx_Uc/", @"");
return imagesurl2;
}
[HttpPost]
public ActionResult PLUpLoadFile()
{
DBResult resp = new DBResult();
if (Request.Files.Count > 0)
{
var UploadFileType = Request.Form["UploadFileType"];
var SelectBsSql = Request.Form["SelectBsSql"];
var type = "";
if (UploadFileType=="GZQ") type = "1";
if (UploadFileType == "GZH") type = "1";
if (UploadFileType == "JC") type = "3";
if (UploadFileType == "EIR") type = "4";
if (UploadFileType == "QX") type = "5";
if (UploadFileType == "QJZ") type = "6";
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var filelist = "";
for (int idx = 0; idx < Request.Files.Count; idx++)
{
var file = Request.Files.Get(idx);
string ext = Path.GetExtension(file.FileName).ToLower();
if (ext == ".asp" || ext == ".aspx" || ext == ".html" || ext == ".exe")
{
resp.Success = false;
resp.Message = "文件类型不正确";
return Json(resp);
}
var BSNO = "";
var GID = "";
if (type == "1" || type == "2")
{
var datalist=MsOpCtnBsCardDAL.GetOpCtnRepairList("LINKGID='"+ SelectBsSql + "'", "");
foreach (var items in datalist)
{
if ((type == "1")&& string.IsNullOrEmpty(items.IMAGE_LINDADDR)){
var imgdataList = MsOpCtnBsCardDAL.GetOpCtnRepairListImg("LINKGID='" + items.GID + "'","");
BSNO = items.BSNO;
if (imgdataList.Count == 0)
{
var imgdata = new OpCtnRepairImg();
imgdata.GID = Guid.NewGuid().ToString();
MsOpCtnBsCardDAL.InsertOpCtnRepairImg(imgdata,items.GID, Convert.ToString(Session["USERID"]));
GID = imgdata.GID;
}
else {
GID = imgdataList[0].GID;
}
}else if ((type == "2") && string.IsNullOrEmpty(items.IMAGE_LINDADDR2))
{
var imgdataList = MsOpCtnBsCardDAL.GetOpCtnRepairListImg("LINKGID='" + items.GID + "'", "");
BSNO = items.BSNO;
if (imgdataList.Count == 0)
{
var imgdata = new OpCtnRepairImg();
imgdata.GID = Guid.NewGuid().ToString();
MsOpCtnBsCardDAL.InsertOpCtnRepairImg(imgdata, items.GID, Convert.ToString(Session["USERID"]));
GID = imgdata.GID;
}
else
{
GID = imgdataList[0].GID;
}
}
}
}
else {
var datalist = MsOpCtnBsCardDAL.GetOpCtnClearingList("LINKGID='" + SelectBsSql + "'", "");
foreach (var items in datalist) {
if ((type == "3") && string.IsNullOrEmpty(items.IMAGE_LINDADDR))
{
BSNO = items.BSNO;
GID = items.GID;
}
else if ((type == "4") && string.IsNullOrEmpty(items.EIRPATH))
{
BSNO = items.BSNO;
GID = items.GID;
}
else if ((type == "5") && string.IsNullOrEmpty(items.IMAGE_CLEARPATH))
{
BSNO = items.BSNO;
GID = items.GID;
}
else if ((type == "6") && string.IsNullOrEmpty(items.IMAGE_CHECKGOVPATH))
{
BSNO = items.BSNO;
GID = items.GID;
}
}
}
var name = Path.GetFileName(file.FileName);
name = name.Replace("%", "").Replace("&", "").Replace("@", "");
if (BSNO != null && BSNO.Trim() != "")
{
var path = Server.MapPath("../../UploadFiles/MsOpFiles/" + BSNO);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
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 (type == "1" || type == "2")
{
MsOpCtnBsCardDAL.UpdateRepairFileData(filenameURL, name, GID, type);
}
else if (type == "3" || type == "4" || type == "5" || type == "6")
MsOpCtnBsCardDAL.UpdateClearingFileData(filenameURL, name, GID, type);
//var isSucess = MsOpReceiptDAL.UpdateFileData(filenameURL, name, bsno, Convert.ToString(Session["USERID"]), "", "", "");
//if (isSucess.Success)
//{
//}
//else
//{
// filelist = filelist + name + ";";
//}
}
else
{
filelist = filelist + name + ";";
}
}
if (filelist.Trim() != "") filelist = "其中文件名:" + filelist + "未导入";
resp.Success = true;
resp.Message = "导入成功"+ filelist;
}
return Json(resp);
}
[HttpPost]
public ActionResult UpLoadFile2()
{
DBResult resp = new DBResult();
if (Request.Files.Count > 0)
{
var UploadFileType = Request.Form["UploadFileType"];
var GID = Request.Form["SelectBsSql"];
var BSNO = Request.Form["SelectBsNo"];
var type = "";
if (UploadFileType == "GZQ") type = "1";
if (UploadFileType == "GZH") type = "1";
if (UploadFileType == "JC") type = "3";
if (UploadFileType == "EIR") type = "4";
if (UploadFileType == "QX") type = "5";
if (UploadFileType == "QJZ") type = "6";
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var filelist = "";
for (int idx = 0; idx < Request.Files.Count; idx++)
{
var file = Request.Files.Get(idx);
string ext = Path.GetExtension(file.FileName).ToLower();
if (ext == ".asp" || ext == ".aspx" || ext == ".html" || ext == ".exe")
{
resp.Success = false;
resp.Message = "文件类型不正确";
return Json(resp);
}
//var BSNO = "";
//var GID = "";
////if (type == "1" || type == "2")
////{
//// var datalist = MsOpCtnBsCardDAL.GetOpCtnRepairList("GID='" + SelectBsSql + "'", "");
//// foreach (var items in datalist)
//// {
//// if ((type == "1") && string.IsNullOrEmpty(items.IMAGE_LINDADDR))
//// {
//// var imgdataList = MsOpCtnBsCardDAL.GetOpCtnRepairListImg("LINKGID='" + items.GID + "'", "");
//// BSNO = items.BSNO;
//// if (imgdataList.Count == 0)
//// {
//// var imgdata = new OpCtnRepairImg();
//// imgdata.GID = Guid.NewGuid().ToString();
//// MsOpCtnBsCardDAL.InsertOpCtnRepairImg(imgdata, items.GID, Convert.ToString(Session["USERID"]));
//// GID = imgdata.GID;
//// }
//// else
//// {
//// GID = imgdataList[0].GID;
//// }
//// }
//// else if ((type == "2") && string.IsNullOrEmpty(items.IMAGE_LINDADDR2))
//// {
//// var imgdataList = MsOpCtnBsCardDAL.GetOpCtnRepairListImg("LINKGID='" + items.GID + "'", "");
//// BSNO = items.BSNO;
//// if (imgdataList.Count == 0)
//// {
//// var imgdata = new OpCtnRepairImg();
//// imgdata.GID = Guid.NewGuid().ToString();
//// MsOpCtnBsCardDAL.InsertOpCtnRepairImg(imgdata, items.GID, Convert.ToString(Session["USERID"]));
//// GID = imgdata.GID;
//// }
//// else
//// {
//// GID = imgdataList[0].GID;
//// }
//// }
//// }
////}
////else
////{
//// var datalist = MsOpCtnBsCardDAL.GetOpCtnClearingList("LINKGID='" + SelectBsSql + "'", "");
//// foreach (var items in datalist)
//// {
//// if ((type == "3") && string.IsNullOrEmpty(items.IMAGE_LINDADDR))
//// {
//// BSNO = items.BSNO;
//// GID = items.GID;
//// }
//// else if ((type == "4") && string.IsNullOrEmpty(items.EIRPATH))
//// {
//// BSNO = items.BSNO;
//// GID = items.GID;
//// }
//// else if ((type == "5") && string.IsNullOrEmpty(items.IMAGE_CLEARPATH))
//// {
//// BSNO = items.BSNO;
//// GID = items.GID;
//// }
//// else if ((type == "6") && string.IsNullOrEmpty(items.IMAGE_CHECKGOVPATH))
//// {
//// BSNO = items.BSNO;
//// GID = items.GID;
//// }
//// }
////}
var name = Path.GetFileName(file.FileName);
name = name.Replace("%", "").Replace("&", "").Replace("@", "");
if (BSNO != null && BSNO.Trim() != "")
{
var path = Server.MapPath("../../UploadFiles/MsOpFiles/" + BSNO);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
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 (UploadFileType == "1" || UploadFileType == "2")
{
MsOpCtnBsCardDAL.UpdateRepairFileData(filenameURL, name, GID, UploadFileType);
}
else if (UploadFileType == "3" || UploadFileType == "4" || UploadFileType == "5" || UploadFileType == "6")
MsOpCtnBsCardDAL.UpdateClearingFileData(filenameURL, name, GID, UploadFileType);
//var isSucess = MsOpReceiptDAL.UpdateFileData(filenameURL, name, bsno, Convert.ToString(Session["USERID"]), "", "", "");
//if (isSucess.Success)
//{
//}
//else
//{
// filelist = filelist + name + ";";
//}
}
else
{
filelist = filelist + name + ";";
}
}
if (filelist.Trim() != "") filelist = "其中文件名:" + filelist + "未导入";
resp.Success = true;
resp.Message = "导入成功" + filelist;
}
return Json(resp);
}
//public ContentResult GetNoList(int start, int limit, string condition, string sort="", string printstr="false")
//{
// var strSql = new StringBuilder();
// strSql.Append("SELECT BSNO, CUSTNO");
// strSql.Append(" FROM OP_CTNBSCARD ");
// if (!string.IsNullOrEmpty(condition))
// {
// strSql.Append(" Where " + condition);
// }
// strSql.Append(" order by isnull(PORTLOAD_CNT_TIME,getdate()) desc ");
// 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 GetNoList(string condition)
{
var dataList = MsOpCtnBsCardDAL.GetBSNOLIST(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult CQDataList(string condition, string printstr)
{
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) };
}
var strSql = new StringBuilder();
strSql.Append("SELECT SUM(CASE WHEN (PORTLOAD_CNT_TIME IS NULL AND PRE_CNT_TIME is not null AND DATEDIFF([day],PRE_CNT_TIME,GETDATE())>7) THEN 1 ELSE 0 END) PORTLOADCNTCQ ");
strSql.Append(",SUM(CASE WHEN (ETD IS NULL AND PORTLOAD_CNT_TIME IS NOT NULL AND DATEDIFF([day],PORTLOAD_CNT_TIME,GETDATE())>7) THEN 1 ELSE 0 END) ETDCQ ");
strSql.Append(",SUM(CASE WHEN (ETA IS NULL AND ETD IS NOT NULL AND DATEDIFF([day],ETD,GETDATE())>7) THEN 1 ELSE 0 END) ETACQ ");
strSql.Append(",SUM(CASE WHEN (DEST_RTCNT_TIME IS NULL AND ETA IS NOT NULL AND DATEDIFF([day],ETA,GETDATE())>7) THEN 1 ELSE 0 END) DESTRTCNTCQ ");
strSql.Append(" from op_ctnbscard where (PORTLOAD_CNT_TIME IS NULL or ETD IS NULL or ETA IS NULL or DEST_RTCNT_TIME IS NULL) ");
var isopen = MsBaseInfoDAL.GetUserModuleEnable("MsOpCtnCQTXIsOnly", Convert.ToString(Session["USERID"]));
if (isopen) {
strSql.Append(" and (APPLYNO IN (SELECT APPLYNO FROM V_OP_BS WHERE OP='" + Convert.ToString(Session["SHOWNAME"]) + "')) ");
}
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,100, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
}
public ContentResult GetOpLogList(string condition, string sort)
{
var dataList = MsOpCtnBsCardDAL.GetOpLogList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#region 参照部分
#endregion
}
}