/// <summary> /// Handler /// </summary> public void Handler() { ///获取状态为待处理的车辆状态信息,其中类型为正常过点、校验补入、车辆归队 List <VehiclePointStatusInfo> vehiclePointStatusInfos = new VehiclePointStatusBLL().GetList("" + "[PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + " and " + "[VEHICLE_STATUS] in (" + (int)VehicleStatusTypeConstants.NormalPoint + "," + (int)VehicleStatusTypeConstants.CheckAndFill + "," + (int)VehicleStatusTypeConstants.VehicleReturn + ")", "[ID]"); if (vehiclePointStatusInfos.Count == 0) { return; } #region TWD 计数器及基础数据获取 ///根据状态点代码获取时间窗零件类中需求累计方式㉒为过点且状态为已启用⑭的数据 List <TwdPartBoxInfo> twdPartBoxInfos = new TwdPartBoxBLL().GetList("" + "[REQUIREMENT_ACCUMULATE_MODE] = " + (int)RequirementAccumulateModeConstants.PassSpot + " and " + "[STATUS] =" + (int)BasicDataStatusConstants.Enable + " and " + "[STATUS_POINT_CODE] in ('" + string.Join("','", vehiclePointStatusInfos.Select(d => d.StatusPointCode).ToArray()) + "')", string.Empty); ///物料拉动信息 List <MaintainInhouseLogisticStandardInfo> twdMaintainInhouseLogisticStandardInfos = new List <MaintainInhouseLogisticStandardInfo>(); if (twdPartBoxInfos.Count > 0) { ///同时获取这些零件类下对应的已启用的物料拉动信息 twdMaintainInhouseLogisticStandardInfos = new MaintainInhouseLogisticStandardBLL().GetList("" + "[STATUS] =" + (int)BasicDataStatusConstants.Enable + " and " + "[INHOUSE_SYSTEM_MODE] = N'" + (int)PullModeConstants.Twd + "' and " + "[INHOUSE_PART_CLASS] in ('" + string.Join("','", twdPartBoxInfos.Select(d => d.PartBoxCode).ToArray()) + "')", string.Empty); } #endregion #region JIS 计数器及基础数据获取 ///根据状态点代码获取排序零件类中状态㉖为已启用的数据 List <JisPartBoxInfo> jisPartBoxInfos = new JisPartBoxBLL().GetList("" + "[STATUS] =" + (int)BasicDataStatusConstants.Enable + " and " + "[STATUS_POINT_CODE] in ('" + string.Join("','", vehiclePointStatusInfos.Select(d => d.StatusPointCode).ToArray()) + "')", string.Empty); ///物料拉动信息 List <MaintainInhouseLogisticStandardInfo> jisMaintainInhouseLogisticStandardInfos = new List <MaintainInhouseLogisticStandardInfo>(); if (jisPartBoxInfos.Count > 0) { ///同时获取这些零件类下对应的已启用的物料拉动信息 jisMaintainInhouseLogisticStandardInfos = new MaintainInhouseLogisticStandardBLL().GetList("" + "[STATUS] =" + (int)BasicDataStatusConstants.Enable + " and " + "[INHOUSE_SYSTEM_MODE] = N'" + (int)PullModeConstants.Jis + "' and " + "[INHOUSE_PART_CLASS] in ('" + string.Join("','", jisPartBoxInfos.Select(d => d.PartBoxCode).ToArray()) + "')", string.Empty); } #endregion foreach (VehiclePointStatusInfo vehiclePointStatusInfo in vehiclePointStatusInfos) { ///执行语句 StringBuilder stringBuilder = new StringBuilder(); ///TWD if (twdPartBoxInfos.Count > 0 && twdMaintainInhouseLogisticStandardInfos.Count > 0) { stringBuilder.AppendLine(TwdCounterDeal(vehiclePointStatusInfo, twdPartBoxInfos, twdMaintainInhouseLogisticStandardInfos)); } ///JIS if (jisPartBoxInfos.Count > 0 && jisMaintainInhouseLogisticStandardInfos.Count > 0) { stringBuilder.AppendLine(JisCounterDeal(vehiclePointStatusInfo, jisPartBoxInfos, jisMaintainInhouseLogisticStandardInfos)); } ///单条车辆状态全部类型计数器更新完成后标记其状态为已处理 stringBuilder.AppendLine("update [LES].[TT_BAS_VEHICLE_POINT_STATUS] set " + "[PROCESS_FLAG] = " + (int)ProcessFlagConstants.Processed + "," + "[MODIFY_DATE] = GETDATE()," + "[MODIFY_USER] = N'" + loginUser + "' where " + "[ID]= " + vehiclePointStatusInfo.Id + ";"); ///数据库语句执行 using (TransactionScope trans = new TransactionScope()) { CommonBLL.ExecuteNonQueryBySql(stringBuilder.ToString()); trans.Complete(); } } }
/// <summary> /// Handler /// </summary> public void Handler() { ///获取排序零件类中状态㉖为已启用的数据 List <JisPartBoxInfo> jisPartBoxInfos = new JisPartBoxBLL().GetList(" and [STATUS] =" + (int)BasicDataStatusConstants.Enable + "", string.Empty); if (jisPartBoxInfos.Count == 0) { return; } ///获取零件类对应的计数器 List <JisCounterInfo> jisCounterInfos = new JisCounterBLL().GetList("and [PART_BOX_FID] in ('" + string.Join("','", jisPartBoxInfos.Select(d => d.Fid).ToArray()) + "')", string.Empty); if (jisCounterInfos.Count == 0) { return; } ///对应的排序计数器日志 List <JisCounterLogInfo> jisCounterLogInfos = new JisCounterLogBLL().GetList("and [COUNTER_FID] in ('" + string.Join("','", jisCounterInfos.Select(d => d.Fid).ToArray()) + "')", string.Empty); if (jisCounterLogInfos.Count == 0) { return; } ///计数器日志对应的生产订单 List <PullOrdersInfo> pullOrdersInfos = new PullOrdersBLL().GetList("and [ORDER_NO] in ('" + string.Join("','", jisCounterLogInfos.Select(d => d.SourceData).ToArray()) + "')", string.Empty); if (pullOrdersInfos.Count == 0) { return; } ///对应的物料拉动信息 List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandardInfos = new MaintainInhouseLogisticStandardBLL().GetList("and [STATUS] =" + (int)BasicDataStatusConstants.Enable + "" + " and [INHOUSE_PART_CLASS] in ('" + string.Join("','", jisPartBoxInfos.Select(d => d.PartBoxCode).ToArray()) + "')" + " and [PART_NO] in ('" + string.Join("','", jisCounterLogInfos.Select(d => d.PartNo).ToArray()) + "')", string.Empty); if (maintainInhouseLogisticStandardInfos.Count == 0) { return; } foreach (JisPartBoxInfo jisPartBoxInfo in jisPartBoxInfos) { ///零件类对应的物料拉动信息 List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandards = maintainInhouseLogisticStandardInfos.Where(d => d.InhousePartClass == jisPartBoxInfo.PartBoxCode).ToList(); ///计数器 List <JisCounterInfo> jisCounters = new List <JisCounterInfo>(); ///获取状态为20.累计完成的排序计数器 jisCounters = jisCounterInfos.Where(d => d.Status == (int)JisCounterStatusConstants.AccumulativeCompletion && d.PartBoxFid == jisPartBoxInfo.Fid).ToList(); ///若此时未能成功获取到状态为20.累计完成的排序计数器时,需要获取状态为10.正在累计的排序计数器,判断其创建时间加上最大累积时间是否已超过当前时间 if (jisCounters.Count == 0) { jisCounters = jisCounterInfos.Where(d => d.Status == (int)JisCounterStatusConstants.Accumulating && d.PartBoxFid == jisPartBoxInfo.Fid && d.CreateDate.AddMinutes(jisPartBoxInfo.MaxAccumulativeTime.GetValueOrDefault()) > DateTime.Now).ToList(); } if (jisCounters.Count == 0) { continue; } ///若已超过则需要首先标记排序计数器状态为20.累计完成,之后的逻辑按部就班走 BLL.LES.CommonBLL.ExecuteNonQueryBySql(@"update[LES].[TT_MPM_JIS_COUNTER] set [STATUS]=" + (int)JisCounterStatusConstants.AccumulativeCompletion + ",[MODIFY_DATE] = getdate(),[MODIFY_USER] = '" + loginUser + "' where [ID] in (" + string.Join(",", jisCounters.Select(d => d.Id).ToArray()) + ");"); ///根据计数器生成拉动单 foreach (JisCounterInfo jisCounterInfo in jisCounters) { ///sql StringBuilder stringBuilder = new StringBuilder(); ///对应的排序计数器日志 List <JisCounterLogInfo> jisCounterLogs = jisCounterLogInfos.Where(d => d.CounterFid == jisCounterInfo.Fid).ToList(); if (jisCounterLogs.Count == 0) { continue; } ///计数器日志物料对应的物料拉动信息 List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogistics = (from maintainInhouseLogisticStandard in maintainInhouseLogisticStandards join jisCounterLog in jisCounterLogs on maintainInhouseLogisticStandard.PartNo equals jisCounterLog.PartNo select maintainInhouseLogisticStandard).ToList(); if (maintainInhouseLogistics.Count == 0) { continue; } switch (jisPartBoxInfo.JisPullMode.GetValueOrDefault()) { ///排序拉动 case (int)JisPullModeConstants.JisPull: stringBuilder.AppendFormat(JisPull(jisPartBoxInfo, jisCounterInfo, jisCounterLogs, maintainInhouseLogistics, pullOrdersInfos, true)); break; ///物料成套拉动 case (int)JisPullModeConstants.CompletePull: stringBuilder.AppendFormat(JisPull(jisPartBoxInfo, jisCounterInfo, jisCounterLogs, maintainInhouseLogistics, pullOrdersInfos, false)); break; default: continue; } ///数据库执行语句 if (stringBuilder.Length > 0) { stringBuilder.AppendFormat(@"update[LES].[TT_MPM_JIS_COUNTER] set [STATUS]=" + (int)JisCounterStatusConstants.GeneratedDocuments + ",[MODIFY_DATE] = getdate(),[MODIFY_USER] = '" + loginUser + "' where [ID] = " + jisCounterInfo.Id + "; "); using (TransactionScope trans = new TransactionScope()) { BLL.LES.CommonBLL.ExecuteNonQueryBySql(stringBuilder.ToString()); trans.Complete(); } } } } }