| | |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public ErpModel CreateAsn(AsnInfo model) |
| | | public ErpModel CreateAsn(SendAsnVm model,string userName) |
| | | { |
| | | try |
| | | { |
| | | var resultModel = new ErpModel() { Success = -1, Message = "" }; |
| | | if (string.IsNullOrEmpty(model.AsnType)) |
| | | if (string.IsNullOrEmpty(model.billType.ToString())) |
| | | { |
| | | resultModel.Message = "单据类型不可为空!"; |
| | | return resultModel; |
| | | } |
| | | if (string.IsNullOrEmpty(model.Customer)) |
| | | { |
| | | resultModel.Message = "客户不可为空!"; |
| | | return resultModel; |
| | | } |
| | | if (string.IsNullOrEmpty(model.OrderCode)) |
| | | |
| | | if (string.IsNullOrEmpty(model.orderNo.ToString())) |
| | | { |
| | | resultModel.Message = "上游系统单号不可为空!"; |
| | | return resultModel; |
| | | } |
| | | if (model.AsnDetails.Count <= 0) |
| | | if (model.orderDCmdList.Count <= 0) |
| | | { |
| | | resultModel.Message = "入库单明细不可为空!"; |
| | | return resultModel; |
| | | } |
| | | |
| | | // 根据客户编号获取客户名称 |
| | | var CustomerModel = Db.Queryable<SysCustomer>().First(it => it.CustomerNo == model.Customer && it.IsDel == "0"); |
| | | if (CustomerModel == null) |
| | | { |
| | | resultModel.Message = "客户编号不存在!"; |
| | | return resultModel; |
| | | } |
| | | |
| | | // 入库总表信息 |
| | | string asnNo = new Common().GetMaxNo("ASN"); |
| | | var asnModel = new BllArrivalNotice() |
| | | { |
| | | ASNNo = asnNo, |
| | | Status = "0",//等待执行 |
| | | Type = model.AsnType, |
| | | Origin = string.IsNullOrEmpty(model.Origin) ? "ERP" : model.Origin, |
| | | CustomerNo = model.Customer, |
| | | CustomerName = CustomerModel.CustomerName, |
| | | OrderCode = model.OrderCode, |
| | | UserName = model.Username |
| | | Type = model.billType.ToString(), |
| | | Origin = "SAP", |
| | | CustomerNo = model.vendorNo, |
| | | CustomerName = model.vendorName, |
| | | OrderCode = model.orderNo.ToString(), |
| | | UserName = userName |
| | | }; |
| | | |
| | | // 入库明细表信息 |
| | | List<BllArrivalNoticeDetail> detailModels = new List<BllArrivalNoticeDetail>(); |
| | | foreach (AsnDetail asnDetailModel in model.AsnDetails) |
| | | foreach (var asnDetailModel in model.orderDCmdList) |
| | | { |
| | | if (string.IsNullOrEmpty(asnDetailModel.SkuNo)) |
| | | if (string.IsNullOrEmpty(asnDetailModel.skuNo.ToString())) |
| | | { |
| | | resultModel.Message = "物料编码不可为空!"; |
| | | return resultModel; |
| | | } |
| | | |
| | | if (asnDetailModel.Qty <= 0) |
| | | if (Convert.ToDecimal(asnDetailModel.expectedQty) <= 0) |
| | | { |
| | | resultModel.Message = "数量应为正整数!"; |
| | | resultModel.Message = "应收物料数量应大于0!"; |
| | | return resultModel; |
| | | } |
| | | if (string.IsNullOrEmpty(asnDetailModel.LotNo)) |
| | | if (string.IsNullOrEmpty(asnDetailModel.lotNo.ToString())) |
| | | { |
| | | resultModel.Message = "批次号不可为空!"; |
| | | return resultModel; |
| | | } |
| | | |
| | | // 获取物料详细信息 |
| | | var skuModel = Db.Queryable<SysMaterials>().First(it => it.SkuNo == asnDetailModel.SkuNo && it.IsDel == "0"); |
| | | var skuModel = Db.Queryable<SysMaterials>().First(it => it.SkuNo == asnDetailModel.skuNo.ToString() && it.IsDel == "0"); |
| | | if (skuModel == null) |
| | | { |
| | | resultModel.Message = "不存在当前物料信息!"; |
| | |
| | | var detailModel = new BllArrivalNoticeDetail() |
| | | { |
| | | ASNNo = asnNo, |
| | | SkuNo = asnDetailModel.SkuNo, |
| | | SkuNo = asnDetailModel.skuNo.ToString(), |
| | | SkuName = skuModel.SkuName, |
| | | Standard = skuModel.Standard, |
| | | LotNo = asnDetailModel.LotNo, |
| | | LotNo = asnDetailModel.lotNo.ToString(), |
| | | LotText = "", |
| | | Qty = (decimal)asnDetailModel.Qty, |
| | | FactQty=0, |
| | | CompleteQty=0, |
| | | Qty = Convert.ToDecimal(asnDetailModel.expectedQty), |
| | | FactQty = 0, |
| | | CompleteQty = 0, |
| | | PackagNo = skuModel.PackagNo, |
| | | SupplierLot = asnDetailModel.SupplierLot, |
| | | SupplierLot = asnDetailModel.supplyBatch,//生产日期 |
| | | Lot1 = asnDetailModel.productionDate,//过期日期 |
| | | Lot2 = asnDetailModel.expireDate, |
| | | Status = "0", |
| | | IsSampling = "0", |
| | | InspectStatus = "0", |