Exemple #1
0
        //public Context(OutStockCreateRule<TBase_Model> outStockCreateRule)
        //{
        //    this.outStockCreateRule = outStockCreateRule;
        //}

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

            switch (type)
            {
            case RuleAll_Config.OutStockSplitItem:     //拣货拆分机制
                if (isEnable == RuleAll_Config.RuleAllUnEnable)
                {
                    ruleAllCreate = (StrategeRuleAll <T>)(Object) new OutStockCreate_UnEnableRule();
                }
                else if (isEnable == RuleAll_Config.RuleAllEnable)
                {
                    ruleAllCreate = (StrategeRuleAll <T>)(Object) new OutStockCreate_EnableRule();
                }

                break;

            case RuleAll_Config.OutStockSlotItem:     //拣货分配机制
                if (isEnable == RuleAll_Config.RuleAllUnEnable)
                {
                    ruleAllCreate = (StrategeRuleAll <T>)(Object) new OutStockCreate_UnEnableSlotRule();
                }
                else if (isEnable == RuleAll_Config.RuleAllEnable)
                {
                    ruleAllCreate = (StrategeRuleAll <T>)(Object) new OutStockCreate_EnableSlotRule();
                }

                break;

            case RuleAll_Config.SerialItem:    //序列号启用
                if (isEnable == RuleAll_Config.RuleAllUnEnable)
                {
                    ruleAllCreate = (StrategeRuleAll <T>)(object) new Stock_SerialUnEnableRule();
                }
                else if (isEnable == RuleAll_Config.RuleAllEnable)
                {
                    ruleAllCreate = (StrategeRuleAll <T>)(object) new Stock_SerialEnableRule();
                }

                break;

            case RuleAll_Config.OutStockPickItem:    //拣货规则启用
                if (isEnable == RuleAll_Config.RuleAllUnEnable)
                {
                    ruleAllCreate = (StrategeRuleAll <T>)(object) new OutStockTask_UnEnablePickRule();
                }
                else if (isEnable == RuleAll_Config.RuleAllEnable)
                {
                    ruleAllCreate = (StrategeRuleAll <T>)(object) new OutStockTask_EnablePickRule();
                }
                break;

            default:
                ruleAllCreate = null;
                break;
            }
        }
Exemple #2
0
        protected override List <string> GetSaveModelListSql(UserModel user, List <T_OutStockCreateInfo> modelList)
        {
            RuleAll.t_RuleAll_DB         ruleDB   = new RuleAll.t_RuleAll_DB();
            List <RuleAll.T_RuleAllInfo> ruleList = ruleDB.GetRuleListByPage(4);

            if (ruleList[0].IsEnable == 1)//不启用拣货分配规则
            {
                //GetDisPickRuleModelList(modelList);//得到需要生单的数据
            }
            else if (ruleList[0].IsEnable == 2)              //启用拣货分配规则
            {
                return(CreateOutStockTask(user, modelList)); //得到需要生单的数据
            }

            return(CreateOutStockTask(user, modelList));



            #region 注释公司代码
            //string strSql = string.Empty;
            //int voucherID = 0;

            //string VoucherNoID = string.Empty;
            //string VoucherNo = string.Empty;
            //List<string> lstSql = new List<string>();

            //var groupByList = from t in modelList.Where(t => t.OKSelect == true)
            //                  group t by new { t1 = t.VoucherNo } into m
            //                  select new
            //                  {
            //                      VoucherNo = m.Key.t1,
            //                  };

            //foreach (var item in groupByList)
            //{
            //    voucherID = base.GetTableID("SEQ_TASK_ID");

            //    VoucherNoID = base.GetTableID("SEQ_TASK_NO").ToString();

            //    VoucherNo = "D" + System.DateTime.Now.ToString("yyyyMMdd") + VoucherNoID.PadLeft(4, '0');

            //    strSql = string.Format("insert into t_task (Id, Vouchertype, Tasktype, Taskno, Status,   Taskissued,  Createtime,   Creater,  Instockid, Erpvoucherno,  Plant, Plantname,  Taskissueduser,voucherno,supcuscode,supcusname,movetype,erpdocno)" +
            //             " select '{0}',a.Vouchertype,'2','{1}','1', Sysdate,Sysdate,'{2}',a.Id,a.Erpvoucherno,a.Plant,a.Plantname,'{3}',a.voucherno,a.customercode,a.customername,a.movetype,a.erpdocno  from t_Outstock a where a.VoucherNo = '{4}'",
            //             voucherID, VoucherNo, user.UserNo, user.UserNo, item.VoucherNo);

            //    lstSql.Add(strSql);

            //    strSql = string.Format("insert into t_Taskdetails (Id,  Materialno, Materialdesc, Taskqty,  Remainqty,  Linestatus,  HEADERID,  Rowno, Createtime,  Unit  ,  Wbselem , Unitname,  Creater, Salename,SaleCode,erpvoucherno,materialnoid,voucherno,erpdocno)" +
            //        "select SEQ_TASKDETAIL_ID.Nextval,a.Materialno,a.Materialdesc,a.Outstockqty,a.Outstockqty,'1',(select id from t_task where voucherno = '{0}'),a.Rowno,Sysdate,a.Unit,a.Wbselem,a.Unitname," +
            //        "'{1}' ,a.salename,a.salecode,a.erpvoucherno,(select id from t_material where t_Material.partno = a.partno),'{3}',a.erpdocno from t_Outstockdetail a where a.voucherno = '{2}'", item.VoucherNo, user.UserNo, item.VoucherNo, item.VoucherNo);


            //    lstSql.Add(strSql);

            //    strSql = "update t_Outstockdetail a set a.Materialnoid = (select id from t_material where t_material.partno = a.partno) where a.Voucherno = '" + item.VoucherNo + "'";
            //    lstSql.Add(strSql);

            //    strSql = string.Format("update t_Outstock a set a.Status = 2 where a.voucherno = '{0}'", item.VoucherNo);
            //    lstSql.Add(strSql);

            //}

            //return lstSql;
            #endregion
        }
        //启用拣货拆分规则
        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);
        }