/// <summary> /// 保存一条非系统协同车辆信息 /// </summary> /// <param name="goods"></param> /// <returns></returns> public IHttpActionResult SaveUnJointTruckList(Container truck) { JsonObject json = new JsonObject(); Console.WriteLine("SaveUnJointTruckList:" + DateTime.Now.ToString()); List <UnJointTruck> newUnJointTruck = new List <UnJointTruck>(); StringBuilder msg = new StringBuilder(); List <UnJointTruck> _newUnJointTruck = new List <UnJointTruck>(); foreach (var unJointTruck in truck.Trucks) { if (unJointTruck.VehicleType == "19") { if (!CheckContainerisExist(unJointTruck.OrderNO, unJointTruck.StorageNO)) { newUnJointTruck.Add(unJointTruck); } else { msg.Append(string.Format("{0} - {1} already exist, that can not add!", unJointTruck.OrderNO, unJointTruck.StorageNO)); } } } foreach (var unjoin in newUnJointTruck) { try { var _UnJointTruck = string.IsNullOrEmpty(unjoin.VoucherID) ? null : _GateContext.UnJointTrucks.Find(unjoin.VoucherID); if (_UnJointTruck != null) { unjoin.Stamp = DateTime.Now; RemoveHoldingEntityInContext(unjoin); _GateContext.Entry(unjoin).State = EntityState.Modified; } else { if (string.IsNullOrEmpty(unjoin.Status)) { unjoin.Status = "N"; } string vouIdNew = GetUnjointTruckVoucherIDFlow(); unjoin.VoucherID = vouIdNew; unjoin.Stamp = DateTime.Now; _GateContext.UnJointTrucks.Add(unjoin); } _GateContext.SaveChanges(); _newUnJointTruck.Add(unjoin); } catch (Exception ex) { msg.Append(ex.Message); } } // } json["Error"] = msg.ToString(); json["Data"] = _newUnJointTruck; return(Ok(json)); }
/// <summary> /// 保存物品出厂信息 /// </summary> /// <param name="goods"></param> /// <returns></returns> public IHttpActionResult SaveGoodsInfo(Goods goods) { try { Console.WriteLine("SaveGoodsInfo:" + DateTime.Now.ToString()); string voucherId = string.IsNullOrEmpty(goods.VoucherID) ? "" : goods.VoucherID; var _Goods = _GateContext.Goodss.Find(voucherId); string result = string.Empty; if (_Goods != null) { //移除原Item项次 while (_Goods.GoodsItems.Count > 0) { _GateContext.GoodsItems.Remove(_Goods.GoodsItems[0]); } //新增Item项次 foreach (GoodsItem item in goods.GoodsItems) { item.ID = Guid.NewGuid(); item.VoucherID = goods.VoucherID; _GateContext.GoodsItems.Add(item); } goods.Stamp = DateTime.Now; // RemoveHoldingEntityInContext(goods); // _GateContext.Entry(goods).State = EntityState.Modified; } else { if (string.IsNullOrEmpty(goods.Status)) { goods.Status = ""; } string vouIdNew = GetGoodsVoucherIDFlow(); foreach (GoodsItem item in goods.GoodsItems) { item.ID = Guid.NewGuid(); item.VoucherID = vouIdNew; _GateContext.GoodsItems.Add(item); } goods.VoucherID = vouIdNew; goods.Stamp = DateTime.Now; _GateContext.Goodss.Add(goods); } _GateContext.SaveChanges(); return(Ok(goods)); } catch (Exception e) { Console.WriteLine(e); Loger.Error(e); return(BadRequest(e.Message + e.StackTrace)); } }
/// <summary> /// 保存一条PTA\EG车辆信息 /// </summary> /// <param name="goods"></param> /// <returns></returns> public IHttpActionResult SavePtaEgTruck(PtaEgTruck ptaEgTruck) { try { Console.WriteLine("SavePtaEgTruck:" + DateTime.Now.ToString()); string voucherId = string.IsNullOrEmpty(ptaEgTruck.VoucherID) ? "" : ptaEgTruck.VoucherID; var _PtaEgTruck = _GateContext.PtaEgTrucks.Find(voucherId); string result = string.Empty; if (_PtaEgTruck != null) { ptaEgTruck.Stamp = DateTime.Now; // RemoveHoldingEntityInContext(ptaEgTruck); // _GateContext.Entry(ptaEgTruck).State = EntityState.Modified; } else { if (string.IsNullOrEmpty(ptaEgTruck.Status)) { ptaEgTruck.Status = ""; } string vouIdNew = GetPtaEgTruckVoucherIDFlow(); ptaEgTruck.VoucherID = vouIdNew; ptaEgTruck.Stamp = DateTime.Now; _GateContext.PtaEgTrucks.Add(ptaEgTruck); } _GateContext.SaveChanges(); return(Ok(ptaEgTruck)); } catch (Exception e) { Loger.Error(e); Console.WriteLine(e); return(BadRequest(e.Message + e.StackTrace)); } }
/// <summary> /// 保存黑名单信息 /// </summary> /// <param name="goods"></param> /// <returns></returns> public IHttpActionResult SaveBlackList(BL_Request bl_Request) { try { Console.WriteLine("SaveBlackList:" + DateTime.Now.ToString()); string voucherId = string.IsNullOrEmpty(bl_Request.VoucherID) ? "" : bl_Request.VoucherID; var _BL_Request = _GateContext.BL_Requests.Find(voucherId); string result = string.Empty; if (_BL_Request != null) { bl_Request.Stamp = DateTime.Now; // _GateContext.Entry(bl_Request).State = EntityState.Modified; } else { if (string.IsNullOrEmpty(bl_Request.Status)) { bl_Request.Status = ""; } string vouIdNew = GetBlackListVoucherIDFlow(); bl_Request.VoucherID = vouIdNew; bl_Request.Stamp = DateTime.Now; _GateContext.BL_Requests.Add(bl_Request); } _GateContext.SaveChanges(); return(Ok(bl_Request)); } catch (Exception e) { Loger.Error(e); Console.WriteLine(e); return(BadRequest(e.Message + e.StackTrace)); } }