/// <summary> /// VehiclePointStatusInfo -> TwdCounterLogInfo /// </summary> /// <param name="vehiclePointStatusInfo"></param> /// <param name="twdCounterLogInfo"></param> public static void GetTwdCounterLogInfo(VehiclePointStatusInfo vehiclePointStatusInfo, ref TwdCounterLogInfo twdCounterLogInfo) { if (vehiclePointStatusInfo == null) { return; } ///SOURCE_DATA_FID twdCounterLogInfo.SourceDataFid = vehiclePointStatusInfo.Fid; ///SOURCE_DATA_TYPE twdCounterLogInfo.SourceDataType = (int)TwdCounterSourceDataTypeConstants.StatePoint; ///SOURCE_DATA twdCounterLogInfo.SourceData = vehiclePointStatusInfo.OrderNo; }
/// <summary> /// 纵向维度 /// </summary> /// <param name="statusPoints"></param> /// <param name="statusPointInfo"></param> /// <param name="mesVehiclePointScanInfo"></param> /// <param name="assemblyLine"></param> /// <param name="currentSeqNo"></param> /// <returns></returns> public string LongitudinalDimension(List <StatusPointInfo> statusPoints, StatusPointInfo statusPointInfo, MesVehiclePointScanInfo mesVehiclePointScanInfo, string assemblyLine, long currentSeqNo) { ///sql StringBuilder stringBuilder = new StringBuilder(); ///以下开始为纵向维度(同状态点)的处理逻辑 ///以本次采集点编号④对应状态点代码①的状态点顺序③为基准 List <StatusPointInfo> pointInfos = statusPoints. Where(d => d.StatusPointSeq.GetValueOrDefault() > statusPointInfo.StatusPointSeq.GetValueOrDefault()). OrderBy(d => d.StatusPointSeq.GetValueOrDefault()). ToList(); List <VehiclePointStatusInfo> pointStatusInfos = new VehiclePointStatusBLL().GetList("" + "[PLANT] = N'" + statusPointInfo.Plant + "' and " + "[WORKSHOP] = N'" + statusPointInfo.Workshop + "' and " + (string.IsNullOrEmpty(assemblyLine) ? string.Empty : "[ASSEMBLY_LINE] = N'" + assemblyLine + "' and ") + "[SEQ_NO] < " + currentSeqNo + " and " + "[VEHICLE_STATUS] =" + (int)VehicleStatusTypeConstants.VehicleLeave + "", string.Empty); ///依次将状态点顺序③比参照数据大的数据 且非本次计划订单号⑥中车辆状态⑨为初始化数据的过点时间⑦、车辆状态⑨进行更新 ///直至状态点顺序③最大值,理论上当状态点顺序号③逐渐变大时更新数据的数量始终唯一,过点时间⑦按本次发送时间⑦进行更新,车辆状态⑨为正常过点 foreach (var pointInfo in pointInfos) { VehiclePointStatusInfo pointStatusInfo = pointStatusInfos. Where(d => d.StatusPointCode == pointInfo.StatusPointCode). OrderByDescending(d => d.SeqNo.GetValueOrDefault()). FirstOrDefault(); if (pointStatusInfo == null) { continue; } DateTime currentTime = mesVehiclePointScanInfo.SendTime.GetValueOrDefault(); stringBuilder.AppendLine("update [LES].[TT_BAS_VEHICLE_POINT_STATUS] " + "set [PASS_TIME] = N'" + currentTime + "',[VEHICLE_STATUS] = " + (int)VehicleStatusTypeConstants.NormalPoint + ",[MODIFY_USER]='" + loginUser + "',[MODIFY_DATE]=GETDATE()" + "where [ID] = " + pointStatusInfo.Id + ";"); } return(stringBuilder.ToString()); }
/// <summary> /// 在线替换 /// </summary> /// <param name="bomRepleaceConditionInfos"></param> /// <param name="loginUser"></param> public void OnlineReplacement(List <BomRepleaceConditionInfo> bomRepleaceConditionInfos, string loginUser) { if (bomRepleaceConditionInfos.Count == 0) { return; } ///生产订单 List <PullOrdersInfo> pullOrdersInfos = new PullOrdersDAL().GetList("" + " and [CHANGE_FLAG]=" + (int)ChangeFlagConstants.NotReplaced + "", string.Empty); if (pullOrdersInfos.Count == 0) { return; } ///车辆状态点信息集合 List <VehiclePointStatusInfo> vehiclePointStatusInfos = new VehiclePointStatusDAL().GetList("" + "and [ORDER_NO] in ('" + string.Join("','", bomRepleaceConditionInfos.Select(d => d.StartPorderCode).ToArray()) + "')", string.Empty); if (vehiclePointStatusInfos.Count == 0) { return; } ///状态点集合 List <StatusPointInfo> statusPointInfos = new StatusPointDAL().GetList("" + "[STATUS_POINT_CODE] in ('" + string.Join("','", vehiclePointStatusInfos.Select(d => d.StatusPointCode).ToArray()) + "')", string.Empty); if (statusPointInfos.Count == 0) { return; } ///时间窗(过点累计方式)零件类 List <TwdPartBoxInfo> twdPartBoxInfos = new TwdPartBoxDAL().GetList("" + " and [STATUS] =" + (int)BasicDataStatusConstants.Enable + " " + " and [REQUIREMENT_ACCUMULATE_MODE]=" + (int)RequirementAccumulateModeConstants.PassSpot + "" + " and [STATUS_POINT_CODE] in ('" + string.Join("','", statusPointInfos.Select(d => d.StatusPointCode).ToArray()) + "')", string.Empty); ///排序拉动方式 零件类 List <JisPartBoxInfo> jisPartBoxInfos = new JisPartBoxDAL().GetList("" + " and [STATUS] =" + (int)BasicDataStatusConstants.Enable + "" + " and [STATUS_POINT_CODE] in ('" + string.Join("','", statusPointInfos.Select(d => d.StatusPointCode).ToArray()) + "')", string.Empty); ///相应的物料拉动信息 List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandardInfos = new MaintainInhouseLogisticStandardDAL().GetList("" + " and [STATUS] =" + (int)BasicDataStatusConstants.Enable + "" + " (and [INHOUSE_PART_CLASS] in ('" + string.Join("','", twdPartBoxInfos.Select(d => d.PartBoxCode).ToArray()) + "')" + " or [INHOUSE_PART_CLASS] in ('" + string.Join("','", jisPartBoxInfos.Select(d => d.PartBoxCode).ToArray()) + "'))", string.Empty); if (maintainInhouseLogisticStandardInfos.Count == 0) { return; } foreach (BomRepleaceConditionInfo bomRepleaceConditionInfo in bomRepleaceConditionInfos) { ///有效时间内 if (!(bomRepleaceConditionInfo.ExecuteStartTime <= DateTime.Now) || !(DateTime.Now <= bomRepleaceConditionInfo.ExecuteEndTime)) { continue; } ///根据起始生产订单号,获取车辆状态点信息判断其是否在线,若未上线则不执行以下逻辑 PullOrdersInfo pullOrdersInfo = pullOrdersInfos.FirstOrDefault(d => d.OrderNo == bomRepleaceConditionInfo.StartPorderCode); if (pullOrdersInfo == null || pullOrdersInfo.OrderStatus != (int)OrderStatusConstants.AlreadOnline) { continue; } ///若已上线或已下线则需要根据其获取顺序号之后的所有在线生产订单,依次循环进行逻辑处理 TODO:已下线的逻辑? ///同一起始生产订单号可能出现在多条生产线的状态点上,以下为单生产订单处理逻辑 TODO:多条生产线的逻辑? ///已上线的生产订单: ///本生产订单对应的车辆状态点信息 List <VehiclePointStatusInfo> vehiclePointStatuss = vehiclePointStatusInfos.Where(d => d.OrderNo == pullOrdersInfo.OrderNo).ToList(); if (vehiclePointStatuss.Count == 0) { continue; } ///当前车辆最大状态点信息 VehiclePointStatusInfo vehiclePointStatusInfo = vehiclePointStatuss.Where(d => d.OrderNo == pullOrdersInfo.OrderNo).OrderByDescending(d => d.PassTime).FirstOrDefault(); if (vehiclePointStatusInfo == null) { continue; } ///当前顺序号之后的所有的车辆状态点信息 List <VehiclePointStatusInfo> vehiclePoints = vehiclePointStatusInfos.Where(d => d.SeqNo >= vehiclePointStatusInfo.SeqNo).ToList(); ///当前顺序号之后的所有在线生产订单 pullOrdersInfos = (from p in pullOrdersInfos join v in vehiclePoints on p.OrderNo equals v.OrderNo select p).Distinct().ToList(); ///依次循环进行逻辑处理 foreach (PullOrdersInfo pullOrder in pullOrdersInfos) { ///根据生产订单号获取其物料清单,作为后续匹配更改单的源数据 List <PullOrderBomInfo> pullOrderBomInfos = new PullOrderBomDAL().GetList("" + "and [ORDERFID]='" + pullOrdersInfo.Fid + "'", string.Empty); if (pullOrderBomInfos.Count == 0) { continue; } ///本生产订单对应的车辆状态点信息 List <VehiclePointStatusInfo> vehicles = vehiclePointStatusInfos.Where(d => d.OrderNo == pullOrdersInfo.OrderNo).ToList(); if (vehicles.Count == 0) { continue; } ///本产生订单对应的所有状态点信息 List <StatusPointInfo> statusPoints = statusPointInfos.Where(d => vehicles.Select(v => v.StatusPointCode).Contains(d.StatusPointCode)).ToList(); if (statusPoints.Count == 0) { continue; } ///已在线的生产订单在此时,需要根据所在状态点位置 VehiclePointStatusInfo vehiclePointStatus = vehiclePointStatusInfos.Where(d => d.OrderNo == pullOrder.OrderNo).OrderByDescending(d => d.PassTime).FirstOrDefault(); if (vehiclePointStatus == null) { continue; } StatusPointInfo statusPointInfo = statusPointInfos.FirstOrDefault(d => d.StatusPointCode == vehiclePointStatus.StatusPointCode); if (statusPointInfo == null) { continue; } ///将物料拉动的结果集分为三个部分,其一为未累计、其二为已累计未拉动、其三为已拉动 ///该生产订单对应的其后状态点 List <StatusPointInfo> notStatusPoints = statusPoints.Where(d => d.StatusPointSeq > statusPointInfo.StatusPointSeq).ToList(); ///该生产订单对应的状态点及之前的状态点 List <StatusPointInfo> yesStatusPoints = statusPoints.Where(d => d.StatusPointSeq <= statusPointInfo.StatusPointSeq).ToList(); ///其后的状态点 if (notStatusPoints.Count > 0) { ///其一为当前状态点位置之后的状态点对应的时间窗(过点累计方式)、排序拉动方式相应的物料拉动信息物料、供应商、工位 ///该逻辑获取的数据在此不做后续处理,但此逻辑请事先在程序中实现,将会到离队归队时使用 List <TwdPartBoxInfo> twdPartBoxs = twdPartBoxInfos.Where(d => notStatusPoints.Select(s => s.StatusPointCode).Contains(d.StatusPointCode)).ToList(); List <JisPartBoxInfo> jisPartBoxs = jisPartBoxInfos.Where(d => notStatusPoints.Select(s => s.StatusPointCode).Contains(d.StatusPointCode)).ToList(); ///零件类对应的物料拉动信息 if (twdPartBoxs.Count != 0 || jisPartBoxs.Count != 0) { ///生产订单的产线下的物料拉动信息 List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandards = maintainInhouseLogisticStandardInfos. Where(d => d.AssemblyLine == pullOrder.AssemblyLine).Where(d => (twdPartBoxs.Select(t => t.PartBoxCode).Contains(d.InhousePartClass)) || (jisPartBoxs.Select(j => j.PartBoxCode).Contains(d.InhousePartClass))).ToList(); if (maintainInhouseLogisticStandards.Count != 0) { ///拉动信息对应的Bom清单 List <PullOrderBomInfo> pullOrderBoms = pullOrderBomInfos.Where(d => maintainInhouseLogisticStandards.Select(m => m.PartNo).Contains(d.Zcomno) && maintainInhouseLogisticStandards.Select(m => m.SupplierNum).Contains(d.SupplierNum)).ToList(); } } } ///其二、其三目前没有较理想的方式区分开,暂时以已拉动处理、当前状态点位置之前包括该状态点位置对应的拉动方式相关物料拉动信息 if (yesStatusPoints.Count > 0) { List <TwdPartBoxInfo> twdPartBoxs = twdPartBoxInfos.Where(d => yesStatusPoints.Select(s => s.StatusPointCode).Contains(d.StatusPointCode)).ToList(); List <JisPartBoxInfo> jisPartBoxs = jisPartBoxInfos.Where(d => yesStatusPoints.Select(s => s.StatusPointCode).Contains(d.StatusPointCode)).ToList(); ///零件类对应的物料拉动信息 if (twdPartBoxs.Count != 0 || jisPartBoxs.Count != 0) { ///生产订单的产线下的物料拉动信息 List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandards = maintainInhouseLogisticStandardInfos. Where(d => d.AssemblyLine == pullOrder.AssemblyLine).Where(d => (twdPartBoxs.Select(t => t.PartBoxCode).Contains(d.InhousePartClass)) || (jisPartBoxs.Select(j => j.PartBoxCode).Contains(d.InhousePartClass))).ToList(); maintainInhouseLogisticStandards = maintainInhouseLogisticStandards.Where(d => d.PartNo == bomRepleaceConditionInfo.OldPartNo).ToList(); ///根据已拉动的物料拉动信息,与替换条件中的旧物料号对比 ///若不存在于已拉动物料中,则只需要执行生产订单物料清单替换逻辑即可 ///否则需要进行新物料号的自动紧急拉动且生成旧物料号的余料退库单(退库地点为物料拉动信息中的来源库存地点) ///同时也需要执行生产订单物料清单替换逻辑 if (maintainInhouseLogisticStandards.Count > 0) { ///拉动信息对应的Bom清单 List <PullOrderBomInfo> pullOrderBoms = pullOrderBomInfos.Where(d => maintainInhouseLogisticStandards.Select(m => m.PartNo).Contains(d.Zcomno) && maintainInhouseLogisticStandards.Select(m => m.SupplierNum).Contains(d.SupplierNum)).ToList(); foreach (PullOrderBomInfo pullOrderBom in pullOrderBoms) { MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandardInfo = maintainInhouseLogisticStandards.FirstOrDefault(d => d.PartNo == pullOrderBom.Zcomno && d.SupplierNum == pullOrderBom.SupplierNum); if (maintainInhouseLogisticStandardInfo == null) { continue; } ///进行新物料号的自动紧急拉动 ///生成旧物料号的余料退库单(退库地点为物料拉动信息中的来源库存地点) } } new BomRepleaceConditionBLL().ReplacementCriteria(pullOrder, loginUser); } } } } }
/// <summary> /// /// </summary> /// <param name="jisPartBoxInfo"></param> /// <param name="jisCounterInfo"></param> /// <param name="vehiclePointStatusInfo"></param> /// <param name="maintainInhouseLogisticStandardInfo"></param> /// <param name="currentQty"></param> /// <returns></returns> private string UpdateJisCounter(JisPartBoxInfo jisPartBoxInfo, JisCounterInfo jisCounterInfo, VehiclePointStatusInfo vehiclePointStatusInfo, MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandardInfo, decimal currentQty) { ///创建计数器日志 JisCounterLogInfo jisCounterLogInfo = JisCounterLogBLL.CreateJisCounterLogInfo(jisCounterInfo.Fid.GetValueOrDefault(), loginUser); ///以车辆过点信息填充计数器日志 JisCounterLogBLL.GetJisCounterLogInfo(vehiclePointStatusInfo, ref jisCounterLogInfo); ///以零件类信息填充计数器日志 JisCounterLogBLL.GetJisCounterLogInfo(jisPartBoxInfo, ref jisCounterLogInfo); ///以物料拉动信息填充计数器日志 JisCounterLogBLL.GetJisCounterLogInfo(maintainInhouseLogisticStandardInfo, ref jisCounterLogInfo); ///PART_QTY jisCounterLogInfo.PartQty = currentQty; /// return(JisCounterLogDAL.GetInsertSql(jisCounterLogInfo)); }
/// <summary> /// JIS /// </summary> /// <param name="vehiclePointStatusInfo"></param> /// <param name="jisPartBoxInfos"></param> /// <param name="jisCounterInfos"></param> /// <param name="jisMaintainInhouseLogisticStandardInfos"></param> /// <returns></returns> private string JisCounterDeal(VehiclePointStatusInfo vehiclePointStatusInfo, List <JisPartBoxInfo> jisPartBoxInfos, List <MaintainInhouseLogisticStandardInfo> jisMaintainInhouseLogisticStandardInfos) { /// StringBuilder stringBuilder = new StringBuilder(); ///根据车辆状态信息中的生产订单号①获取到对应的生产订单物料清单、此处为了保障执行效率,需要根据已获取的物料拉动信息过滤获取物料清单 List <PullOrderBomInfo> pullOrderBomInfos = new PullOrderBomBLL().GetList("" + "[ZORDNO] = N'" + vehiclePointStatusInfo.OrderNo + "' and " + "[ZCOMNO] in ('" + string.Join("','", jisMaintainInhouseLogisticStandardInfos.Select(d => d.PartNo).ToArray()) + "')", string.Empty); if (pullOrderBomInfos.Count == 0) { return(string.Empty); } /// foreach (JisPartBoxInfo jisPartBoxInfo in jisPartBoxInfos) { ///不是这个信息点的零件类忽略 if (vehiclePointStatusInfo.StatusPointCode != jisPartBoxInfo.StatusPointCode) { continue; } ///根据物料拉动信息外键获取计数器,未能成功获取时需要创建 JisCounterInfo jisCounterInfo = new JisCounterBLL().GetInfoByPartBoxFid(jisPartBoxInfo.Fid.GetValueOrDefault()); if (jisCounterInfo == null) { jisCounterInfo = CreateJisCounterInfo(jisPartBoxInfo); } ///零件类对应的物料拉动信息 List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandards = jisMaintainInhouseLogisticStandardInfos.Where(d => d.InhousePartClass == jisPartBoxInfo.PartBoxCode).ToList(); if (maintainInhouseLogisticStandards.Count == 0) { continue; } ///零件类过滤后的物料拉动信息对应的物料清单 List <PullOrderBomInfo> pullOrderBoms = pullOrderBomInfos.Where(d => maintainInhouseLogisticStandards.Select(m => m.PartNo).Contains(d.Zcomno)).ToList(); if (pullOrderBoms.Count == 0) { continue; } ///当排序计数器的累计方式⑧为按车辆累计时 if (jisPartBoxInfo.AccumulativeType.GetValueOrDefault() == (int)JisAccumulativeTypeConstants.VehicleAccumulative) { ///本次可累计车辆数量 decimal vehicleQty = jisCounterInfo.AccumulativeQty.GetValueOrDefault() - jisCounterInfo.CurrentQty.GetValueOrDefault(); int vehicleCounterStatus = (int)JisCounterStatusConstants.Accumulating; if (vehicleQty == 1) { vehicleCounterStatus = (int)JisCounterStatusConstants.AccumulativeCompletion; } /// stringBuilder.AppendLine(UpdateJisCounter(jisPartBoxInfo, jisCounterInfo, 1, vehicleCounterStatus)); } /// foreach (PullOrderBomInfo pullOrderBom in pullOrderBoms) { ///匹配物料拉动信息的最小维度是 物料图号+供应商+工位,依次降低维度来获取唯一的物料拉动信息 MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandard = maintainInhouseLogisticStandards.FirstOrDefault(d => d.PartNo == pullOrderBom.Zcomno && d.SupplierNum == pullOrderBom.SupplierNum && d.Location == pullOrderBom.Zloc); ///物料图号+供应商 if (maintainInhouseLogisticStandard == null) { maintainInhouseLogisticStandard = maintainInhouseLogisticStandards.FirstOrDefault(d => d.PartNo == pullOrderBom.Zcomno && d.SupplierNum == pullOrderBom.SupplierNum); } ///物料图号 if (maintainInhouseLogisticStandard == null) { maintainInhouseLogisticStandard = maintainInhouseLogisticStandards.FirstOrDefault(d => d.PartNo == pullOrderBom.Zcomno); } ///未能成功获取到正确的物料拉动信息 if (maintainInhouseLogisticStandard == null) { continue; } ///当排序计数器的累计方式⑧为按车辆累计时 if (jisPartBoxInfo.AccumulativeType.GetValueOrDefault() == (int)JisAccumulativeTypeConstants.VehicleAccumulative) { stringBuilder.AppendLine(UpdateJisCounter(jisPartBoxInfo, jisCounterInfo, vehiclePointStatusInfo, maintainInhouseLogisticStandard, pullOrderBom.Zqty.GetValueOrDefault())); } ///当排序计数器的累计方式⑧为按器具累计时 if (jisPartBoxInfo.AccumulativeType.GetValueOrDefault() == (int)JisAccumulativeTypeConstants.UtensilAccumulative) { ///物料需求数量 decimal requireQty = pullOrderBom.Zqty.GetValueOrDefault(); while (requireQty > 0) { int jisCounterStatus = (int)JisCounterStatusConstants.Accumulating; ///本次可累计数量 decimal currentQty = jisCounterInfo.AccumulativeQty.GetValueOrDefault() - jisCounterInfo.CurrentQty.GetValueOrDefault(); if (currentQty == 0) { break; } ///需求大于本次可累计 if (currentQty <= requireQty) { ///剩余需累计数量 requireQty -= currentQty; ///累计完成 jisCounterStatus = (int)JisCounterStatusConstants.AccumulativeCompletion; } else { ///将需求赋予本次 currentQty = requireQty; ///需求清空 requireQty = 0; } /// stringBuilder.AppendLine(UpdateJisCounter(jisPartBoxInfo, jisCounterInfo, currentQty, jisCounterStatus)); /// stringBuilder.AppendLine(UpdateJisCounter(jisPartBoxInfo, jisCounterInfo, vehiclePointStatusInfo, maintainInhouseLogisticStandard, currentQty)); ///当剩余需求数量大于零时,需要创建计数器 if (requireQty > 0) { jisCounterInfo = CreateJisCounterInfo(jisPartBoxInfo); } } } ///触发层级拉动 stringBuilder.AppendLine(TwdCounterBLL.LevelPullRequirementCounter( maintainInhouseLogisticStandard, pullOrderBom.Zqty.GetValueOrDefault(), loginUser, jisCounterInfo.Fid.GetValueOrDefault(), jisCounterInfo.PartBoxCode)); } } return(stringBuilder.ToString()); }
/// <summary> /// TWD /// </summary> /// <param name="vehiclePointStatusInfo"></param> /// <param name="twdCounterInfos"></param> /// <param name="twdMaintainInhouseLogisticStandardInfos"></param> /// <returns></returns> private string TwdCounterDeal(VehiclePointStatusInfo vehiclePointStatusInfo, List <TwdPartBoxInfo> twdPartBoxInfos, List <MaintainInhouseLogisticStandardInfo> twdMaintainInhouseLogisticStandardInfos) { /// StringBuilder stringBuilder = new StringBuilder(); ///根据车辆状态信息中的生产订单号①获取到对应的生产订单物料清单、此处为了保障执行效率,需要根据已获取的计数器的物料号⑩过滤获取物料清单 ///ZORDNO = 生产订单号 ///ZCOMNO = 物料图号 List <PullOrderBomInfo> pullOrderBomInfos = new PullOrderBomBLL().GetList("" + "[ZORDNO] = N'" + vehiclePointStatusInfo.OrderNo + "' and " + "[ZCOMNO] in ('" + string.Join("','", twdMaintainInhouseLogisticStandardInfos.Select(d => d.PartNo).ToArray()) + "')", string.Empty); if (pullOrderBomInfos.Count == 0) { return(string.Empty); } /// foreach (TwdPartBoxInfo twdPartBoxInfo in twdPartBoxInfos) { ///不是这个信息点的零件类忽略 if (vehiclePointStatusInfo.StatusPointCode != twdPartBoxInfo.StatusPointCode) { continue; } ///本零件类对应的物料拉动信息 List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandards = twdMaintainInhouseLogisticStandardInfos.Where(d => d.InhousePartClass == twdPartBoxInfo.PartBoxCode).ToList(); ///若本零件类无物料拉动信息则返回 if (twdMaintainInhouseLogisticStandardInfos.Count == 0) { continue; } ///零件类过滤后的物料拉动信息对应的物料清单 List <PullOrderBomInfo> pullOrderBoms = pullOrderBomInfos.Where(d => maintainInhouseLogisticStandards.Select(m => m.PartNo).Contains(d.Zcomno)).ToList(); ///循环过滤后的物料清单 foreach (PullOrderBomInfo pullOrderBom in pullOrderBoms) { ///匹配物料拉动信息的最小维度是 物料图号+供应商+工位,依次降低维度来获取唯一的物料拉动信息 MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandard = maintainInhouseLogisticStandards.FirstOrDefault(d => d.PartNo == pullOrderBom.Zcomno && d.SupplierNum == pullOrderBom.SupplierNum && d.Location == pullOrderBom.Zloc); ///物料图号+供应商 if (maintainInhouseLogisticStandard == null) { maintainInhouseLogisticStandard = maintainInhouseLogisticStandards.FirstOrDefault(d => d.PartNo == pullOrderBom.Zcomno && d.SupplierNum == pullOrderBom.SupplierNum); } ///物料图号 if (maintainInhouseLogisticStandard == null) { maintainInhouseLogisticStandard = maintainInhouseLogisticStandards.FirstOrDefault(d => d.PartNo == pullOrderBom.Zcomno); } ///未能成功获取到正确的物料拉动信息 if (maintainInhouseLogisticStandard == null) { continue; } ///根据物料拉动信息外键获取计数器,未能成功获取时需要创建 TwdCounterInfo twdCounterInfo = TwdCounterBLL.GetInfoByPartPullFid(maintainInhouseLogisticStandard.Fid); if (twdCounterInfo == null) { ///创建计数器 twdCounterInfo = TwdCounterBLL.CreateTwdCounterInfo(loginUser); ///以物料拉动信息填充计数器 TwdCounterBLL.GetTwdCounterInfo(maintainInhouseLogisticStandard, ref twdCounterInfo); ///以零件类信息填充计数器 TwdCounterBLL.GetTwdCounterInfo(twdPartBoxInfo, ref twdCounterInfo); /// twdCounterInfo.Id = new TwdCounterBLL().InsertInfo(twdCounterInfo); if (twdCounterInfo.Id == 0) { throw new Exception("MC:0x00000453");///时间窗计数器创建失败 } } ///计数器状态未处于启用 if (twdCounterInfo.Status != (int)BasicDataStatusConstants.Enable) { continue; } stringBuilder.AppendLine(TwdCounterBLL.UpdateTwdCounter(maintainInhouseLogisticStandard, twdPartBoxInfo, pullOrderBom.Zqty.GetValueOrDefault(), twdCounterInfo.Id, loginUser)); ///创建计数器日志 TwdCounterLogInfo twdCounterLogInfo = TwdCounterLogBLL.CreateTwdCounterLogInfo(twdCounterInfo.Fid.GetValueOrDefault(), loginUser); ///以车辆过点信息填充计数器日志 TwdCounterLogBLL.GetTwdCounterLogInfo(vehiclePointStatusInfo, ref twdCounterLogInfo); ///以物料拉动信息填充计数器日志 TwdCounterLogBLL.GetTwdCounterLogInfo(maintainInhouseLogisticStandard, ref twdCounterLogInfo); ///以零件类信息填充计数器日志 TwdCounterLogBLL.GetTwdCounterLogInfo(twdPartBoxInfo, ref twdCounterLogInfo); ///PART_QTY twdCounterLogInfo.PartQty = pullOrderBom.Zqty.GetValueOrDefault(); /// stringBuilder.AppendLine(TwdCounterLogDAL.GetInsertSql(twdCounterLogInfo)); ///触发层级拉动 stringBuilder.AppendLine(TwdCounterBLL.LevelPullRequirementCounter( maintainInhouseLogisticStandard, pullOrderBom.Zqty.GetValueOrDefault(), loginUser, twdCounterInfo.Fid.GetValueOrDefault(), twdCounterInfo.PartBoxCode)); } } return(stringBuilder.ToString()); }
/// <summary> /// InsertInfo /// </summary> /// <param name="info"></param> /// <returns></returns> public long InsertInfo(VehiclePointStatusInfo info) { return(dal.Add(info)); }
/// <summary> /// 车辆过点信息处理 /// </summary> /// <param name="mesVehiclePointScanInfo"></param> /// <param name="scanPointInfos"></param> /// <param name="statusPointInfos"></param> /// <param name="intLesVehicleSeqStep"></param> /// <returns></returns> public string VehicleCrossingScanSql(MesVehiclePointScanInfo mesVehiclePointScanInfo, List <ScanPointInfo> scanPointInfos, List <StatusPointInfo> statusPointInfos, int intLesVehicleSeqStep, PullOrdersInfo pullOrdersInfo, List <PlantInfo> plantInfos) { ///sql StringBuilder stringBuilder = new StringBuilder(); ///根据采集点编号④ = MES扫描点③获取到唯一的扫描点代码①,此处需要匹配工厂编号① = 工厂④ PlantInfo plantInfo = plantInfos.Where(d => d.SapPlantCode == mesVehiclePointScanInfo.Enterprise).First(); ScanPointInfo scanPointInfo = scanPointInfos.Where(d => d.MesScanPointCode == mesVehiclePointScanInfo.UnitNo && d.Plant == plantInfo.Plant).FirstOrDefault(); if (scanPointInfo == null) { return(string.Empty); } ///并根据唯一的扫描点代码①=④从状态点表中获取对应的状态点集合 List <StatusPointInfo> statusPointByscanPointInfos = statusPointInfos.Where(d => d.ScanPointCode == scanPointInfo.ScanPointCode).ToList(); if (statusPointByscanPointInfos.Count == 0) { return(string.Empty); } ///处理状态点集合 foreach (StatusPointInfo statusPointInfo in statusPointByscanPointInfos) { ///当状态点数据中是否匹配生产线⑪=true时、需要根据计划订单号匹配生产订单⑥中对应的生产线、若是否匹配生产线⑪=false则无需进行匹配 string assemblyLine = statusPointInfo.AssemblyLineFixedFlag.GetValueOrDefault() ? statusPointInfo.AssemblyLine : string.Empty; ///车辆状态点信息 List <VehiclePointStatusInfo> vehiclePointStatusInfos = new VehiclePointStatusBLL().GetList("" + "[PLANT] = N'" + statusPointInfo.Plant + "' and " + "[WORKSHOP] = N'" + statusPointInfo.Workshop + "' and " + (string.IsNullOrEmpty(assemblyLine) ? string.Empty : "[ASSEMBLY_LINE] = N'" + assemblyLine + "' and ") + "[ORDER_NO] = N'" + mesVehiclePointScanInfo.DmsNo + "'", string.Empty); ///扫描点基础数据 List <StatusPointInfo> statusPoints = new StatusPointBLL().GetList("" + "[PLANT] = N'" + statusPointInfo.Plant + "' and " + (string.IsNullOrEmpty(assemblyLine) ? string.Empty : "[ASSEMBLY_LINE] = N'" + assemblyLine + "' and ") + "[WORKSHOP] = N'" + statusPointInfo.Workshop + "'", string.Empty); ///若没有数据则需要根据该维度获取状态点基础数据中对应的数据集合 ///并以此集合为基础将信息匹配完成后批量写入车辆状态点信息 long currentSeqNo = 0; #region 横向维度 if (vehiclePointStatusInfos.Count == 0) { ///首次批量插入一个生产订单在工厂⑨车间⑧或工厂⑨车间⑧生产线⑦维度范围内数据时 foreach (var statusPoint in statusPoints.OrderBy(d => d.StatusPointSeq.GetValueOrDefault()).ToList()) { ///StatusPointInfo ->VehiclePointStatusInfo VehiclePointStatusInfo pointStatusInfo = new VehiclePointStatusInfo(); ///ORDER_NO,生产订单号 pointStatusInfo.OrderNo = mesVehiclePointScanInfo.DmsNo; ///STATUS_POINT_CODE,状态点代码 pointStatusInfo.StatusPointCode = statusPoint.StatusPointCode; ///PLANT pointStatusInfo.Plant = statusPoint.Plant; ///Workshop pointStatusInfo.Workshop = statusPoint.Workshop; ///ASSEMBLY_LINE pointStatusInfo.AssemblyLine = statusPoint.AssemblyLine; ///SPJ pointStatusInfo.Spj = pullOrdersInfo.Spj; ///KNR pointStatusInfo.Knr = pullOrdersInfo.Knr; ///Schicht pointStatusInfo.Schicht = null; ///Shift pointStatusInfo.Shift = null; ///Vin pointStatusInfo.Vin = pullOrdersInfo.Vin; ///RunningNo pointStatusInfo.RunningNo = mesVehiclePointScanInfo.DmsSeq.ToString(); ///PassTime,过点时间 pointStatusInfo.PassTime = null; ///VehicleStatus,初始化 pointStatusInfo.VehicleStatus = (int)VehicleStatusTypeConstants.Initializtion; ///ProcessFlag pointStatusInfo.ProcessFlag = (int)ProcessFlagConstants.Untreated; ///SeqNo,LES序号 pointStatusInfo.SeqNo = GetcurrentSeqNo(statusPoints, statusPointInfo, intLesVehicleSeqStep); stringBuilder.AppendLine(VehiclePointStatusDAL.GetInsertSql(pointStatusInfo)); } ///LES排序号 currentSeqNo = GetcurrentSeqNo(statusPoints, statusPointInfo, intLesVehicleSeqStep); ///更新生产订单状态为已上线 stringBuilder.AppendFormat("update [LES].[TT_BAS_PULL_ORDERS] set " + "[ORDER_STATUS]=" + (int)OrderStatusConstants.AlreadOnline + "" + ",[MODIFY_USER]='" + loginUser + "',[MODIFY_DATE]=GETDATE() " + "where [ID] = " + pullOrdersInfo.Id + ";"); } ///若已存在数据则首先需要将本采集点编号④对应的状态点代码②数据的过点时间⑦=⑦、车辆状态⑨更新 ///车辆状态的更新目前已知的类型有初始化、正常过点、校验补入、车辆离队、车辆归队,需要枚举项VEHICLE_STATUS_TYPE支持 else { VehiclePointStatusInfo pointStatusInfo = vehiclePointStatusInfos.FirstOrDefault(d => d.StatusPointCode == statusPointInfo.StatusPointCode); if (pointStatusInfo == null) { continue; } ///当车辆离队时,更新LES排序号⑬为零,车辆归队时重新计算车辆所在位置对应的LES排序号⑬,规则依照之前逻辑 ///离队标记 bool leaveFlag = false; if (leaveFlag) { List <StatusPointInfo> statuses = statusPoints.Where(d => d.StatusPointSeq.GetValueOrDefault() >= statusPointInfo.StatusPointSeq.GetValueOrDefault()).ToList(); List <VehiclePointStatusInfo> infos = vehiclePointStatusInfos.Where(d => statuses.Select(s => s.StatusPointCode).Contains(d.StatusPointCode)).ToList(); foreach (var info in infos) { stringBuilder.AppendLine("update [LES].[TT_BAS_VEHICLE_POINT_STATUS] " + "set [VEHICLE_STATUS] = " + (int)VehicleStatusTypeConstants.VehicleLeave + ",[SEQ_NO] = 0,[MODIFY_USER]='" + loginUser + "',[MODIFY_DATE]=GETDATE() " + "where [ID] = " + info.Id + ";"); } ///更新生产订单状态为已离队 stringBuilder.AppendFormat("update [LES].[TT_BAS_PULL_ORDERS] set " + "[ORDER_STATUS]=" + (int)OrderStatusConstants.Bryan + "" + ",[MODIFY_USER]='" + loginUser + "',[MODIFY_DATE]=GETDATE() " + "where [ID] = " + pullOrdersInfo.Id + ";"); continue; } ///车辆归队 if (pointStatusInfo.VehicleStatus == (int)VehicleStatusTypeConstants.VehicleLeave) { stringBuilder.AppendLine("update [LES].[TT_BAS_VEHICLE_POINT_STATUS] " + "set [PASS_TIME] = N'" + mesVehiclePointScanInfo.SendTime.GetValueOrDefault() + "'," + "[VEHICLE_STATUS] = " + (int)VehicleStatusTypeConstants.VehicleReturn + " ," + "[SEQ_NO] = " + GetcurrentSeqNo(statusPoints, statusPointInfo, intLesVehicleSeqStep) + ",[MODIFY_USER]='" + loginUser + "',[MODIFY_DATE]=GETDATE()" + "where [ID] = " + pointStatusInfo.Id + ";"); List <StatusPointInfo> statuses = statusPoints.Where(d => d.StatusPointSeq.GetValueOrDefault() > statusPointInfo.StatusPointSeq.GetValueOrDefault()).ToList(); List <VehiclePointStatusInfo> infos = vehiclePointStatusInfos.Where(d => statuses.Select(s => s.StatusPointCode).Contains(d.StatusPointCode)).ToList(); foreach (var info in infos) { stringBuilder.AppendLine("update [LES].[TT_BAS_VEHICLE_POINT_STATUS] " + "set [VEHICLE_STATUS] = " + (int)VehicleStatusTypeConstants.Initializtion + " ," + "[SEQ_NO] = " + GetcurrentSeqNo(statuses, statusPointInfo, intLesVehicleSeqStep) + " ,[MODIFY_USER]='" + loginUser + "',[MODIFY_DATE]=GETDATE()" + "where [ID] = " + info.Id + ";"); } ///更新生产订单状态为已归队 stringBuilder.AppendFormat("update [LES].[TT_BAS_PULL_ORDERS] set " + "[ORDER_STATUS]=" + (int)OrderStatusConstants.ComeBack + "" + ",[MODIFY_USER]='" + loginUser + "',[MODIFY_DATE]=GETDATE() " + "where [ID] = " + pullOrdersInfo.Id + ";"); } ///LES序号 currentSeqNo = pointStatusInfo.SeqNo.GetValueOrDefault(); DateTime currentTime = mesVehiclePointScanInfo.SendTime.GetValueOrDefault(); stringBuilder.AppendLine("update [LES].[TT_BAS_VEHICLE_POINT_STATUS] " + "set [PASS_TIME] = N'" + currentTime + "',[VEHICLE_STATUS] = " + (int)VehicleStatusTypeConstants.NormalPoint + " ,[MODIFY_USER]='" + loginUser + "',[MODIFY_DATE]=GETDATE()" + "where [ID] = " + pointStatusInfo.Id + ";"); ///对于状态点顺序在本次更新的车辆状态点信息之前的且车辆状态为初始化的数据需要更新其过点时间⑦、车辆状态⑨为校验补入 ///过点时间根据获取最近一条有过点时间⑦到本条车辆状态数据过点时间⑦的时间差按车辆状态⑨初始化的状态点数量平均分配计算赋值 List <VehiclePointStatusInfo> vehiclePointStatuses = vehiclePointStatusInfos. Where(d => d.VehicleStatus == (int)VehicleStatusTypeConstants.VehicleLeave && d.StatusPointCode != statusPointInfo.StatusPointCode). OrderByDescending(d => d.Id). ToList(); if (vehiclePointStatuses.Count == 0) { continue; } DateTime?lastTime = new VehiclePointStatusDAL().GetLastTime( statusPointInfo.Plant, statusPointInfo.Workshop, statusPointInfo.StatusPointCode, statusPointInfo.AssemblyLine); TimeSpan timeSpan = mesVehiclePointScanInfo.SendTime.GetValueOrDefault() - lastTime.GetValueOrDefault(); int deductionSecondsPer = Convert.ToInt32(timeSpan.TotalSeconds) / (vehiclePointStatuses.Count - 1); foreach (var vehiclePointStatuse in vehiclePointStatuses) { currentTime = currentTime.AddSeconds(0 - deductionSecondsPer); stringBuilder.AppendLine("update [LES].[TT_BAS_VEHICLE_POINT_STATUS] set " + "[PASS_TIME] = N'" + currentTime + "'," + "[VEHICLE_STATUS] = " + (int)VehicleStatusTypeConstants.CheckAndFill + ",[MODIFY_USER]='" + loginUser + "',[MODIFY_DATE]=GETDATE() " + "where [ID] = " + vehiclePointStatuse.Id + ";"); } ///TODO: ///当前过点类型为正常过点、车辆离队时触发以上逻辑 ///过点类型目前接口中未体现,后期需要增加,预先考虑逻辑放置位置,类型为车辆归队时只需更新本条记录即可 ///若接口中车辆归队与正常过点无法区分,则需要在车辆离队时将其状态标记在生产订单上,以便区别正常过点与车辆归队 } ///以上为横向维度(同生产订单号)的处理逻辑 #endregion ///以下为纵向维度(同状态点)的处理逻辑 stringBuilder.AppendFormat(LongitudinalDimension(statusPoints, statusPointInfo, mesVehiclePointScanInfo, assemblyLine, currentSeqNo)); } return(stringBuilder.ToString()); }