New file |
| | |
| | | using Model.InterFaceModel; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using WMS.DAL; |
| | | using WMS.Entity.BllAsnEntity; |
| | | using WMS.Entity.Context; |
| | | using WMS.IBLL.IBllTransServer; |
| | | |
| | | namespace WMS.BLL.BllTransServer |
| | | { |
| | | public class NoticeServer : DbHelper<BllArrivalNotice>, INoticeServer |
| | | { |
| | | private static readonly SqlSugarScope Db = DataContext.Db; |
| | | public NoticeServer() : base(Db) |
| | | { |
| | | } |
| | | |
| | | public ErpModel CreateAsn(AsnInfo model) |
| | | { |
| | | try |
| | | { |
| | | var resultModel = new ErpModel() { Success = -1, Message = "" }; |
| | | if (string.IsNullOrEmpty(model.OrderCode)) |
| | | { |
| | | resultModel.Message = "上游系统单号不可为空!"; |
| | | return resultModel; |
| | | } |
| | | if (model.AsnDetails.Count <= 0) |
| | | { |
| | | resultModel.Message = "入库单明细不可为空!"; |
| | | return resultModel; |
| | | } |
| | | |
| | | // 入库总表信息 |
| | | string asnNo = new Common().GetMaxNo("ASN"); |
| | | var asnModel = new BllArrivalNotice() |
| | | { |
| | | ASNNo = asnNo, |
| | | Status = "0",//等待执行 |
| | | Type = "0",//原料入库 |
| | | Origin = string.IsNullOrEmpty(model.Origin) ? "MES" : model.Origin, |
| | | CustomerNo = model.Customer, |
| | | CustomerName = "", |
| | | OrderCode = model.OrderCode, |
| | | }; |
| | | |
| | | // 入库明细表信息 |
| | | List<BllArrivalNoticeDetail> detailModels = new List<BllArrivalNoticeDetail>(); |
| | | foreach (AsnDetail asnDetailModel in model.AsnDetails) |
| | | { |
| | | if (string.IsNullOrEmpty(asnDetailModel.SkuNo)) |
| | | { |
| | | resultModel.Message = "物料编码不可为空!"; |
| | | return resultModel; |
| | | } |
| | | if (string.IsNullOrEmpty(asnDetailModel.SkuName)) |
| | | { |
| | | resultModel.Message = "物料名称不可为空!"; |
| | | return resultModel; |
| | | } |
| | | if (asnDetailModel.Qty <= 0) |
| | | { |
| | | resultModel.Message = "数量应大于0!"; |
| | | return resultModel; |
| | | } |
| | | if (string.IsNullOrEmpty(asnDetailModel.LotNo)) |
| | | { |
| | | resultModel.Message = "批次号不可为空!"; |
| | | return resultModel; |
| | | } |
| | | var detailModel = new BllArrivalNoticeDetail() |
| | | { |
| | | ASNNo = asnNo, |
| | | OrderDetailCode = asnDetailModel.OrderDetailCode, |
| | | SkuNo = asnDetailModel.SkuNo, |
| | | SkuName = asnDetailModel.SkuName, |
| | | LotNo = asnDetailModel.LotNo, |
| | | LotText = "", |
| | | Qty = (decimal)asnDetailModel.Qty, |
| | | FactQty = 0, |
| | | CompleteQty = 0, |
| | | SupplierLot = asnDetailModel.SupplierLot, |
| | | Status = "0", |
| | | IsSampling = "0", |
| | | InspectStatus = "0", |
| | | CreateUser = 0 |
| | | }; |
| | | detailModels.Add(detailModel); |
| | | } |
| | | |
| | | Db.BeginTran(); |
| | | // 插入入库单总表 |
| | | Db.Insertable(asnModel).ExecuteCommand(); |
| | | |
| | | // 插入入库单明细表 |
| | | Db.Insertable(detailModels).ExecuteCommand(); |
| | | Db.CommitTran(); |
| | | |
| | | resultModel.Success = 0; |
| | | resultModel.Message = "成功"; |
| | | return resultModel; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.RollbackTran(); |
| | | throw ex; |
| | | } |
| | | } |
| | | } |
| | | } |