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/MsWl_LKPcController.cs

790 lines
32 KiB
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.TruckMng.DAL.MsWl_LKPC;
using DSWeb.Areas.TruckMng.Models.MsWlDjPc;
using DSWeb.Areas.TruckMng.Models.Comm;
using DSWeb.Areas.TruckMng.Models.MsWlPc;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.TruckMng.Helper;
using DSWeb.TruckMng.Helper.Repository;
using HcUtility.Comm;
using HcUtility.Core;
using InvokeWebService;
using System.Text;
using System.Net;
using System.IO;
8 months ago
using DSWeb.SoftMng.Filter;
2 years ago
namespace DSWeb.Areas.TruckMng.Controllers
{
/// <summary>
/// 崂矿派车界面
/// </summary>
[JsonRequestBehavior]
public class MsWl_LKPCController : Controller
{
//
// GET: /TruckMng/MsWlDjPc/
public ActionResult Index()
{
return View();
}
//
// GET: /TruckMng/MsWlDjPc/Edit
public ActionResult Edit()
{
return View();
}
public ActionResult GetList ( )
{
return View();
}
//
// GET/TruckMng/MsWlDjPc/GetDataList
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var sqlwhere = condition;
if (!string.IsNullOrEmpty(condition))
sqlwhere += " and ";
sqlwhere += " PcBillType in ('4','5') ";
var dataList = MsWl_LKPCDAL.GetDataList(sqlwhere,Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request));
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 };
}
//
// GET/TruckMng/MsWlDjPc/GetData/
public ContentResult GetData(string handle, string condition)
{
MsWl_LKPCHead headData = null;
if (handle == "add")
{
headData = new MsWl_LKPCHead();
headData.GID = System.Guid.NewGuid().ToString();
headData.DdCode = CookieConfig.GetCookie_UserCode(Request);
headData.DdName = Convert.ToString(Session["SHOWNAME"]);
headData.LrDate = DateTime.Now;
headData.ExpDate = DateTime.Now.ToString("yyyy-MM-dd");
headData.FeeStatus = "0";
}
if (handle == "edit")
{
var list = MsWl_LKPCDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request));
if (list.Count > 0)
headData = list[0];
}
if (headData == null)
{
headData = new MsWl_LKPCHead();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = headData });
return new ContentResult() { Content = json };
}
public ContentResult GetBodyList(string billno)
{
var condition = " PC_BillNo='" + billno + "' ";
List<MsWl_LK_Cargomb> list = MsWl_LKPCDAL.GetCargoList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeFixBodyList(string billno)
{
var condition = " BillNo='" + billno + "'";
List<MsWlPcFixed> list = MsWl_LKPCDAL.GetFixBodyList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlDjPc/Save
public ContentResult Save(string opstatus, string data,
string Cargobody, string Cargodelbody,
string CargoDobody, string CargoDodelbody,
string fixbody, string fixdelbody, string chfeebody, string chfeedelbody)
{
var head = JsonConvert.Deserialize<MsWl_LKPCHead>(data);
var CargoBodyList = JsonConvert.Deserialize<List<MsWl_LK_Cargomb>>(Cargobody);
var CargoBodyDelList = JsonConvert.Deserialize<List<MsWl_LK_Cargomb>>(Cargodelbody);
var CargoDoList = JsonConvert.Deserialize<List<MsWl_LK_CargoDomb>>(CargoDobody);
var CargoDoDelList = JsonConvert.Deserialize<List<MsWl_LK_CargoDomb>>(CargoDodelbody);
var fixBodyList = JsonConvert.Deserialize<List<MsWlPcFixed>>(fixbody);
var fixBodyDelList = JsonConvert.Deserialize<List<MsWlPcFixed>>(fixdelbody);
var chfeeBodyList = JsonConvert.Deserialize<List<MsChFee>>(chfeebody);
var chfeeBodyDelList = JsonConvert.Deserialize<List<MsChFee>>(chfeedelbody);
head.TotalMil = head.NoLoadMil + head.OverLoadMil;
if (opstatus == "add")
{
head.BillNo = PubSysDAL.GetBillNo("0111");
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
head.UserCode = CookieConfig.GetCookie_UserCode(Request);
head.UserName = CookieConfig.GetCookie_UserName(Request);
head.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
head.OrgName = CookieConfig.GetCookie_OrgName(Request);
head.LrDate = DateTime.Now;
}
else if (opstatus == "edit")
{
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
}
else
{
head.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectRepository();
if (!string.IsNullOrEmpty(CargoDobody)) {
foreach(var _do in CargoDoList){
_do.DODATE = head.ExpDate;
}
}
DBResult result = modb.Save(head,
ModelObjectConvert<MsWl_LK_Cargomb>.ToModelObjectList(CargoBodyList),
ModelObjectConvert<MsWl_LK_Cargomb>.ToModelObjectList(CargoBodyDelList),
ModelObjectConvert<MsWl_LK_CargoDomb>.ToModelObjectList(CargoDoList),
ModelObjectConvert<MsWl_LK_CargoDomb>.ToModelObjectList(CargoDoDelList),
ModelObjectConvert<MsWlPcFixed>.ToModelObjectList(fixBodyList),
ModelObjectConvert<MsWlPcFixed>.ToModelObjectList(fixBodyDelList),
ModelObjectConvert<MsChFee>.ToModelObjectList(chfeeBodyList),
ModelObjectConvert<MsChFee>.ToModelObjectList(chfeeBodyDelList)
);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsWl_LKPCDAL.GetHeadDataByBillNo(head.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data)
{
var head = JsonConvert.Deserialize<MsWl_LKPCHead>(data);
var modb = new ModelObjectDBBill();
DBResult result = modb.Delete(head,
"delete from tMsWl_LK_Cargo where PC_BillNo='" + head.BillNo + "'",
"delete from tMsWl_LK_CargoDo where PC_BillNo='" + head.BillNo + "'");
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
public ContentResult GetTruckNoList(string condition)
{
var list = MsWl_LKPCDAL.GetTruckNoList(Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDrvNameList(string condition)
{
var list = MsWl_LKPCDAL.GetDrvNameList(Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
/*
public ContentResult GetDjBillNoList(string condition)
{
var list = MsWlDjPcDAL.GetDjBillNoList(Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetTruckFuel(string truckNo, string loadType, decimal ton, decimal mil)
{
var fuel = MsWlDjPcDAL.GetTruckFuel(truckNo, loadType, ton, mil);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = fuel });
return new ContentResult() { Content = json };
}
*/
#endregion
#region 获取货物变动信息
public ContentResult GetCargoDoList(string billno)
{
var condition = " PC_BillNo='" + billno + "' ";
List<MsWl_LK_CargoDomb> list = MsWl_LKPCDAL.GetCargoDoList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
#endregion
#region 自动生成 商品变动信息
public ContentResult MakeCargoDo(string CARGO_GID,string IOType,string AREA)
{//生成商品的变动信息
var _result = MsWl_LKPCDAL.MakeCargoDo(CARGO_GID, "",IOType,AREA);
var jsonRespose = new JsonResponse
{
Success = _result.Success,
Message = _result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//return new ContentResult() { Content = JsonConvert.Serialize("") };
}
public ContentResult MakeParentDo(string CARGO_GID,string IOType,string AREA)
{//无作用
var _result = MsWl_LKPCDAL.MakeCargoDo(CARGO_GID, "Parent", IOType,AREA);
var jsonRespose = new JsonResponse
{
Success = _result.Success,
Message = _result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//return new ContentResult() { Content = JsonConvert.Serialize("") };
}
public ContentResult MakeChildDo ( string CARGO_GID, string IOType, string AREA )
{//根据区域和cargo_gid来定位对应种类空桶的cargo_gid
//生成空桶的变动信息
var _result = MsWl_LKPCDAL.MakeCargoDo(CARGO_GID, "Child", IOType, AREA);
var jsonRespose = new JsonResponse
{
Success = _result.Success,
Message = _result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//return new ContentResult() { Content = JsonConvert.Serialize("") };
}
public ContentResult DelCargoDo ( string CARGO_GID, string IOType )
{
//HTmb head = null;
var _result = MsWl_LKPCDAL.DelCargoDo(CARGO_GID, IOType);
var jsonRespose = new JsonResponse
{
Success = _result.Success,
Message = _result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//return new ContentResult() { Content = JsonConvert.Serialize("") };
}
public ContentResult LOCKPC(string PC_BILLNO,string LOCKType)
{
var _result = MsWl_LKPCDAL.LOCKPC(PC_BILLNO, LOCKType);
var jsonRespose = new JsonResponse
{
Success = _result.Success,
Message = _result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//return new ContentResult() { Content = JsonConvert.Serialize("") };
}
public ContentResult LOCKBACK(string PC_BILLNO, string LOCKType)
{
var _result = MsWl_LKPCDAL.LOCKBACK(PC_BILLNO, LOCKType);
var jsonRespose = new JsonResponse
{
Success = _result.Success,
Message = _result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//return new ContentResult() { Content = JsonConvert.Serialize("") };
}
public ContentResult MakeBoxDo ( string PC_BILLNO, string IOType )
{
var _result = MsWl_LKPCDAL.MakeBoxDo(PC_BILLNO,IOType);
var jsonRespose = new JsonResponse
{
Success = _result.Success,
Message = _result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//return new ContentResult() { Content = JsonConvert.Serialize("") };
}
#endregion
#region 从刺猬网接口 获取货物变动信息
//批量 干线信息
public ContentResult GetGXPCList ( string BeginDate, string EndDate, string State )
{
var result = new DBResult();
result.Success = true;
//"http://96656.meichis.com/TrafficIF/T.asmx/GetTransferDelivery?BeginDate=2016-6-1&EndDate=2016-6-1&State=0";
//string url = "http://96656.meichis.com/TrafficIF/T.asmx/GetTransferDelivery";
string url = "http://www.96656.com.cn/TrafficIF/T.asmx/GetTransferDelivery";
string postData = "BeginDate=" + BeginDate + "&EndDate=" + EndDate + "&State=" + State + ""; // 要发放的数据
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(url);
objWebRequest.Method = "POST";
objWebRequest.ContentType = "application/x-www-form-urlencoded";
objWebRequest.ContentLength = byteArray.Length;
Stream newStream = objWebRequest.GetRequestStream();
// Send the data.
newStream.Write(byteArray, 0, byteArray.Length); //写入参数
newStream.Close();
HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string resultJson = sr.ReadToEnd(); // 返回的数据
if (resultJson.ToString() == "")
{
var jsonRespose = new JsonResponse
{
Success = false,
Message = "无返回值",
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else return DoGXInsert(resultJson);
}
//单独 干线信息
public ContentResult GetGXPC ( string SheetCode )
{
var result = new DBResult();
result.Success = true;
//"http://96656.meichis.com/TrafficIF/T.asmx/GetTransferDelivery?BeginDate=2016-6-1&EndDate=2016-6-1&State=0";
string url = "http://www.96656.com.cn/TrafficIF/T.asmx/GetTransferDeliveryBySheetCode";
string postData = "SheetCode=" + SheetCode + ""; // 要发放的数据
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(url);
objWebRequest.Method = "POST";
objWebRequest.ContentType = "application/x-www-form-urlencoded";
objWebRequest.ContentLength = byteArray.Length;
Stream newStream = objWebRequest.GetRequestStream();
// Send the data.
newStream.Write(byteArray, 0, byteArray.Length); //写入参数
newStream.Close();
HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string resultJson = sr.ReadToEnd(); // 返回的数据
if (resultJson.ToString() == "")
{
var jsonRespose = new JsonResponse
{
Success = false,
Message = "无返回值",
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else return DoGXInsert("["+resultJson+"]");
}
private ContentResult DoGXInsert(string resultJson){
var result = new DBResult();
int end = resultJson.LastIndexOf("]") + 1;
var json = resultJson.Substring(0, end);
int start = resultJson.IndexOf("[");
json = json.Substring(start, json.Length - start);
var PCList = JsonConvert.Deserialize<List<CW_GXYS>>(json);
//20160615 将数据存入数据库
var sequence = 0;
foreach (CW_GXYS PCHead in PCList)
{
//1首先 判断站点ID在本系统中是否存在
//2如否 插入此站点信息
//3如是 判断站点名称是否相同
//4--如否,则更新站点信息
PCHead.SupplierWareHouse = "GX" + PCHead.SupplierWareHouse;
var _dr = DealGXPointInfo(PCHead);
var MCHead = new MsWl_LK_MCHead();
MCHead.DbOperationType = DbOperationType.DbotIns;
MCHead.ModelUIStatus = "I";
MCHead.ID = PCHead.ID;
MCHead.PcBillType = "4";
MCHead.SheetCode = PCHead.SheetCode;
MCHead.SupplierWareHouse = PCHead.SupplierWareHouse;
MCHead.SupplierWareHouseName = PCHead.SupplierWareHouseName;
MCHead.State = PCHead.State;
MCHead.StateName = PCHead.StateName;
MCHead.PreArrivalDate = PCHead.PreArrivalDate;
MCHead.PreDepartDate = "1900-01-01";
MCHead.Remark = PCHead.SheetCode;
var MCCargoList = new List<MsWl_LK_MCCargo>();
foreach (CW_CARGO PCCargo in PCHead.Items)
{
var _ID = 0;
_ID++;
var MCCargo = new MsWl_LK_MCCargo();
if (!string.IsNullOrEmpty(PCCargo.DetailID))
{
MCCargo.ID = PCCargo.DetailID;
}
else
{
MCCargo.ID = "00" + _ID.ToString();
}
//MCCargo.ID = PCCargo.ID;
MCCargo.SheetCode_Parent = "";
MCCargo.SheetCode = "";//子表关键字自动填写//PCHead.SheetCode;
MCCargo.SEQUENCE = sequence++.ToString();
MCCargo.POINT_GID = PCHead.SupplierWareHouse;
MCCargo.CARGOINFO_GID = PCCargo.Product;
MCCargo.CargoCount = PCCargo.DeliveryQuantity;
MCCargo.SignInQuantity = PCCargo.SignInQuantity;
MCCargo.PalletCount = MsWl_LKPCDAL.GetPALLETCOUNT(PCCargo);
MCCargo.WEIGHT = "0";
MCCargoList.Add(MCCargo);
}
MCHead.DbOperationType = DbOperationType.DbotIns;
var modb1 = new ModelObjectDBBill();
DBResult result_D = modb1.Delete(MCHead,
"delete from tMsWl_LK_MCCargo where SheetCode_Parent='" + MCHead.SheetCode + "'");
var modb = new ModelObjectRepository();
result = modb.Save(MCHead,
ModelObjectConvert<MsWl_LK_MCCargo>.ToModelObjectList(MCCargoList),
ModelObjectConvert<MsWl_LK_MCCargo>.ToModelObjectList(null));
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//批量 分拨运输
public ContentResult GetFBPCList ( string BeginDate, string EndDate, string State )
{
var result = new DBResult();
result.Success = true;
//"http://96656.meichis.com/TrafficIF/T.asmx/GetTransferDelivery?BeginDate=2016-6-1&EndDate=2016-6-1&State=0";
string url = "http://221.215.209.108:8084/TrafficIF/T.asmx/GetSellOutShipping";
string postData = "BeginDate=" + BeginDate + "&EndDate=" + EndDate + "&State=" + State + ""; // 要发放的数据
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(url);
objWebRequest.Method = "POST";
objWebRequest.ContentType = "application/x-www-form-urlencoded";
objWebRequest.ContentLength = byteArray.Length;
Stream newStream = objWebRequest.GetRequestStream();
// Send the data.
newStream.Write(byteArray, 0, byteArray.Length); //写入参数
newStream.Close();
HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string resultJson = sr.ReadToEnd(); // 返回的数据
if (resultJson.ToString() == "")
{
var jsonRespose = new JsonResponse
{
Success = false,
Message = "无返回值",
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else return DoFBInsert(resultJson);
}
//单独 分拨运输
public ContentResult GetFBPC ( string SheetCode )
{
var result = new DBResult();
result.Success = true;
//"http://96656.meichis.com/TrafficIF/T.asmx/GetTransferDelivery?BeginDate=2016-6-1&EndDate=2016-6-1&State=0";
string url = "http://www.96656.com.cn/TrafficIF/T.asmx/GetSellOutShippingBySheetCode";
string postData = "SheetCode=" + SheetCode + ""; // 要发放的数据
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(url);
objWebRequest.Method = "POST";
objWebRequest.ContentType = "application/x-www-form-urlencoded";
objWebRequest.ContentLength = byteArray.Length;
Stream newStream = objWebRequest.GetRequestStream();
// Send the data.
newStream.Write(byteArray, 0, byteArray.Length); //写入参数
newStream.Close();
HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string resultJson = sr.ReadToEnd(); // 返回的数据
if (resultJson.ToString() == "")
{
var jsonRespose = new JsonResponse
{
Success = false,
Message = "无返回值",
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else return DoFBInsert("[" + resultJson + "]");
}
private ContentResult DoFBInsert ( string resultJson )
{
var result = new DBResult();
int end = resultJson.LastIndexOf("]") + 1;
var json = resultJson.Substring(0, end);
int start = resultJson.IndexOf("[");
json = json.Substring(start, json.Length - start);
var PCList = JsonConvert.Deserialize<List<CW_FBYS>>(json);
//20160615 将数据存入数据库
foreach (CW_FBYS PCHead in PCList)
{
var sequence = 1;
var MCHead = new MsWl_LK_MCHead();
MCHead.DbOperationType = DbOperationType.DbotIns;
MCHead.ModelUIStatus = "I";
MCHead.ID = PCHead.ID;
MCHead.PcBillType = "5";
MCHead.SheetCode = PCHead.SheetCode;
MCHead.SupplierWareHouse = PCHead.SupplierWareHouse;
MCHead.SupplierWareHouseName = PCHead.SupplierWareHouseName;
MCHead.State = PCHead.State;
MCHead.StateName = PCHead.StateName;
MCHead.PreDepartDate = PCHead.PreDepartDate;
MCHead.PreArrivalDate = "1900-01-01";
MCHead.Remark = PCHead.SheetCode;
var MCCargoList = new List<MsWl_LK_MCCargo>();
foreach (CW_POINT Point in PCHead.Items)
{
foreach (CW_CARGO PCCargo in Point.Items)
{
var _ID = 0;
_ID++;
var MCCargo = new MsWl_LK_MCCargo();
if (!string.IsNullOrEmpty(PCCargo.DetailID))
{
MCCargo.ID = PCCargo.DetailID;
}
else
{
MCCargo.ID = "00" + _ID.ToString();
}
//MCCargo.ID = PCCargo.ID;
MCCargo.SheetCode_Parent = "";
MCCargo.SheetCode = Point.SheetCode;//子表关键字自动填写//PCHead.SheetCode;
MCCargo.SEQUENCE = sequence++.ToString();
MCCargo.POINT_GID = Point.Client;
MCCargo.CARGOINFO_GID = PCCargo.Product;
MCCargo.CargoCount = PCCargo.DeliveryQuantity;
MCCargo.SignInQuantity = PCCargo.SignInQuantity;
MCCargo.PalletCount = MsWl_LKPCDAL.GetPALLETCOUNT(PCCargo);
MCCargo.WEIGHT = "0";
MCCargoList.Add(MCCargo);
}
}
MCHead.DbOperationType = DbOperationType.DbotIns;
var modb1 = new ModelObjectDBBill();
DBResult result_D = modb1.Delete(MCHead,
"delete from tMsWl_LK_MCCargo where SheetCode_Parent='" + MCHead.SheetCode + "'");
var modb = new ModelObjectRepository();
result = modb.Save(MCHead,
ModelObjectConvert<MsWl_LK_MCCargo>.ToModelObjectList(MCCargoList),
ModelObjectConvert<MsWl_LK_MCCargo>.ToModelObjectList(null));
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//return result;
}
public ContentResult GetMCHeadList ( int start, int limit, string sort, string condition )
{
var dataList = MsWl_LKPCDAL.GetMCHeadList(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 GetMCCargoList ( string condition )
{
//var condition = " SheetCode_Parent='" + SheetCode_Parent + "' ";
List<MsWl_LK_MCCargo> list = MsWl_LKPCDAL.GetMCCargoList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult DealGXPointInfo ( CW_GXYS Point )
{
var result = new DBResult();
var PointList = MsWl_LKPCDAL.GetPointList(" GID='" + Point.SupplierWareHouse + "'", "");
//var dataList = MsWl_LKPCDAL.GetMCHeadList(" SupplierWareHouse='" + Point.SupplierWareHouse + "' ", "");
if (PointList.Count > 0)
{
//已有 需要更新
var _d = PointList[0];
if (_d.NAME != Point.SupplierWareHouseName)
{
var _r = MsWl_LKPCDAL.GetPointList(" GID='" + Point.SupplierWareHouse + "'", "");
foreach (var _p in _r)
{
_p.GID = Point.SupplierWareHouse;
_p.NAME = Point.SupplierWareHouseName;
}
var modb = new ModelObjectRepository();
result = modb.SaveComm(
ModelObjectConvert<MsWl_LK_Pointmb>.ToModelObjectList(_r),
ModelObjectConvert<MsWl_LK_Pointmb>.ToModelObjectList(null)
);
}
}
else {
//没有 需要新增
var _r = new List<MsWl_LK_Pointmb>();
var _p = new MsWl_LK_Pointmb();
_p.GID = Point.SupplierWareHouse;
_p.NAME = Point.SupplierWareHouseName;
_p.POINTTYPE = "干线";
_p.INSERTED = "";
_r.Add(_p);
var modb = new ModelObjectRepository();
result = modb.SaveComm(
ModelObjectConvert<MsWl_LK_Pointmb>.ToModelObjectList(_r),
ModelObjectConvert<MsWl_LK_Pointmb>.ToModelObjectList(null)
);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 从刺猬网数据向派车单内添加明细
//20160809 如果是分拨 则根据站点写入区域
public ContentResult AddMCCargoToCargo(string Billno, string IDList, string PcBillType)
{
var _count = 0;
//var corpcode = CookieConfig.GetCookie_OrgCode(Request);
//var userid = CookieConfig.GetCookie_UserId(Request);
_count = MsWl_LKPCDAL.AddMCCargoToCargo(Billno, IDList, PcBillType);
var _success = false;
if (_count > 0)
{
_success = true;
}
var json = JsonConvert.Serialize(new { Success = _success, Message = "查询成功", totalCount = _count });
return new ContentResult() { Content = json };
}
#endregion
}
}