コード例 #1
0
        /// <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();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Handler
        /// </summary>
        public void Handler()
        {
            ///获取发单状态⑪为10未发单,且发单时间⑨已小于等于当前时间的时间窗窗口时间数据
            ///按发单时间⑨从早到晚进行排序,若发单时间⑨相同的情况下按ID排序,如果其中有相同零件类的多条窗口时间数据则以发单时间⑨最晚的一条作为有效数据
            List <TwdWindowTimeInfo> twdWindowTimeInfos = new TwdWindowTimeBLL().GetList("" +
                                                                                         "[SEND_TIME_STATUS] = " + (int)SendTimeStatusConstants.NoSend + " and " +
                                                                                         "[SEND_TIME] <= GETDATE() and " +
                                                                                         "[SEND_TIME] = (select max([SEND_TIME]) from [LES].[TT_MPM_TWD_WINDOW_TIME] a with(nolock) " +
                                                                                         "where [LES].[TT_MPM_TWD_WINDOW_TIME].[PART_BOX_FID] = a.[PART_BOX_FID])", "[ID]");

            if (twdWindowTimeInfos.Count == 0)
            {
                return;
            }
            ///根据窗口时间中的零件类外键①获取时间窗零件类、同时获取对应的物料拉动信息、注意此处的数据都需要为已启用状态
            List <TwdPartBoxInfo> twdPartBoxInfos = new TwdPartBoxBLL().GetList("" +
                                                                                "[STATUS] =" + (int)BasicDataStatusConstants.Enable + " and " +
                                                                                "[FID] in ('" + string.Join("','", twdWindowTimeInfos.Select(d => d.PartBoxFid.GetValueOrDefault()).ToArray()) + "')", string.Empty);

            if (twdPartBoxInfos.Count == 0)
            {
                return;
            }
            ///物料拉动信息
            List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandardInfos = new MaintainInhouseLogisticStandardBLL().GetList("" +
                                                                                                                                               "[STATUS] =" + (int)BasicDataStatusConstants.Enable + " and " +
                                                                                                                                               "[INHOUSE_PART_CLASS] in ('" + string.Join("','", twdPartBoxInfos.Select(d => d.PartBoxCode).ToArray()) + "') and " +
                                                                                                                                               "[INHOUSE_SYSTEM_MODE] = N'" + (int)PullModeConstants.Twd + "'", string.Empty);

            if (maintainInhouseLogisticStandardInfos.Count == 0)
            {
                return;
            }
            ///供应商信息
            List <string> supplierNums = twdPartBoxInfos.Where(d => !string.IsNullOrEmpty(d.SupplierNum)).Select(d => d.SupplierNum).ToList();

            supplierNums.AddRange(maintainInhouseLogisticStandardInfos.Where(d => !string.IsNullOrEmpty(d.SupplierNum)).Select(d => d.SupplierNum).ToList());
            List <SupplierInfo> supplierInfos = new SupplierBLL().GetList("" +
                                                                          "[SUPPLIER_NUM] in ('" + string.Join("','", supplierNums.ToArray()) + "')", string.Empty);

            ///逐条进行处理
            foreach (TwdWindowTimeInfo twdWindowTimeInfo in twdWindowTimeInfos)
            {
                ///获取未发单时间窗对应的零件类
                TwdPartBoxInfo twdPartBoxInfo = twdPartBoxInfos.FirstOrDefault(d => d.Fid.GetValueOrDefault() == twdWindowTimeInfo.PartBoxFid.GetValueOrDefault());
                if (twdPartBoxInfo == null)
                {
                    continue;
                }
                ///获取零件类对应的物料拉动信息
                List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandards = maintainInhouseLogisticStandardInfos.Where(d => d.InhousePartClass == twdWindowTimeInfo.PartBoxCode).ToList();
                if (maintainInhouseLogisticStandards.Count == 0)
                {
                    continue;
                }
                ///根据已获得的物料拉动信息获取对应的计数器,此处可以直接过滤出其当前计数⑮大于零的数据
                List <TwdCounterInfo> twdCounterInfos = new TwdCounterBLL().GetList("" +
                                                                                    "[STATUS] =" + (int)BasicDataStatusConstants.Enable + " and " +
                                                                                    "[PART_PULL_FID] in ('" + string.Join("','", maintainInhouseLogisticStandards.Select(d => d.Fid).ToArray()) + "')  and " +
                                                                                    "isnull([CURRENT_QTY],0) > 0", string.Empty);
                if (twdCounterInfos.Count == 0)
                {
                    continue;
                }
                ///生成拉动单
                StringBuilder @string = new StringBuilder();
                @string.AppendLine(CreateTwdPullOrder(twdCounterInfos, twdPartBoxInfo, supplierInfos, twdWindowTimeInfo, maintainInhouseLogisticStandards));
                ///数据库语句执行
                using (TransactionScope trans = new TransactionScope())
                {
                    if (@string.Length > 0)
                    {
                        CommonBLL.ExecuteNonQueryBySql(@string.ToString());
                    }
                    trans.Complete();
                }
            }
        }