public ActionResult AutoOrder(string productName) { string orderNum = WebUtil.GetFormValue <string>("orderNum", string.Empty); PageInfo page = new PageInfo { PageIndex = 1, PageSize = 5 }; Bill <OrdersEntity, OrderDetailEntity> bill = new OrderBill(); OrdersEntity entity = new OrdersEntity(); if (orderNum != string.Empty) { entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%"); } entity.Where(a => a.AuditeStatus == (int)EAudite.Pass).And(a => a.Status != (int)EOrderStatus.AllDelivery); List <OrdersEntity> list = bill.GetList(entity, ref page); list = list.IsNull() ? new List <OrdersEntity>() : list; StringBuilder sb = new StringBuilder(); JsonObject jsonObject = null; foreach (OrdersEntity t in list) { jsonObject = new JsonObject(); jsonObject.AddProperty("OrderNum", t.OrderNum); jsonObject.AddProperty("CusName", t.CusName); sb.Append(jsonObject.ToString() + "\n"); } if (sb.Length == 0) { sb.Append("\n"); } return(Content(sb.ToString())); }
/// <summary> /// 根据订单号查询所有订单相关联的的排产单号 /// </summary> /// <param name="orderNum"></param> /// <returns></returns> public List <string> GetOrderPlan(string orderNum) { OrdersEntity entity = new OrdersEntity(); entity.Include(a => new { a.OrderNum, a.ContractOrder }); entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%"); List <OrdersEntity> list = this.Orders.GetList(entity); if (!list.IsNullOrEmpty()) { List <string> items = list.Select(a => a.ContractOrder).ToList(); return(items); } return(null); }
/// <summary> /// 审核单据 /// </summary> /// <param name="entity"></param> /// <returns></returns> public override string Audite(OutStorageEntity entity) { if (entity.Status == (int)EAudite.NotPass) { entity.IncludeStatus(true).IncludeReason(true).Where(a => a.OrderNum == entity.OrderNum); int line = this.OutStorage.Update(entity); return(line > 0 ? "1000" : string.Empty); } else if (entity.Status == (int)EAudite.Pass) { Proc_AuditeOutStorageEntity auditeEntity = new Proc_AuditeOutStorageEntity(); auditeEntity.OrderNum = entity.OrderNum; auditeEntity.Status = entity.Status; auditeEntity.AuditUser = entity.AuditUser; auditeEntity.Reason = entity.Reason; auditeEntity.OperateType = entity.OperateType; auditeEntity.EquipmentNum = entity.EquipmentNum; auditeEntity.EquipmentCode = entity.EquipmentCode; auditeEntity.Remark = entity.Remark; int line = this.Proc_AuditeOutStorage.ExecuteNonQuery(auditeEntity); /*** * 如果是销售订单则需要更改订单中的发货数量以及相应的状态 * 1. 查询出库单,判断出库单的类型 * 2. 查询出库单所有的内容详细,判断存在哪些订单 * 3. 统计相应的订单的出库总数量 * 4. 修改订单状态 * */ OutStorageEntity outEntity = new OutStorageEntity(); outEntity.IncludeAll(); outEntity.Where(a => a.OrderNum == entity.OrderNum); outEntity = this.OutStorage.GetSingle(outEntity); OutStoDetailEntity detail = new OutStoDetailEntity(); detail.Where(a => a.OrderNum == entity.OrderNum); detail.IncludeAll(); List <OutStoDetailEntity> listDetail = this.OutStoDetail.GetList(detail); if (outEntity != null && !listDetail.IsNullOrEmpty()) { if (outEntity.OutType == (int)EOutType.Sell) { OutStorageProvider outProvider = new OutStorageProvider(); foreach (var item in listDetail.Where(a => !a.ContractOrder.IsEmpty() && !a.ContractSn.IsEmpty()).GroupBy(a => new { a.ContractOrder, a.ContractSn })) { OutStoDetailEntity tempOutDetail = new OutStoDetailEntity(); tempOutDetail.Where(a => a.ContractOrder == item.Key.ContractOrder).And(a => a.ContractSn == item.Key.ContractSn); List <OutStoDetailEntity> list = outProvider.GetOrderDetail(tempOutDetail); double value = list.Sum(a => a.Num); OrderDetailEntity orderDetail = new OrderDetailEntity(); orderDetail.RealNum = value; orderDetail.IncludeRealNum(true); orderDetail.Where(a => a.SnNum == item.Key.ContractSn).And(a => a.OrderNum == item.Key.ContractOrder); this.OrderDetail.Update(orderDetail); orderDetail = new OrderDetailEntity(); orderDetail.IncludeAll(); orderDetail.And(a => a.OrderNum == item.Key.ContractOrder); List <OrderDetailEntity> listOrderDetail = this.OrderDetail.GetList(orderDetail); bool flag = true; foreach (OrderDetailEntity detailItem in listOrderDetail) { if (detailItem.RealNum < detailItem.Num) { flag = false; } } OrdersEntity order = new OrdersEntity(); if (flag) { order.Status = (int)EOrderStatus.AllDelivery; } else { order.Status = (int)EOrderStatus.PartialDelivery; } order.IncludeStatus(true); order.Where(a => a.OrderNum == item.Key.ContractOrder); this.Orders.Update(order); } } } return(auditeEntity.ReturnValue); } return(string.Empty); }