/// <summary> /// VmiPullOrderDetailInfo -> VmiShippingPartInfo /// </summary> /// <param name="vmiPullOrderDetailInfo"></param> /// <param name="vmiShippingPartInfo"></param> public static void GetVmiShippingPartInfo(VmiPullOrderDetailInfo vmiPullOrderDetailInfo, ref VmiShippingPartInfo info) { if (vmiPullOrderDetailInfo == null) { return; } ///FID, info.Fid = vmiPullOrderDetailInfo.Fid; ///ORDER_FID,拉动单外键 info.OrderFid = vmiPullOrderDetailInfo.OrderFid; ///ORDER_CODE,拉动单号 info.OrderCode = vmiPullOrderDetailInfo.OrderCode; ///ROW_NO,行号 info.RowNo = vmiPullOrderDetailInfo.RowNo; ///SUPPLIER_NUM,供应商代码 info.SupplierNum = vmiPullOrderDetailInfo.SupplierNum; ///WORKSHOP_SECTION,工段 info.WorkshopSection = vmiPullOrderDetailInfo.WorkshopSection; ///LOCATION,工位 info.Location = vmiPullOrderDetailInfo.Location; ///PART_NO,物料号 info.PartNo = vmiPullOrderDetailInfo.PartNo; ///PART_VERSION,物料版本 info.PartVersion = vmiPullOrderDetailInfo.PartVersion; ///PART_CNAME,物料中文描述 info.PartCname = vmiPullOrderDetailInfo.PartCname; ///PART_ENAME,物料英文描述 info.PartEname = vmiPullOrderDetailInfo.PartEname; ///MEASURING_UNIT_NO,单位 info.MeasuringUnitNo = vmiPullOrderDetailInfo.MeasuringUnitNo; ///PACKAGE,单包装数量 info.Package = vmiPullOrderDetailInfo.Package; ///PACKAGE_MODEL,包装编号 info.PackageModel = vmiPullOrderDetailInfo.PackageModel; ///REQUIRED_PACKAGE_QTY,需求包装数 info.RequiredPackageQty = vmiPullOrderDetailInfo.RequiredPackageQty; ///REQUIRED_PART_QTY,需求物料数量 info.RequiredPartQty = vmiPullOrderDetailInfo.RequiredPartQty; ///COMMENTS,备注 info.Comments = vmiPullOrderDetailInfo.Comments; }
/// <summary> /// 预发货 /// </summary> /// <param name="rowsKeyValues"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool AsnInfos(List <string> rowsKeyValues, string loginUser) { List <VmiPullOrderDetailInfo> vmiPullOrderDetailInfos = new List <VmiPullOrderDetailInfo>(); foreach (var rowsKeyValue in rowsKeyValues) { string[] keyValues = rowsKeyValue.Split(new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries); if (keyValues.Length == 0) { throw new Exception("MC:0x00000084");///数据错误 } if (keyValues.Length == 1) { throw new Exception("MC:0x00000496");///预发货数量不能为空 } VmiPullOrderDetailInfo vmiPullOrderDetailInfo = new VmiPullOrderDetailInfo(); vmiPullOrderDetailInfo.Id = Convert.ToInt64(keyValues[0]); vmiPullOrderDetailInfo.AsnQty = Convert.ToDecimal(keyValues[1]); vmiPullOrderDetailInfos.Add(vmiPullOrderDetailInfo); } VmiShippingPartBLL.AddCartVmiShippingPartInfo(vmiPullOrderDetailInfos, loginUser); return(true); }
/// <summary> /// 加入VMI物料购物车 /// </summary> /// <returns></returns> public static void AddCartVmiShippingPartInfo(List <VmiPullOrderDetailInfo> vmiPullOrderDetailInfos, string loginUser) { if (vmiPullOrderDetailInfos.Count == 0) { throw new Exception("MC:3x00000027");///传入参数异常 } ///现有数据库中的VMI拉动单明细 List <VmiPullOrderDetailInfo> vmiPullOrderDetails = new VmiPullOrderDetailDAL().GetList("" + "[ID] in (" + string.Join(",", vmiPullOrderDetailInfos.Select(w => w.Id).ToArray()) + ")", string.Empty); if (vmiPullOrderDetails.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } List <VmiPullOrderInfo> vmiPullOrderInfos = new VmiPullOrderDAL().GetList("" + "[FID] in ('" + string.Join("','", vmiPullOrderDetails.Select(d => d.OrderFid.GetValueOrDefault()).ToArray()) + "')", string.Empty); if (vmiPullOrderInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } ///当前登录用户的预发货集合 List <VmiShippingPartInfo> vmiShippingPartInfos = new VmiShippingPartDAL().GetList("[CREATE_USER] = N'" + loginUser + "'", string.Empty); StringBuilder @string = new StringBuilder(); foreach (var vmiPullOrderDetail in vmiPullOrderDetails) { ///本次预发货数量 VmiPullOrderDetailInfo orderDetailInfo = vmiPullOrderDetailInfos.FirstOrDefault(d => d.Id == vmiPullOrderDetail.Id); if (orderDetailInfo == null) { throw new Exception("MC:0x00000084");///数据错误 } VmiPullOrderInfo vmiPullOrderInfo = vmiPullOrderInfos.FirstOrDefault(d => d.Fid.GetValueOrDefault() == vmiPullOrderDetail.OrderFid.GetValueOrDefault()); if (vmiPullOrderInfo == null) { throw new Exception("MC:0x00000084");///数据错误 } if (vmiPullOrderDetail.RequiredPartQty.GetValueOrDefault() - vmiPullOrderDetail.AsnDraftQty.GetValueOrDefault() - vmiPullOrderDetail.AsnConfirmQty.GetValueOrDefault() - orderDetailInfo.AsnQty < 0) { throw new Exception("MC:0x00000497");///需求数量扣除草稿数量以及确认数量后不够本次预发货数量 } ///更新VMI拉动单草稿数量 @string.AppendLine("update [LES].[TT_MPM_VMI_PULL_ORDER_DETAIL] " + "set [ASN_DRAFT_QTY] = isnull([ASN_DRAFT_QTY],0) + " + orderDetailInfo.AsnQty + ",[MODIFY_DATE] = GETDATE(),[MODIFY_USER] = N'" + loginUser + "' " + "where [ID] = " + orderDetailInfo.Id + ";"); ///预发货集合中是否已存在拉动单明细,存在则累加数量 VmiShippingPartInfo vmiShippingPartInfo = vmiShippingPartInfos.FirstOrDefault(d => d.Fid.GetValueOrDefault() == vmiPullOrderDetail.Fid.GetValueOrDefault()); if (vmiShippingPartInfo == null) { /// vmiShippingPartInfo = CreateVmiShippingPartInfo(loginUser); GetVmiShippingPartInfo(vmiPullOrderDetail, ref vmiShippingPartInfo); GetVmiShippingPartInfo(vmiPullOrderInfo, ref vmiShippingPartInfo); ///ASN_DRAFT_QTY,ASN草稿物料数量 vmiShippingPartInfo.AsnDraftQty = orderDetailInfo.AsnQty; @string.AppendLine(VmiShippingPartDAL.GetInsertSql(vmiShippingPartInfo)); } else { @string.AppendLine("update [LES].[TE_MPM_VMI_SHIPPING_PART] " + "set [ASN_DRAFT_QTY] = isnull([ASN_DRAFT_QTY],0) + " + orderDetailInfo.AsnQty + ",[MODIFY_DATE] = GETDATE(),[MODIFY_USER] = N'" + loginUser + "' " + "where [ID] = " + vmiShippingPartInfo.Id + ";"); } } ///执行 using (TransactionScope trans = new TransactionScope()) { if (@string.Length > 0) { CommonDAL.ExecuteNonQueryBySql(@string.ToString()); } trans.Complete(); } }
public long InsertInfo(VmiPullOrderDetailInfo info) { return(dal.Add(info)); }