You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/TruckMng/Controllers/PcHeadEdit_WFSDController.cs

442 lines
16 KiB
C#

3 years ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.TruckMng.DAL;
using DSWeb.Areas.TruckMng.DAL.MsRptPcHeadEdit;
using DSWeb.Areas.TruckMng.Models.MsWlBs;
using DSWeb.TruckMng.Helper;
using HcUtility.Comm;
using DSWeb.Areas.CommMng.Models;
using Microsoft.Practices.EnterpriseLibrary.Data;
using HcUtility.Core;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.EntityDA;
using DSWeb.TruckMng.Helper.Repository;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.MvcShipping.Models.MsOpLetter;
using DSWeb.Areas.MvcShipping.DAL;
using DSWeb.MvcShipping.DAL.ChMonthCloseDAL;
namespace DSWeb.Areas.TruckMng.Controllers
{
/// <summary>
/// 路单查询
/// </summary>
[JsonRequestBehavior]
public class PcHeadEdit_WFSDController : Controller
//20160217 应对潍坊松达需求
//在MSRPTPcHead(烟台爱德林需求)基础上修改
{
//
// GET: /RptMng/MsRptPcHeadQry
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ActionResult FeeEdit ( )
{
return View();
}
public ActionResult FeeAmendEdit()
{
return View();
}
public ContentResult GetDataList ( int start, int limit, string sort, string condition )
{
var dataList = MsRptPcHeadEditDAL.GetWFSDList(condition, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_UserName(Request), CookieConfig.GetCookie_CompanyId(Request), 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 GetDataFenList(int start, int limit, string sort, string condition)
{
var dataList = MsRptPcHeadEditDAL.GetWFSDFenList(condition, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition)
{
MsWlPcHead_WFSDEdit head = null;
if (handle == "edit" || handle == "copyadd")
{
head = MsRptPcHeadEditDAL.GetWFSDData(condition);
}
if (head == null)
{
head = new MsWlPcHead_WFSDEdit();
head.gId = "PC_" + Guid.NewGuid().ToString("N").ToUpper();
head.PGid = head.gId;
head.UserCode = CookieConfig.GetCookie_UserCode(Request);
head.UserName = Convert.ToString(Session["SHOWNAME"]);
head.BLTYPE = "派车单票";
var period = ChMonthCloseDAL.GetData("", CookieConfig.GetCookie_CompanyId(Request));
if (Convert.ToDateTime(period.FDAY) > DateTime.Now)
{
head.ACCDATE = period.PERIOD;
} else head.ACCDATE= DateTime.Now.ToString("yyyy-MM");
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult CreateDriverFee(string FeeValue, string data)
{
var headData = JsonConvert.Deserialize<MsWlPcHead_WFSDEdit>(data);
CostModel cm = new CostModel
{
BSNO = headData.gId,
CustomerName = headData.F_CustomerName,
FeeName = "陆运费",
FeeType = "2",
FeeValue = Convert.ToSingle(FeeValue),
CustomerType = "车队",
Remark = "利润自动生成司机费用",
};
DBResult resultCost = new DBResult { Success = false, Message = "" };
resultCost = MsOpLetterDAL.CreateCost(cm, CookieConfig.GetCookie_UserId(Request));
var jsonRespose = new JsonResponse
{
Success = resultCost.Success,
Message = resultCost.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveWFSD(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<MsWlPcHead_WFSDEdit>(data);
var isPost = true;
var errorstr = "";
var custno = "";
if (opstatus == "add")
{
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='陆运'", Convert.ToString(Session["COMPANYID"]));
billnoset.BILLTYPE = "0111";
billnoset.RULEDATETYPE = "业务日期";
var bsdate=headData.ExpDate;
if (bsdate == "" || bsdate == null)
bsdate = DateTime.Now.ToString("yyyy-MM-dd");
headData.BillNo = MsSysBillNoSetDAL.GetBillNo(billnoset, bsdate, DateTime.Now.ToString("yyyy-MM")); //获取合同号
headData.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
headData.DbOperationType = DbOperationType.DbotIns;
headData.TRANSSTATUS = "新建";
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
//if ( !string.IsNullOrEmpty(headData.ExpDate)){
// headData.ExpDate = headData.ExpDate.Replace("T", " ");
//}
//if ( !string.IsNullOrEmpty(headData.ExpDate))
//{
// headData.ExpDate = headData.ExpDate.Substring(0, 10);
//}
//if ( !string.IsNullOrEmpty(headData.ArriveDate))
//{
// headData.ArriveDate = headData.ArriveDate.Substring(0, 10);
//}
//if (!string.IsNullOrEmpty(headData.ReturnDate))
//{
// headData.ReturnDate = headData.ReturnDate.Substring(0, 10);
//}
if (!string.IsNullOrEmpty(headData.LrDate))
{
headData.LrDate = headData.LrDate.Substring(0, 10);
}
else
{
var currentTime = System.DateTime.Now;
headData.LrDate = currentTime.ToString("d");
}
var BSNO = headData.gId;
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
if (result.Success == true) { }
else
{
MsSysBillNoSetDAL.DeleteBsNo(custno);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsRptPcHeadEditDAL.GetWFSDData("GID='" + BSNO + "'")
};
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 SaveWFSDList ( string data )
{
var dataList = JsonConvert.Deserialize<List<MsWlPcHead_WFSDEdit>>(data);
foreach (var _d in dataList){
if ( !string.IsNullOrEmpty(_d.ExpDate)){
_d.ExpDate = _d.ExpDate.Replace("T", " ");
}
if ( !string.IsNullOrEmpty(_d.ExpDate))
{
_d.ExpDate = _d.ExpDate.Substring(0, 10);
}
if ( !string.IsNullOrEmpty(_d.ArriveDate))
{
_d.ArriveDate = _d.ArriveDate.Substring(0, 10);
}
if (!string.IsNullOrEmpty(_d.ReturnDate))
{
_d.ReturnDate = _d.ReturnDate.Substring(0, 10);
}
if (!string.IsNullOrEmpty(_d.LrDate))
{
_d.LrDate = _d.LrDate.Substring(0, 10);
}
else
{
var currentTime = System.DateTime.Now;
_d.LrDate = currentTime.ToString("d");
}
if (_d.BillNo == "" || _d.BillNo == "*")
{
_d.DbOperationType = DbOperationType.DbotIns;
_d.ModelUIStatus = "I";
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='陆运'", Convert.ToString(Session["COMPANYID"]));
billnoset.BILLTYPE = "0111";
_d.BillNo = MsSysBillNoSetDAL.GetBillNo(billnoset, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM")); //获取合同号
_d.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
_d.gId = "PC_" + Guid.NewGuid().ToString("N").ToUpper();
_d.PGid = _d.gId;
}
else
{
_d.DbOperationType = DbOperationType.DbotUpd;
_d.ModelUIStatus = "E";
}
}
var result = new DBResult();
var _L = ModelObjectConvert<MsWlPcHead_WFSDEdit>.ToModelObjectList(dataList);
//var _DL = ModelObjectConvert<MsWlPcHead_ADLEdit>.ToModelObjectList(DeldataList);
var modb = new ModelObjectRepository();
result = modb.SaveHead(_L);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult HuiDan(string data,string jsonBody)
{
var headData = JsonConvert.Deserialize<MsWlPcHead_WFSDEdit>(data);
var bodylist = JsonConvert.Deserialize<List<MsWlPcHead_WFSDEdit>>(jsonBody);
var result = MsRptPcHeadEditDAL.HuiDan(headData,bodylist);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult CreatePC ( string MblNo, string CustomerName, string ContainerQty, string Ton, string LoadCount )
{
var result = new DBResult();
var _D = new MsWlPcHead_WFSDEdit();
_D.MblNo = MblNo;
_D.CustomerName = CustomerName;
_D.ContainerQty = ContainerQty;//件数
_D.Ton = Ton;//重量
_D.LoadCount = LoadCount;//体积
//////////////
_D.DbOperationType = DbOperationType.DbotIns;
_D.ModelUIStatus = "I";
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='拼箱运输'", Convert.ToString(Session["COMPANYID"]));
billnoset.BILLTYPE = "0121";
_D.BillNo = MsSysBillNoSetDAL.GetBillNo(billnoset, DateTime.Now.ToString(), DateTime.Now.ToString()); //获取合同号
_D.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
_D.gId = "PC_" + Guid.NewGuid().ToString("N").ToUpper();
var modb = new ModelObjectRepository();
result = modb.Save(_D);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AddBillAuto(string data)
{
var head = JsonConvert.Deserialize<MsWlBsHead>(data);
var headData = new MsWlPcHead_WFSDEdit();
var isPost = true;
var errorstr = "";
var custno = "";
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='陆运'", Convert.ToString(Session["COMPANYID"]));
billnoset.BILLTYPE = "0111";
billnoset.RULEDATETYPE = "业务日期";
var bsdate = headData.ExpDate;
if (bsdate == "" || bsdate == null)
bsdate = DateTime.Now.ToString("yyyy-MM-dd");
headData.BillNo = MsSysBillNoSetDAL.GetBillNo(billnoset, bsdate, DateTime.Now.ToString("yyyy-MM")); //获取合同号
headData.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
headData.DbOperationType = DbOperationType.DbotIns;
headData.RefBillNo = head.BillNo;
headData.CustName= head.CustName;
headData.CustomerName = head.CustName;
headData.VoyVeg = head.VoyVeg;
headData.EtDate = head.EtDate;
headData.DstArea = head.DstArea;
headData.EndPortDate = head.EndPortDate;
headData.MblNo = head.MblNo;
headData.DispatchName = head.DispatchName;
headData.DetiNation = head.DetiNation;
if (!string.IsNullOrEmpty(headData.LrDate))
{
headData.LrDate = headData.LrDate.Substring(0, 10);
}
else
{
var currentTime = System.DateTime.Now;
headData.LrDate = currentTime.ToString("d");
}
var BSNO = headData.gId;
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
if (result.Success == true) { }
else
{
MsSysBillNoSetDAL.DeleteBsNo(custno);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsRptPcHeadEditDAL.GetWFSDData("GID='" + BSNO + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#region 参照部分
#endregion
}
}