示例#1
0
        public override void GetOutStockSlotList(ref List <T_OutStockCreateInfo> modelList)
        {
            PickRule.T_PickRule_DB pickDB = new PickRule.T_PickRule_DB();
            //分配规则
            List <PickRule.T_PickRuleInfo> pickRuleList = pickDB.GetPearRuleListByPage(3);

            Object obj = WMS.Factory.ServiceFactory.CreateObject(pickRuleList[0].ParameterIDN);

            OutStockCreate_SplitContext <T_OutStockCreateInfo, T_OutStockCreateInfo> context = new OutStockCreate_SplitContext <T_OutStockCreateInfo, T_OutStockCreateInfo>
                                                                                                   ((OutStockCreate_SplitBaseRule <T_OutStockCreateInfo, T_OutStockCreateInfo>)obj);

            context.GetOutStockCreateAutoSlotList(ref modelList);
        }
        //启用拣货拆分规则
        public override bool GetOutStockCreateList(ref List <T_OutStockCreateInfo> lstBaseModel, ref string ErrorMsg)
        {
            OutStockCreate_ModelData    modelData        = new OutStockCreate_ModelData();
            List <T_OutStockCreateInfo> newModelList     = new List <T_OutStockCreateInfo>();
            List <T_OutStockCreateInfo> itemList         = new List <T_OutStockCreateInfo>();
            List <T_PickRuleInfo>       pickRuleMainType = new List <T_PickRuleInfo>();//具体的物料类别规则集合

            PickRule.T_PickRule_DB pickDB = new PickRule.T_PickRule_DB();
            //拣货拆分规则
            List <PickRule.T_PickRuleInfo> pickRuleSplitList = pickDB.GetPearRuleListByPage(RuleAll_Config.RuleTypeSplit).OrderBy(t => t.SortLevel).ToList();

            if (pickRuleSplitList == null || pickRuleSplitList.Count == 0)
            {
                ErrorMsg = "拣货拆分规则未配置";
                return(false);
            }


            //获取生单物料库存
            Stock.T_Stock_DB         stockDB   = new Stock.T_Stock_DB();
            List <Stock.T_StockInfo> stockList = new List <Stock.T_StockInfo>();

            //汇总本次生单的物料
            List <T_OutStockCreateInfo> lstMgp = MaterialGroupBy(lstBaseModel);

            //string strMaterialXml = XmlUtil.Serializer(typeof(List<T_OutStockCreateInfo>), lstMgp);

            stockList = stockDB.GetCanStockListByMaterialNoIDToSql(lstMgp);
            //if (stockDB.GetCanStockListByMaterialNoID(strMaterialXml, ref stockList, ref ErrorMsg) == false)
            //{
            //    return false;
            //}

            //根据传入规则类型判断new对象
            RuleAll.t_RuleAll_DB         ruleDB   = new RuleAll.t_RuleAll_DB();
            List <RuleAll.T_RuleAllInfo> ruleList = ruleDB.GetRuleListByPage(RuleAll_Config.OutStockSumQty);
            int isEnable = ruleList == null ? 0 : ruleList[0].IsEnable.ToInt32();//1-不启用 2-启用

            //启用单据相同物料数量汇总
            if (isEnable == 2)
            {
                lstBaseModel = OutStockSameMaterialNoSumQty(lstBaseModel);
            }


            //把要生单的数据根据物料类别分组
            var mainTypeCodeList = from t in lstBaseModel group t by new { t1 = t.MainTypeCode } into m
                select new { MainTypeCode = m.Key.t1 };

            foreach (var item in mainTypeCodeList)
            {
                //获取具体的物料类别规则
                pickRuleMainType = pickRuleSplitList.FindAll(t => t.MaterialClassCode == item.MainTypeCode).OrderBy(t => t.SortLevel).ToList();

                foreach (var item1 in pickRuleMainType)
                {
                    //循环开始,默认按照优先级升序
                    //如果第一个优先级是零散区,先按照零散区拆分
                    //循环第二个优先级,假设是楼层,根据零散区的结果按照楼层拆分
                    //循环结束

                    //循环开始,默认按照优先级升序
                    //如果第一个优先级是楼层,先按照楼层拆分
                    //循环第二个优先级,假设是零散区,根据楼层的结果按照零散区拆分
                    //循环结束
                    Object obj = WMS.Factory.ServiceFactory.CreateObject(item1.ParameterIDN);

                    OutStockCreate_SplitContext <T_OutStockCreateInfo, Stock.T_StockInfo> context
                        = new OutStockCreate_SplitContext <T_OutStockCreateInfo, Stock.T_StockInfo>
                              ((OutStockCreate_SplitBaseRule <T_OutStockCreateInfo, Stock.T_StockInfo>)obj);
                    context.GetOutStockCreateSplitList(ref lstBaseModel, stockList);
                }
            }

            lstBaseModel = modelData.GetNewOutStockModelList(lstBaseModel);

            return(true);
        }