public JsonResult Forward(string sourceShipDocID, string targetTaskId, bool isOriginComplete, bool isTrashOrigin, string returnReason, string[] _caridz) { string message; ShippingDocument ret = this.service.TZRalation.Forward(sourceShipDocID, targetTaskId, isOriginComplete, isTrashOrigin, returnReason, out message, _caridz); return(OperateResult(ret != null, message, ret)); }
/// <summary> /// 运输单结算 /// </summary> /// <param name="sd"></param> public void JS(ShippingDocument sd) { sd.IsJS = true; decimal price = 0; ContractItem ci = this.m_UnitOfWork.GetRepositoryBase <ContractItem>().Get(this.m_UnitOfWork.GetRepositoryBase <ProduceTask>().Get(sd.TaskID).ContractItemsID); List <PriceSetting> list = this.m_UnitOfWork.GetRepositoryBase <PriceSetting>().All().Where(p => p.ContractItemsID == ci.ID).OrderBy(p => p.ChangeTime).ToList(); if (list.Count > 0) { int i = 0; while (list[i].ChangeTime < sd.BuildTime) { i++; } if (i == 0) { price = (ci.UnPumpPrice == null?0:(Decimal)ci.UnPumpPrice) + (ci.PumpPrice == null?0:(Decimal)ci.PumpPrice); } else { price = (list[i - 1].UnPumpPrice == null ? 0 : (Decimal)list[i - 1].UnPumpPrice) + (ci.PumpPrice == null ? 0 : (Decimal)ci.PumpPrice); } } else { price = (ci.UnPumpPrice == null?0:(Decimal)ci.UnPumpPrice) + (ci.PumpPrice == null?0:(Decimal)ci.PumpPrice); } sd.JSPrice = sd.SignInCube * price; this.m_UnitOfWork.ShippingDocumentRepository.Update(sd, null); this.m_UnitOfWork.Flush(); }
/// <summary> /// 删除记录 /// </summary> /// <param name="entity"></param> public override void Delete(TZRalation entity) { if (entity.IsAudit) { throw new Exception("已审核记录禁止删除"); } logger.Debug(string.Format("删除转退料记录,ID:{0},ReturnType:{1},ActionType:{2}", entity.ID, entity.ReturnType, entity.ActionType)); if (entity.ReturnType == "RT0") { var shipDocRepo = this.m_UnitOfWork.GetRepositoryBase <ShippingDocument>(); ShippingDocument sourceShippingDocument = entity.SourceShippingDocument; sourceShippingDocument.IsEffective = true; if (!string.IsNullOrEmpty(sourceShippingDocument.Remark) && sourceShippingDocument.Remark.IndexOf("CODEADD整车转发") >= 0) { sourceShippingDocument.Remark = sourceShippingDocument.Remark.Remove(sourceShippingDocument.Remark.IndexOf("CODEADD整车转发")); } ShippingDocument targetShippingDocument = entity.TargetShippingDocument; targetShippingDocument.IsEffective = false; targetShippingDocument.Remark = (string.IsNullOrEmpty(targetShippingDocument.Remark) ? "" : targetShippingDocument.Remark + " ") + "整车转发记录被删除"; shipDocRepo.Update(sourceShippingDocument, null); shipDocRepo.Update(targetShippingDocument, null); } base.Delete(entity); }
public ActionResult GetCarDataInfoForTask(string TaskID) { IList <Car> CarList = this.service.Car.Query(). Where(p => (p.TerminalID != null || p.TerminalID != string.Empty) && p.IsUsed && (p.GPSStatus == GpsCarStatus.Arrived || p.GPSStatus == GpsCarStatus.Go || p.GPSStatus == GpsCarStatus.Back || p.GPSStatus == GpsCarStatus.Burden)).ToList(); var factory = this.service.Company.GetCurrentCompany(); IList <ShippingDocument> shippingList = new List <ShippingDocument>(); foreach (Car car in CarList) { //优化 ShippingDocument sd = this.service.ShippingDocument.Query().OrderByDescending(p => p.BuildTime). FirstOrDefault(p => p.CarID == car.ID && p.IsEffective); if (sd != null) { shippingList.Add(sd); } } var cars = from car in CarList join ship in shippingList on car.ID equals ship.CarID where ship.TaskID == TaskID select car; var data = (List <object>)getCarDataExec(cars.ToList(), false); return(Json(data)); }
IList <ShippingDocument> GetShippingDocs() { if (Session["shipDocs"] == null) { SqlServerHelper helper = new SqlServerHelper(); IList <ShippingDocument> docs = new List <ShippingDocument>(); using (SqlDataReader sdr = helper.ExecuteReader("sp_kanban_shippingdocs", System.Data.CommandType.StoredProcedure, null)) { while (sdr.Read()) { ShippingDocument d = new ShippingDocument(); d.TaskID = sdr.GetString(0); d.CarID = sdr.IsDBNull(1) ? "" : sdr.GetString(1); d.ParCube = sdr.IsDBNull(2) ? 0 : sdr.GetDecimal(2); d.ProvidedCube = sdr.IsDBNull(3) ? 0 : sdr.GetDecimal(3); d.ProvidedTimes = sdr.IsDBNull(4) ? 0 : sdr.GetInt32(4); d.BuildTime = sdr.GetDateTime(5); d.SlurryCount = sdr.IsDBNull(6) ? 0 : sdr.GetDecimal(6); d.PumpName = sdr.IsDBNull(7) ? "" : sdr.GetString(7); d.ShipDocType = sdr.IsDBNull(8) ? "" : sdr.GetString(8); d.ArriveTime = sdr.IsDBNull(9) ? (DateTime?)null : sdr.GetDateTime(9); //暂时用质检员代替时量 docs.Add(d); } } Session["shipDocs"] = docs; return(docs); } else { return((IList <ShippingDocument>)Session["shipDocs"]); } }
public JsonResult GetLastDocByCarId(string carId) { TZRalation tz = this.service.TZRalation.Query() .Where(p => p.CarID == carId && p.IsCompleted == false) .FirstOrDefault(); if (tz != null) {//有未完成的退转料记录 return(OperateResult(false, Lang.TZRelation_Error_HasUnCompletedRecords_NO, null)); } else { ShippingDocument doc = this.service.ShippingDocument.Query() .Where(p => p.CarID == carId && p.IsEffective) .OrderByDescending(p => p.BuildTime) .FirstOrDefault(); if (doc != null && this.service.TZRalation.Query() .Where(p => p.SourceShipDocID == doc.ID) .Count() > 0) { return(OperateResult(false, Lang.TZRelation_Error_HasTZRelationRecords, null)); } return(OperateResult(doc != null, "", doc)); } }
public ShippingDocument Create() { var shippingDoc = new ShippingDocument() { ID = FindAll().Count + 1 }; shippingRepository.Insert(shippingDoc); return(shippingDoc); }
public void Delete(ShippingDocument entity) { if (entity.ListOfPackages != null) { foreach (var package in entity.ListOfPackages) { packages.Delete(package); } } if (entity.OrderDocument != null) { orders.Delete(entity.OrderDocument); } posts.Remove(entity); }
public ActionResult CopyRecord(string id, int pots) { try { ProductRecord obj = this.service.GetGenericService <ProductRecord>().Get(id); ShippingDocument ShippingDocument = this.service.GetGenericService <ShippingDocument>().Get(obj.ShipDocID); IList <ProductRecord> ps = this.service.GetGenericService <ProductRecord>().Query().Where(m => m.ShipDocID == obj.ShipDocID).ToList(); int?MaxPots = this.service.DispatchList.CalculateTotalPot(obj.PCRate, ShippingDocument.SendCube); IList <ProductRecordItem> items = this.service.ProductRecordItemService.Query().Where(m => m.ProductRecordID == id).ToList(); if (MaxPots < ps.Count + 1) { throw new Exception("本车生产" + ShippingDocument.SendCube + "方,最多" + MaxPots + "盘,超出盘数了"); } ProductRecord temp = new ProductRecord(); temp.ID = obj.ID.Substring(0, obj.ID.LastIndexOf('_')) + "_" + pots; temp.IsManual = true; temp.PCRate = obj.PCRate; temp.PotTimes = pots; temp.ShipDocID = obj.ShipDocID; temp.BuildTime = obj.BuildTime; temp.ProduceCube = obj.ProduceCube; temp.DispatchID = obj.DispatchID; temp.ProductLineID = obj.ProductLineID; temp = this.service.GetGenericService <ProductRecord>().Add(temp); foreach (ProductRecordItem item in items) { ProductRecordItem obj1 = new ProductRecordItem(); obj1.ProductRecordID = temp.ID; obj1.SiloID = item.SiloID; obj1.StuffID = item.StuffID; obj1.TheoreticalAmount = item.TheoreticalAmount; obj1.ActualAmount = item.ActualAmount; obj1.ErrorValue = item.ErrorValue; this.service.ProductRecordItemService.Add(obj1); } return(OperateResult(true, Lang.Msg_Operate_Success, temp)); } catch (Exception ex) { return(OperateResult(false, ex.Message, false)); } }
public ActionResult HandleAdd(ProductRecord ProductRecord) { ShippingDocument shippingDocument = this.service.GetGenericService <ShippingDocument>().Get(ProductRecord.ShipDocID); ProductRecord.ProductLineID = shippingDocument.ProductLineID; if (ProductRecord.ID == null) { ProductRecord.ElectValue = 0; ProductRecord.IsManual = true; return(base.Add(ProductRecord)); } else { return(base.Update(ProductRecord)); } }
public JsonResult GetLastDocAutoByCarId(string carId) { TZRalation tz = this.service.TZRalation.Query() .Where(p => p.CarID == carId && p.IsCompleted == false && p.AH == Model.Enums.Consts.Auto && (p.ActionType == string.Empty || p.ActionType == null)) .OrderByDescending(p => p.BuildTime) .FirstOrDefault(); if (tz != null) { ShippingDocument doc = this.service.ShippingDocument.Query().Where(p => p.ID == tz.SourceShipDocID).FirstOrDefault(); return(OperateResult(true, string.Empty, doc)); } else { return(OperateResult(false, string.Empty, null)); } }
public bool Import(string id) { using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction()) { try { bool result = true; ProductRecord obj = this.Get(id); ShippingDocument shipdoc = this.m_UnitOfWork.ShippingDocumentRepository.Get(obj.ShipDocID); ConsMixprop cm = this.m_UnitOfWork.ConsMixpropRepository.Get(shipdoc.ConsMixpropID); List <ConsMixpropItem> list = this.m_UnitOfWork.ConsMixpropItemRepository.Query().Where(m => m.ConsMixpropID == cm.ID && m.Amount > 0).ToList(); ThreadID tid; PublicService ps = new PublicService(); foreach (ConsMixpropItem c in list) { ProductRecordItem tmp = new ProductRecordItem(); tmp.ActualAmount = obj.ProduceCube * c.Amount; tmp.TheoreticalAmount = obj.ProduceCube * c.Amount; tmp.SiloID = c.SiloID; tmp.StuffID = c.Silo.StuffInfo.ID; tmp.ProductRecordID = id; tmp.ErrorValue = 0; tmp.ProductLineID = obj.ProductLineID; this.m_UnitOfWork.GetRepositoryBase <ProductRecordItem>().Add(tmp); tid = new ThreadID(); tid.currentDate = DateTime.Now; tid.typeID = tmp.StuffID; //主材id tid.typename = "0"; //主材 ps.ThreadID.Add(tid); } tx.Commit(); return(result); } catch (Exception ex) { tx.Rollback(); logger.Error(ex.Message); throw new Exception(ex.Message); } } }
public string FactoryDistance(ShippingDocument ship, LastestGpsInfo gps) { if (ship == null || gps == null) { return(null); } distanceByShip ds = this.service.GetGenericService <distanceByShip>().Query().Where(m => m.shipdocid == ship.ID).FirstOrDefault(); distance dt = this.service.GetGenericService <distance>().Query().Where(m => m.projectid == ship.ProjectID && m.CastMode.TreeCode == ship.CastMode).FirstOrDefault(); var factory = this.service.Company.GetCurrentCompany(); if (ds == null || dt == null || ds.outbuilding == 0m) { string str = GetFactoryDistance(gps, factory); return(str); } decimal d = dt.distance - (gps.Distance.Value - ds.outbuilding); return(d < 0 ? (0.01m).ToString() : d.ToString()); }
public override ActionResult Delete(string[] id) { foreach (object item in id) { ConsMixprop cm = this.m_ServiceBase.Get(item); DateTime dt1 = cm.BuildTime; string taskid = cm.TaskID; string pid = cm.ProductLineID; ProduceTask pt = this.service.ProduceTask.Get(taskid); ShippingDocument doc = this.service.ShippingDocument.Find("TaskID = '" + taskid + "' AND IsEffective = 1 AND ShipDocType = '0'", 1, 1, "ID", "DESC").FirstOrDefault(); if (doc != null) { DateTime dt2 = doc.BuildTime; if (doc.ProvidedCube > 0 && doc.ProductLineID == pid && dt1 < dt2) { return(OperateResult(false, Lang.Msg_Operate_Failed + "已生产的施工配比不允许删除", "")); } } } return(base.Delete(id)); }
public static ShippingDocument CreateShippingDocumentWithPackedPackage() { ShippingDocument p = new ShippingDocument { ID = 4, Operator = new Operator() { FirstName = "Konrad", LastName = "Dymek" }, OrderDocument = new OrderDocument() { ID = 1, Client = new OrderClient() { FirstName = "Prezes", LastName = "Prezes", EMail = "*****@*****.**" }, Goods = new List <string>() { "Towar 11" }, OrderDate = DateTime.Now, OrderDocumentNumber = "ORD/4", ShippingType = Shipment.POST }, ListOfPackages = new List <Package>() { new Package() { ID = 1, Number = "PCG/1", Status = Statuses.PACKED }, }, ShippingDocumentNumber = "DOC/4" }; return(p); }
public object getDispatchInfoByID(string id) { string shipDocID = string.Empty; int? nullable = 0; DispatchList list = base.m_UnitOfWork.GetRepositoryBase <DispatchList>().Get(id); if (list != null) { shipDocID = list.ShipDocID; nullable = list.BTotalPot + list.STotalPot; } else { DispatchListHistory history = base.m_UnitOfWork.GetRepositoryBase <DispatchListHistory>().Find("DispatchID = '" + id + "'", 1, 10, "ASC", "AutoID").FirstOrDefault <DispatchListHistory>(); if (history != null) { shipDocID = history.ShipDocID; nullable = history.BTotalPot + history.STotalPot; } } ShippingDocument document = base.m_UnitOfWork.GetRepositoryBase <ShippingDocument>().Get(shipDocID); return(new { Result = true, Message = string.Empty, TaskID = (document == null) ? string.Empty : document.TaskID, ShipDocID = (document == null) ? string.Empty : document.ID, ProjectName = (document == null) ? string.Empty : document.ProjectName, ConStrength = (document == null) ? string.Empty : document.ConStrength, ProductLineID = (document == null) ? string.Empty : document.ProductLineID, CarID = (document == null) ? string.Empty : document.CarID, SendCube = (document == null) ? 0M : document.SendCube, SendPot = nullable, Operator = (document == null) ? string.Empty : document.Operator }); }
///// <summary> ///// GPS获取所有车辆和状态信息 ///// </summary> ///// <returns></returns> //public ActionResult GetAllCarAndStatus(string id) //{ // try // { // IList<Car> carlist = new List<Car>(); // if (string.IsNullOrEmpty(id)) // { // carlist = this.service.Car.Query().Where(p => p.IsUsed).ToList(); // } // else // { // carlist = this.service.Car.Query().Where(p => p.IsUsed && p.ID == id).ToList(); // } // IList<LastestGpsInfo> lsiList = this.service.GetGenericService<LastestGpsInfo>().Query().ToList(); // IList<ShippingDocument> shippingList = this.service.ShippingDocument.getShippingTask(null); // if (carlist != null && lsiList != null && shippingList != null) // { // var cars = from car in carlist // join gpss in lsiList on car.TerminalID equals gpss.TerminalID into gpsinfo // from gps in gpsinfo.DefaultIfEmpty() // join cartask in shippingList // on car.ID equals cartask.CarID into cartasks // from task in cartasks.DefaultIfEmpty() // where car.CarTypeID == Model.Enums.CarType.Mixer // orderby car.OrderNum ascending // select new // { // car = car, // gps = gps, // task = task // }; // var factory = this.service.Company.GetCurrentCompany(); // var result = cars.ToList().Select( // s => new // { // Id = s.car.ID, // CustomNo = s.car.ID, // CarNum = s.car.CarNo, // TerminalID = s.car.TerminalID, // SIM = s.car.SIM, // Owner = s.car.Owner, // CarTypeName = s.car.CarTypeID == null ? "" : GetDicName(s.car.CarTypeID), // CarWeight = s.car.CarWeight, // CarCapacity = s.task == null ? 0 : s.task.ParCube, // ProvidedTimes = s.task == null ? 0 : s.task.ProvidedTimes, // StatusID = s.car.GPSStatus == null ? Model.Enums.GpsCarStatus.UnKnown : s.car.GPSStatus, // //默认未知 // StatusCode = s.car.GPSStatus == null ? Model.Enums.GpsCarStatus.UnKnown : s.car.GPSStatus, // StatusName = s.car.GPSStatus == null ? "未知" : GetDicName(s.car.GPSStatus), // DriverID = s.task == null ? string.Empty : s.task.Driver, // DriverName = s.task == null ? string.Empty : s.task.Driver, // ProduceLineID = s.task == null ? string.Empty : s.task.ProductLineID, // ProduceLineName = s.task == null ? string.Empty : s.task.ProductLineName, // //gpsinfo // Latitude = s.gps == null || s.gps.Latitude == null ? null : s.gps.Latitude.Value.ToString("#0.0000"), // Longtidue = s.gps == null || s.gps.Longtidue == null ? null : s.gps.Longtidue.Value.ToString("#0.0000"), // Speed = s.gps == null ? null : s.gps.Speed, // Height = s.gps == null ? null : s.gps.Height, // Direction = s.gps == null ? null : s.gps.Direction, // Oil = s.gps == null ? null : s.gps.Oil, // ProjectDistance = GetProjectDistance(s.gps, s.task), // FactoryDistance = GetFactoryDistance(s.gps, factory), // UnLoad = s.gps == null ? null : s.gps.UnLoad, // UnLoadTme = s.gps == null ? null : s.gps.UnLoadTme, // Place = s.gps == null ? null : s.gps.Place, // AccFlag = s.gps == null ? null : s.gps.AccFlag, // BeaterStatus = s.gps == null ? null : s.gps.BeaterStatus, // ErrorCode = s.gps == null ? null : s.gps.ErrorCode, // //经纬度无效 // IsGpsError = s.gps == null || s.gps.Latitude == null || s.gps.Longtidue == null, // //gps数据传递延时5分钟 // IsGprsError = s.gps == null ? true : s.gps.Receivetime.Value.AddHours(2) < DateTime.Now, // //taskInfo // TaskID = s.task == null ? null : s.task.TaskID, // ProjectID = s.task == null ? null : (s.task == null ? null : s.task.ProjectID) // } // ).ToList(); // return new ContentResult // { // Content = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }.Serialize(result), // ContentType = "application/json" // }; // //return Json(result); // } // return null; // } // catch (Exception ex) // { // return null; // } //} private string GetProjectDistance(LastestGpsInfo gps, ShippingDocument task) { if (gps == null || !gps.Latitude.HasValue || !gps.Longtidue.HasValue || task == null) { return(null); } else { Project p = this.service.Project.Query().Where(pj => pj.ID == task.ProjectID).ToList().FirstOrDefault(); if (p == null || !p.Latitude.HasValue || !p.Longitude.HasValue) { return(null); } return(LatLonUtils.GetDistance( gps.Latitude.Value, gps.Longtidue.Value, p.Latitude.Value, p.Longitude.Value).ToString("#0.00")); } }
public void Delete(ShippingDocument entity) { shippingRepository.Delete(entity); }
public void Insert(ShippingDocument entity) { posts.Add(entity); }
private object getCarDataExec(IList <Car> cars, bool GridData) { JsonJqGridData data = new JsonJqGridData(); data.rows = new List <JqGridRow>(); IList <object> DataList = new List <object>(); var gpsinfos = this.service.GetGenericService <LastestGpsInfo>().Query().ToList(); var OneTimeAgo = DateTime.Now.AddHours(-4); var allogs = this.service.GetGenericService <AlarmLog>().Query() .Where(exp => exp.AlarmTime >= OneTimeAgo).ToList(); var infos = from car in cars join gpsinfo in gpsinfos on car.TerminalID equals gpsinfo.TerminalID orderby car.CarNo select new { Id = car.ID , CustomNo = car.ID , TerminalId = car.TerminalID , CarType = car.CarTypeID != null ? car.CarTypeID : "" , SimNo = car.SIM , Longtidue = gpsinfo.Longtidue , Latitude = gpsinfo.Latitude , Speed = gpsinfo.Speed , Height = gpsinfo.Height , Direction = gpsinfo.Direction , Oil = gpsinfo.Oil , Distance = gpsinfo.Distance , AccFlag = gpsinfo.AccFlag != null ? gpsinfo.AccFlag : "3" , BeaterStatus = gpsinfo.BeaterStatus != null ? gpsinfo.BeaterStatus : "4" , Sendtime = gpsinfo.Sendtime , StatusName = car.GPSStatus != null ? car.GPSStatus : "" , //Driver = car.Status != null ? car.Status.CurrentDriverName : "" // , //DriverTel = car.Status != null ? car.Status.CurrentDriverTel : "" //, Driver = getCarDriver(car.ID) , DriverTel = "" , DayCount = this.service.ShippingDocument.Query().Count(s => s.IsEffective && //优化 s.ProduceDate >= DateTime.Now.Date && s.ProduceDate <= DateTime.Now.Date.AddDays(1).AddSeconds(-1) && s.CarID == car.ID) //今天的调度运输单车次 , MonthCount = this.service.ShippingDocument.Query().Count(s => s.IsEffective && s.ProduceDate >= new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1) && s.ProduceDate <= new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddSeconds(-1) && s.CarID == car.ID) //这个月的调度运输单车次 }; data.records = infos.Count(); data.page = 1; data.total = infos.Count(); foreach (var item in infos.ToList().OrderBy(c => c.CustomNo)) { ShippingDocument shippingdocument = this.service.ShippingDocument.Query().OrderByDescending(p => p.BuildTime) .FirstOrDefault(p => p.IsEffective == true && p.CarID == item.Id && (item.StatusName == GpsCarStatus.Arrived || item.StatusName == GpsCarStatus.Back || item.StatusName == GpsCarStatus.Burden || item.StatusName == GpsCarStatus.Go)); var row = new JqGridRow(); var cells = new List <string>(); //计算报警数 List <GPS_CarAlarmInfo> alarmInfos = this.service.AlarmLog.GetAlarams(item.TerminalId, cars, gpsinfos, allogs); int alarmCount = alarmInfos.Count(); var alarmInfostr = Newtonsoft.Json.JsonConvert.SerializeObject(alarmInfos, Newtonsoft.Json.Formatting.Indented); var itemTaskName = string.Empty; var itemTaskStatus = string.Empty; var ParCube = string.Empty; var taskInfo = shippingdocument; if (taskInfo != null) { itemTaskName = taskInfo.ProjectName + ":" + taskInfo.CastMode + ":" + taskInfo.ConsPos + ":" + taskInfo.ConStrength; itemTaskStatus = taskInfo.Status; ParCube = taskInfo.ParCube.ToString(); } if (GridData) { row.id = item.Id.ToString(); cells.Add(item.Id.ToString()); cells.Add(item.TerminalId); cells.Add(alarmCount + ""); cells.Add(alarmCount + ""); cells.Add(item.CustomNo); cells.Add(item.CarType); cells.Add(item.Longtidue + ""); cells.Add(item.Latitude + ""); cells.Add(item.AccFlag); cells.Add(item.BeaterStatus); cells.Add(item.StatusName); cells.Add(itemTaskStatus); cells.Add(itemTaskName); cells.Add(ParCube); cells.Add(item.Sendtime.ToString()); cells.Add(item.SimNo); cells.Add(item.Oil.HasValue ? item.Oil.Value + "" : "--"); cells.Add(item.Speed.HasValue ? item.Speed + "" : "--"); cells.Add(item.Height.HasValue ? item.Height + "" : "--"); cells.Add(item.Direction.HasValue ? item.Direction + "" : "--"); cells.Add(item.Distance.HasValue ? item.Distance.Value.ToString(".0") : "--"); cells.Add(item.Driver); cells.Add(item.DriverTel); cells.Add(""); //参考地址 cells.Add(alarmInfostr); cells.Add(item.DayCount.ToString()); cells.Add(item.MonthCount.ToString()); row.cell = cells; data.rows.Add(row); } else { var dataitem = new { Id = item.Id, TerminalId = item.TerminalId, AlarmCount = alarmCount, CustomNo = item.CustomNo, Longtidue = item.Longtidue, Latitude = item.Latitude, AccFlag = item.AccFlag, BeaterStatus = item.BeaterStatus, StatusName = item.StatusName, TaskName = itemTaskName, itemTaskStatus = itemTaskStatus, Sendtime = item.Sendtime.ToString(), SimNo = item.SimNo, CarType = item.CarType, ParCube = taskInfo.ParCube, DayCount = item.DayCount, MonthCount = item.MonthCount, Oil = item.Oil.HasValue ? item.Oil.Value + "" : "--", Speed = item.Speed.HasValue ? item.Speed + "" : "--", Height = item.Height.HasValue ? item.Height + "" : "--", Direction = item.Direction.HasValue ? item.Direction + "" : "--", Distance = item.Distance.HasValue ? item.Distance.Value.ToString(".0") : "--", Driver = item.Driver, DriverTel = item.DriverTel, AlarmInfos = alarmInfostr }; DataList.Add(dataitem); } } object returndata; if (GridData) { returndata = data; } else { returndata = DataList; } return(returndata); }
/// <summary> /// 整车转发 /// </summary> /// <param name="sourceShipDocID">源运输单ID</param> /// <param name="targetTaskId">转至任务单</param> /// <param name="isOriginComplete">原任务单已完成(不需要转料后补)</param> /// <param name="isTrashOrigin">原任务单作废</param> /// <param name="returnReason">转发原因</param> /// <returns></returns> public ShippingDocument Forward(string sourceShipDocID, string targetTaskId, bool isOriginComplete, bool isTrashOrigin, string returnReason, out string message, string[] _carids) { var shipDocRepo = this.m_UnitOfWork.GetRepositoryBase <ShippingDocument>(); ShippingDocument oldDoc = shipDocRepo.Get(sourceShipDocID); ProduceTask task = this.m_UnitOfWork.GetRepositoryBase <ProduceTask>().Get(targetTaskId); message = Lang.Msg_Operate_Success; if (oldDoc != null && task != null) { //UNDONE: 转发方量和生产方量是否要处理 ShippingDocument newDoc = new ShippingDocument();// oldDoc.Clone() as ShippingDocument;\ //如果有_carids说明不光转发还要换车 if (_carids == null || _carids.Length == 0 || string.IsNullOrEmpty(_carids[0])) { newDoc.CarID = oldDoc.CarID; } else { newDoc.CarID = _carids[0]; } newDoc.IsEffective = true; newDoc.ContractID = task.ContractID; newDoc.ContractName = task.Contract.ContractName; newDoc.CustName = task.Contract.CustName; newDoc.CustomerID = task.Contract.CustomerID; newDoc.CustMixpropID = task.CustMixpropID; newDoc.ProductLineName = oldDoc.ProductLineName; newDoc.ProductLineID = oldDoc.ProductLineID; newDoc.DeliveryTime = DateTime.Now; //newDoc.ProduceDate = oldDoc.ProduceDate; newDoc.ProduceDate = DateTime.Now; newDoc.ConsMixpropID = oldDoc.ConsMixpropID; newDoc.SlurryConsMixpropID = oldDoc.SlurryConsMixpropID; newDoc.FormulaName = oldDoc.FormulaName; newDoc.ProjectName = task.ProjectName; newDoc.ProjectAddr = task.ProjectAddr; newDoc.ProjectID = task.ProjectID; newDoc.ShipDocType = "0"; newDoc.ConStrength = task.ConStrength; newDoc.CastMode = task.CastMode; newDoc.ConsPos = task.ConsPos; newDoc.ImpGrade = task.ImpGrade; newDoc.ImyGrade = task.ImyGrade; newDoc.ImdGrade = task.ImdGrade; newDoc.CarpRadii = task.CarpRadii; newDoc.CementBreed = task.CementBreed; newDoc.Distance = oldDoc.Distance; newDoc.RealSlump = task.Slump;//oldDoc.RealSlump;此处换成目标工地的坍落度,保持与票面一致 newDoc.BetonCount = oldDoc.BetonCount; newDoc.SlurryCount = oldDoc.SlurryCount; newDoc.OtherCube = oldDoc.OtherCube; newDoc.XuCube = oldDoc.XuCube; newDoc.RemainCube = oldDoc.RemainCube; newDoc.ShippingCube = oldDoc.ShippingCube; newDoc.PlanCube = task.PlanCube; //调度方量 = 混凝土 + 砂浆 newDoc.SendCube = newDoc.BetonCount + newDoc.SlurryCount; //出票方量 = 调度方量 + 其它方量 + 剩余方量 decimal?parCube = newDoc.SendCube + newDoc.OtherCube + (newDoc.RemainCube ?? 0); newDoc.ParCube = parCube ?? 0; newDoc.SignInCube = newDoc.ParCube; newDoc.ScrapCube = 0; newDoc.TransferCube = 0; newDoc.Surveyor = oldDoc.Surveyor; newDoc.Operator = oldDoc.Operator; newDoc.RegionID = task.RegionID; newDoc.ForkLift = task.ForkLift; newDoc.PlanClass = task.PlanClass; //newDoc.ProduceDate = DateTime.Now; newDoc.SupplyUnit = task.SupplyUnit; newDoc.ConstructUnit = task.ConstructUnit; newDoc.Signer = AuthorizationService.CurrentUserID; newDoc.LinkMan = task.LinkMan; newDoc.Tel = task.Tel; //是否代外生产. newDoc.EntrustUnit = task.IsCommission ? task.SupplyUnit : ""; newDoc.Remark = string.Format("CODEADD由运输单:{0}整车转发生成", sourceShipDocID); newDoc.IsProduce = oldDoc.IsProduce; newDoc.ID = null; newDoc.TaskID = targetTaskId; //从最后一个发货单取得累计方量和车数 ShippingDocumentService sdService = new ShippingDocumentService(this.m_UnitOfWork); ShippingDocument doc = sdService.Query() .Where(p => p.TaskID == targetTaskId && p.IsEffective == true && p.ShipDocType == "0") .OrderByDescending(p => p.BuildTime) .FirstOrDefault(); if (doc != null) { newDoc.ProvidedTimes = doc.ProvidedTimes + 1; newDoc.ProvidedCube = doc.ProvidedCube + newDoc.ParCube; newDoc.PumpName = doc.PumpName; } else { newDoc.ProvidedTimes = 1; newDoc.ProvidedCube = newDoc.ParCube; } //newDoc.ProjectName = task.ProjectName; //newDoc.ConStrength = task.ConStrength; //newDoc.CastMode = task.CastMode; //newDoc.ConsPos = task.ConsPos; //newDoc.ImpGrade = task.ImpGrade; //newDoc.ImyGrade = task.ImyGrade; //newDoc.ImdGrade = task.ImdGrade; //newDoc.CarpRadii = task.CarpRadii; //newDoc.CementBreed = task.CementBreed; //newDoc.ForkLift = task.ForkLift; //newDoc.PlanClass = task.PlanClass; //newDoc.ProduceDate = DateTime.Now; //newDoc.SupplyUnit = task.SupplyUnit; //newDoc.ConstructUnit = task.ConstructUnit; ////是否托外生产. //newDoc.EntrustUnit = task.IsCommission ? task.SupplyUnit : ""; //newDoc.IsEffective = true; //生产登记关系转移到新发货单 newDoc.DispatchLists = new List <DispatchList>(); //newDoc.DispatchLists.Clear(); //newDoc.DispatchLists = null; newDoc.TZRalations = null; foreach (var d in oldDoc.DispatchLists) { newDoc.DispatchLists.Add(d); } //原调度关系清空 oldDoc.DispatchLists.Clear(); //原运输单是否作废 oldDoc.IsEffective = !isTrashOrigin; //记录作废原因 if (oldDoc.IsEffective) { oldDoc.Remark = (string.IsNullOrEmpty(oldDoc.Remark) ? "" : oldDoc.Remark + " ") + "CODEADD整车转发"; } else { oldDoc.Remark = (string.IsNullOrEmpty(oldDoc.Remark) ? "" : oldDoc.Remark + " ") + "CODEADD整车转发作废"; } //退转料记录 TZRalation tzRelation = new TZRalation { SourceShipDocID = oldDoc.ID, SourceCube = oldDoc.ParCube, CarID = oldDoc.CarID, Driver = oldDoc.Driver, Cube = oldDoc.ParCube, ReturnType = ZLERP.Model.Enums.ReturnType.Forward, ActionType = ZLERP.Model.Enums.ActionType.Transfer, IsCompleted = true, ReturnReason = returnReason }; //UNDONE:目标任务单是否要更新已供和累计方量 using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction()) { try { oldDoc.IsProduce = false; shipDocRepo.Update(oldDoc, null); //this.m_UnitOfWork.Flush(); shipDocRepo.Add(newDoc); // this.m_UnitOfWork.Flush(); tzRelation.TargetShipDocID = newDoc.ID; //整车转发时,生产记录自动转 List <ProductRecord> prList = this.m_UnitOfWork.GetRepositoryBase <ProductRecord>().Query() .Where(m => m.ShipDocID == oldDoc.ID) .ToList(); foreach (ProductRecord pr in prList) { pr.ShipDocID = newDoc.ID; this.m_UnitOfWork.GetRepositoryBase <ProductRecord>().Update(pr, null); } DateTime ts = DateTime.Now; tzRelation.ActionTime = ts; tzRelation.ActionCube = tzRelation.Cube; //整车转发状态设置为3 tzRelation.IsLock = "3"; //转退料单号 tzRelation.TzRalationFlag = getZtlDh() + "ZC"; base.Add(tzRelation); tx.Commit(); return(newDoc); } catch (Exception ex) { message = ex.Message; tx.Rollback(); logger.Error(ex.Message, ex); } } } return(null); }
public static ShippingDocument CreateEmptyShippingDocument() { ShippingDocument p = new ShippingDocument(); return(p); }
//public override void Update(TZRalation entity) //{ // base.Update(entity); // entity.IsLock = "3"; // AddHistory(entity, "update", entity.CarID, entity.Cube); //} /// <summary> /// 审核退料转发记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Audit(int id) { TZRalation entity = this.Get(id); if (entity != null) { if (entity.IsCompleted && !entity.IsAudit) { entity.IsAudit = true; entity.Auditor = AuthorizationService.CurrentUserID; entity.AuditTime = DateTime.Now; ShippingDocument sourceDoc = entity.SourceShippingDocument; ////分装审核处理,肖敏,2013-09-15 //IList<TZRalation> tzList = this.Query().Where(p => p.SourceShipDocID == entity.SourceShipDocID).ToList(); ////分装 //if (tzList.Count > 1) //{ // //剩料时,原运输单的转料方量累加 // //签收方量不变 // if (entity.ReturnType == ReturnType.ShengLiao && entity.ActionType == ActionType.Transfer) // { // decimal tc = 0; // foreach (var tz in tzList) // { // if (tz.IsAudit && tz.IsCompleted) // { // tc += tz.Cube; // } // } // sourceDoc.TransferCube = tc; // } // //退料时,转料方量=剩料方量累加 // //原运输单的签收方量=出票方量-退料方量 // if (entity.ReturnType == ReturnType.TuiLiao && entity.ActionType == ActionType.Transfer) // { // decimal tc = 0; // foreach (var tz in tzList) // { // if (tz.IsAudit && tz.IsCompleted) // { // tc += tz.Cube; // } // } // sourceDoc.TransferCube = tc; // sourceDoc.SignInCube = sourceDoc.ParCube - tc; // } //} //else //{ // //xjm修改 // //2013-04-08 // //剩料时,原运输单的转料方量=剩料方量 // //签收方量不变 // if (entity.ReturnType == ReturnType.ShengLiao && entity.ActionType == ActionType.Transfer) // { // sourceDoc.TransferCube = entity.Cube; // } // //退料时,原运输单的签收方量=出票方量-退料方量 // //转料方量=剩料方量 // if (entity.ReturnType == ReturnType.TuiLiao && entity.ActionType == ActionType.Transfer) // { // //sourceDoc.SignInCube -= entity.Cube; // sourceDoc.SignInCube = sourceDoc.ParCube - entity.Cube; // sourceDoc.TransferCube = entity.Cube; // } //} ////报废,原运输单报废方量设置 ////签收方量=出票方量-报废方量 //if (entity.ReturnType == ReturnType.TuiLiao && entity.ActionType == ActionType.Reject) //{ // sourceDoc.ScrapCube = entity.Cube; // sourceDoc.SignInCube = sourceDoc.ParCube - entity.Cube; //} ////整车转发,原运输单的转料方量=运输方量 ////签收方量=0 //if (entity.ReturnType == ReturnType.Forward) //{ // sourceDoc.TransferCube = sourceDoc.ShippingCube; // sourceDoc.SendCube = 0; // sourceDoc.SignInCube = 0; // sourceDoc.ParCube = 0; //} //剩料时,转料方量=剩料方量累加 //签收方量不变 if (entity.ReturnType == ReturnType.ShengLiao && entity.ActionType == ActionType.Transfer) { sourceDoc.TransferCube += entity.ActionCube; } //退料时,转料方量=退料方量累加 //签收方量=出票方量-退料方量 if (entity.ReturnType == ReturnType.TuiLiao && entity.ActionType == ActionType.Transfer) { sourceDoc.TransferCube += entity.ActionCube; //sourceDoc.SignInCube = sourceDoc.ParCube - (sourceDoc.ParCube - sourceDoc.SignInCube) - entity.ActionCube; sourceDoc.SignInCube = sourceDoc.SignInCube - entity.ActionCube; } //报废,报废方量=剩退方量累加 //签收方量=出票方量-报废方量 if (entity.ReturnType == ReturnType.TuiLiao && entity.ActionType == ActionType.Reject) { sourceDoc.ScrapCube += entity.ActionCube; //sourceDoc.SignInCube = sourceDoc.ParCube - (sourceDoc.ParCube - sourceDoc.SignInCube) - entity.ActionCube; sourceDoc.SignInCube = sourceDoc.SignInCube - entity.ActionCube; } //整车转发,原运输单的转料方量=运输方量 //签收方量=0 if (entity.ReturnType == ReturnType.Forward) { sourceDoc.TransferCube = sourceDoc.ShippingCube; sourceDoc.SendCube = 0; sourceDoc.SignInCube = 0; sourceDoc.ParCube = 0; } using (IGenericTransaction trans = this.m_UnitOfWork.BeginTransaction()) { try { this.Update(entity, null); this.m_UnitOfWork.GetRepositoryBase <ShippingDocument>().Update(sourceDoc, null); this.m_UnitOfWork.Flush(); trans.Commit(); return(true); } catch { trans.Rollback(); } } } } return(false); }