/// <summary> /// 获取层级拉动需求累计语句 /// </summary> /// <param name="maintainInhouseLogisticStandardInfo"></param> /// <param name="requireQty"></param> /// <param name="loginUser"></param> /// <param name="counterFid"></param> /// <param name="partBoxCode"></param> /// <returns></returns> public static string LevelPullRequirementCounter(MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandardInfo, decimal requireQty, string loginUser, Guid counterFid, string partBoxCode) { ///当物料拉动信息中的是否层级拉动标记 =False或未设置时函数直接返回空 if (!maintainInhouseLogisticStandardInfo.IsTriggerPull.GetValueOrDefault()) { return(string.Empty); } ///根据物料拉动信息中的层级拉动仓库存储区以及物料号、供应商获取物料拉动信息表中目标仓库存储区对应的物料号、供应商数据 List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandardInfos = new MaintainInhouseLogisticStandardDAL().GetList("" + "[T_WM_NO] = N'" + maintainInhouseLogisticStandardInfo.WmNo + "' and " + "[T_ZONE_NO] = N'" + maintainInhouseLogisticStandardInfo.ZoneNo + "' and " + "[PART_NO] = N'" + maintainInhouseLogisticStandardInfo.PartNo + "' and " + "[STATUS] = " + (int)BasicDataStatusConstants.Enable + " and " + "[INHOUSE_SYSTEM_MODE] = N'" + (int)PullModeConstants.Twd + "'", string.Empty); ///若获取不成功则将供应商条件去除重新获取,此处在程序执行时可以先根据物料号获取,再过滤供应商 MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandard = maintainInhouseLogisticStandardInfos.FirstOrDefault(d => d.SupplierNum == maintainInhouseLogisticStandardInfo.SupplierNum); if (maintainInhouseLogisticStandard == null) { maintainInhouseLogisticStandardInfo = maintainInhouseLogisticStandardInfos.FirstOrDefault(); } ///未能成功获取物料拉动信息 if (maintainInhouseLogisticStandard == null) { return(string.Empty); } ///获取零件类信息 TwdPartBoxInfo twdPartBoxInfo = new TwdPartBoxDAL().GetInfo(maintainInhouseLogisticStandard.InhousePartClass); ///未能成功获取零件类信息 if (twdPartBoxInfo == null) { return(string.Empty); } ///零件类未启用 if (twdPartBoxInfo.Status.GetValueOrDefault() != (int)BasicDataStatusConstants.Enable) { return(string.Empty); } ///根据物料拉动信息外键获取计数器,未能成功获取时需要创建 TwdCounterInfo twdCounterInfo = new TwdCounterDAL().GetInfoByPartPullFid(maintainInhouseLogisticStandard.Fid.GetValueOrDefault()); if (twdCounterInfo == null) { ///创建计数器 twdCounterInfo = CreateTwdCounterInfo(loginUser); ///以物料拉动信息填充计数器 GetTwdCounterInfo(maintainInhouseLogisticStandard, ref twdCounterInfo); ///以零件类信息填充计数器 GetTwdCounterInfo(twdPartBoxInfo, ref twdCounterInfo); /// twdCounterInfo.Id = new TwdCounterDAL().Add(twdCounterInfo); if (twdCounterInfo.Id == 0) { throw new Exception("MC:0x00000453");///时间窗计数器创建失败 } } ///计数器状态未处于启用 if (twdCounterInfo.Status != (int)BasicDataStatusConstants.Enable) { return(string.Empty); } /// StringBuilder stringBuilder = new StringBuilder(); /// stringBuilder.AppendLine(UpdateTwdCounter(maintainInhouseLogisticStandard, twdPartBoxInfo, requireQty, twdCounterInfo.Id, loginUser)); ///创建计数器日志 TwdCounterLogInfo twdCounterLogInfo = TwdCounterLogBLL.CreateTwdCounterLogInfo(twdCounterInfo.Fid.GetValueOrDefault(), loginUser); ///以物料拉动信息填充计数器日志 TwdCounterLogBLL.GetTwdCounterLogInfo(maintainInhouseLogisticStandard, ref twdCounterLogInfo); ///以零件类信息填充计数器日志 TwdCounterLogBLL.GetTwdCounterLogInfo(twdPartBoxInfo, ref twdCounterLogInfo); ///PART_QTY twdCounterLogInfo.PartQty = requireQty; ///SOURCE_DATA_FID twdCounterLogInfo.SourceDataFid = counterFid; ///SOURCE_DATA_TYPE twdCounterLogInfo.SourceDataType = (int)TwdCounterSourceDataTypeConstants.Calculator; ///SOURCE_DATA twdCounterLogInfo.SourceData = partBoxCode; /// stringBuilder.AppendLine(TwdCounterLogDAL.GetInsertSql(twdCounterLogInfo)); ///触发层级拉动 stringBuilder.AppendLine(LevelPullRequirementCounter( maintainInhouseLogisticStandard, requireQty, loginUser, twdCounterInfo.Fid.GetValueOrDefault(), twdCounterInfo.PartBoxCode)); return(stringBuilder.ToString()); }
/// <summary> /// 层级拉动 /// </summary> /// <param name="maintainInhouseLogisticStandardInfo"></param> /// <param name="requireQty"></param> /// <param name="loginUser"></param> /// <param name="counterFid"></param> /// <param name="partBoxCode"></param> /// <returns></returns> public static string LevelPullCounter(MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandardInfo, decimal requireQty, string loginUser, Guid counterFid, TwdPartBoxInfo twdPartBoxInfo) { ///未能成功获取零件类信息 if (twdPartBoxInfo == null) { return(string.Empty); } ///零件类未启用 if (twdPartBoxInfo.Status.GetValueOrDefault() != (int)BasicDataStatusConstants.Enable) { return(string.Empty); } ///根据物料拉动信息外键获取计数器,未能成功获取时需要创建 TwdCounterInfo twdCounterInfo = new TwdCounterDAL().GetInfoByPartPullFid(maintainInhouseLogisticStandardInfo.Fid.GetValueOrDefault()); if (twdCounterInfo == null) { ///创建计数器 twdCounterInfo = CreateTwdCounterInfo(loginUser); ///以物料拉动信息填充计数器 GetTwdCounterInfo(maintainInhouseLogisticStandardInfo, ref twdCounterInfo); ///以零件类信息填充计数器 GetTwdCounterInfo(twdPartBoxInfo, ref twdCounterInfo); /// twdCounterInfo.Id = new TwdCounterDAL().Add(twdCounterInfo); if (twdCounterInfo.Id == 0) { throw new Exception("MC:0x00000453");///时间窗计数器创建失败 } } ///计数器状态未处于启用 if (twdCounterInfo.Status != (int)BasicDataStatusConstants.Enable) { return(string.Empty); } /// StringBuilder stringBuilder = new StringBuilder(); /// stringBuilder.AppendLine(UpdateTwdCounter(maintainInhouseLogisticStandardInfo, twdPartBoxInfo, requireQty, twdCounterInfo.Id, loginUser)); ///创建计数器日志 TwdCounterLogInfo twdCounterLogInfo = TwdCounterLogBLL.CreateTwdCounterLogInfo(twdCounterInfo.Fid.GetValueOrDefault(), loginUser); ///以物料拉动信息填充计数器日志 TwdCounterLogBLL.GetTwdCounterLogInfo(maintainInhouseLogisticStandardInfo, ref twdCounterLogInfo); ///以零件类信息填充计数器日志 TwdCounterLogBLL.GetTwdCounterLogInfo(twdPartBoxInfo, ref twdCounterLogInfo); ///PART_QTY twdCounterLogInfo.PartQty = requireQty; ///SOURCE_DATA_FID twdCounterLogInfo.SourceDataFid = counterFid; ///SOURCE_DATA_TYPE twdCounterLogInfo.SourceDataType = (int)TwdCounterSourceDataTypeConstants.Calculator; ///SOURCE_DATA twdCounterLogInfo.SourceData = twdPartBoxInfo.PartBoxCode; /// stringBuilder.AppendLine(TwdCounterLogDAL.GetInsertSql(twdCounterLogInfo)); ///触发层级拉动 stringBuilder.AppendLine(LevelPullCounter( maintainInhouseLogisticStandardInfo, requireQty, loginUser, twdCounterInfo.Fid.GetValueOrDefault(), twdPartBoxInfo)); return(stringBuilder.ToString()); }
/// <summary> /// 提交 /// </summary> /// <param name="info"></param> /// <param name="rowsKeyValues"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool EntitySubmitInfos(TwdCounterUpdateInfo info, List <string> rowsKeyValues, string loginUser) { List <TwdCounterInfo> twdCounterInfos = new TwdCounterDAL().GetList("[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ")", string.Empty); if (twdCounterInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } string sql = string.Empty; foreach (var twdCounterInfo in twdCounterInfos) { if (twdCounterInfo.Status.GetValueOrDefault() == (int)BasicDataStatusConstants.Disabled) { throw new Exception("MC:0x00000455");///计数器已作废不能修改数量 } sql += "update [LES].[TT_MPM_TWD_COUNTER] set " + "[CURRENT_QTY] = isnull([CURRENT_QTY],0) +" + info.SubmitQty.GetValueOrDefault() + "," + "[MODIFY_DATE] = GETDATE()," + "[MODIFY_USER] = N'" + loginUser + "' where " + "[ID] = " + twdCounterInfo.Id + ";"; ///根据计数器的物料拉动信息外键获取物料拉动信息 MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandardInfo = new MaintainInhouseLogisticStandardDAL().GetInfoByFid(twdCounterInfo.PartPullFid.GetValueOrDefault()); if (maintainInhouseLogisticStandardInfo == null) { throw new Exception("MC:0x00000213");///物料拉动信息数据错误 } if (maintainInhouseLogisticStandardInfo.Status.GetValueOrDefault() != (int)BasicDataStatusConstants.Enable) { throw new Exception("MC:0x00000233");///没有已启用的物料拉动信息 } ///获取零件类信息 TwdPartBoxInfo twdPartBoxInfo = new TwdPartBoxDAL().GetInfo(maintainInhouseLogisticStandardInfo.InhousePartClass); ///未能成功获取零件类信息 if (twdPartBoxInfo == null) { throw new Exception("MC:0x00000225");///拉动零件类数据错误 } ///零件类未启用 if (twdPartBoxInfo.Status.GetValueOrDefault() != (int)BasicDataStatusConstants.Enable) { throw new Exception("MC:0x00000456");///零件类未启用 } ///创建计数器日志 TwdCounterLogInfo twdCounterLogInfo = TwdCounterLogBLL.CreateTwdCounterLogInfo(twdCounterInfo.Fid.GetValueOrDefault(), loginUser); ///以物料拉动信息填充计数器日志 TwdCounterLogBLL.GetTwdCounterLogInfo(maintainInhouseLogisticStandardInfo, ref twdCounterLogInfo); ///以零件类信息填充计数器日志 TwdCounterLogBLL.GetTwdCounterLogInfo(twdPartBoxInfo, ref twdCounterLogInfo); ///PART_QTY twdCounterLogInfo.PartQty = info.SubmitQty.GetValueOrDefault(); ///SOURCE_DATA_FID twdCounterLogInfo.SourceDataFid = twdCounterInfo.Fid; ///SOURCE_DATA_TYPE twdCounterLogInfo.SourceDataType = (int)TwdCounterSourceDataTypeConstants.Manual; ///SOURCE_DATA twdCounterLogInfo.SourceData = twdCounterInfo.PartBoxCode; ///Comments twdCounterLogInfo.Comments = info.Comments; /// sql += TwdCounterLogDAL.GetInsertSql(twdCounterLogInfo); ///触发层级拉动 sql += TwdCounterBLL.LevelPullRequirementCounter( maintainInhouseLogisticStandardInfo, info.SubmitQty.GetValueOrDefault(), loginUser, twdCounterInfo.Fid.GetValueOrDefault(), twdCounterInfo.PartBoxCode); } /// using (var trans = new TransactionScope()) { if (!string.IsNullOrEmpty(sql)) { CommonDAL.ExecuteNonQueryBySql(sql); } trans.Complete(); } /// return(true); }