Ejemplo n.º 1
0
        public override bool GetOutStockTaskDetailPickList(ref List <T_OutStockTaskDetailsInfo> modelList, ref string strError)
        {
            PickRule.T_PickRule_DB pickDB = new PickRule.T_PickRule_DB();
            //拣货拆分规则
            List <PickRule.T_PickRuleInfo> pickRuleSplitList = pickDB.GetPearRuleListByPage(RuleAll_Config.RuleTypePick).OrderBy(t => t.SortLevel).ToList();

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

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

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

            //var newModelList = from t in modelList
            //                   group t by new { t1 = t.MaterialNoID } into m
            //                   select new T_OutStockTaskDetailsInfo
            //                   {
            //                       MaterialNoID = m.Key.t1
            //                   };

            stockList = stockDB.GetCanStockListByMaterialNoIDToSql(lstMgp);



            //所有物料都没有库存,不拆分,直接返回
            if (stockList == null || stockList.Count == 0)
            {
                modelList.ForEach(t => t.RePickQty = 0);
                //strError = "获取订单明细所有物料可用库存为零!";
                //return false;
            }
            else
            {
                //int houseProp = modelList[0].HouseProp;
                //物料有库存,先按照整箱区和零拣区过滤
                //stockList = stockList.Where(t => t.HouseProp == houseProp).ToList();

                //if (stockList == null || stockList.Count == 0)
                //{
                //    modelList.ForEach(t => t.RePickQty = 0);
                //}
                //else
                //{
                //    //需要按照库位拆分库存
                //    modelList = CreateNewListByPickRuleAreaNo(modelList, stockList);
                //}
                modelList = CreateNewListByPickRuleAreaNo(modelList, stockList);
            }



            return(true);
        }
Ejemplo n.º 2
0
        public string GetZhList(string ErpVoucherNo, string Type)
        {
            BaseMessage_Model <List <U9Zh> > messageModel = new BaseMessage_Model <List <U9Zh> >();

            try
            {
                if (string.IsNullOrEmpty(ErpVoucherNo))
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = " 参数不能为空";
                    return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <U9Zh> > >(messageModel));
                }

                T_Material_Batch_DB _db      = new T_Material_Batch_DB();
                List <U9Zh>         BaseInfo = new List <U9Zh>();
                BaseInfo = _db.GetZhList(ErpVoucherNo, Type);
                BaseInfo.ForEach(item => item.VoucherType = 52);
                LogNet.LogInfo("----------------------------------------------------转换单获取单据信息" + BaseInfo);


                //string aaa = "[{\"detailBehind\":[{\"RowNo\":10,\"Type\":1,\"MaterialNo\":\"MR03070F0001-372\",\"MaterialName\":\"交流小电机\",\"MaterialDesc\":\"交流小电机\",\"Spec\":\"3RK15CC\",\"ErpWareHouseNo\":\"G060\",\"ErpWareHouseName\":\"东莞成品仓库\",\"Qty\":1.0,\"Unit\":\"Pcs\",\"BatchNo\":\"TraY-21030078\",\"FanHao\":null,\"RandomCode\":\"5WM3GACM\",\"Row\":10,\"subFlag\":0},{\"RowNo\":20,\"Type\":1,\"MaterialNo\":\"JR20003070F0001-413\",\"MaterialName\":\"小电机减速箱\",\"MaterialDesc\":\"小电机减速箱\",\"Spec\":\"3GN20K-B·10-78\",\"ErpWareHouseNo\":\"G060\",\"ErpWareHouseName\":\"东莞成品仓库\",\"Qty\":1.0,\"Unit\":\"Pcs\",\"BatchNo\":\"TraY-21030078\",\"FanHao\":null,\"RandomCode\":\"5WM3GACM\",\"Row\":10,\"subFlag\":0},{\"RowNo\":10,\"Type\":1,\"MaterialNo\":\"MR04022-0020\",\"MaterialName\":\"交流大电机\",\"MaterialDesc\":\"交流大电机\",\"Spec\":\"Y22-100S2-TG-C\",\"ErpWareHouseNo\":\"G060\",\"ErpWareHouseName\":\"东莞成品仓库\",\"Qty\":1.0,\"Unit\":\"Pcs\",\"BatchNo\":\"TraY-21030078\",\"FanHao\":null,\"RandomCode\":\"5WM3GACM\",\"Row\":20,\"subFlag\":0},{\"RowNo\":30,\"Type\":1,\"MaterialNo\":\"JR21002022F0001-003\",\"MaterialName\":\"大电机减速箱\",\"MaterialDesc\":\"大电机减速箱\",\"Spec\":\"CV22-200B·T1\",\"ErpWareHouseNo\":\"G060\",\"ErpWareHouseName\":\"东莞成品仓库\",\"Qty\":1.0,\"Unit\":\"Pcs\",\"BatchNo\":\"TraY-21030078\",\"FanHao\":null,\"RandomCode\":\"5WM3GACM\",\"Row\":20,\"subFlag\":0}],\"ErpVoucherNo\":\"TraY-21030078\",\"ErpVoucherType\":1001910300976711,\"ErpVoucherTypeName\":\"料品形态转换\",\"CreateTime\":\"2021-03-26\",\"StrongHoldCode\":\"0300\",\"StrongHoldName\":\"营销中心\",\"CustomerNo\":\"\",\"CustomerName\":\"\",\"RowNo\":0,\"Type\":0,\"MaterialNo\":null,\"MaterialName\":null,\"MaterialDesc\":null,\"Spec\":null,\"ErpWareHouseNo\":null,\"ErpWareHouseName\":null,\"Qty\":0.0,\"Unit\":null,\"detail\":[{\"RowNo\":10,\"Type\":0,\"MaterialNo\":\"JMF1902-8684\",\"MaterialName\":\"小电机减速电机\",\"MaterialDesc\":\"小电机减速电机\",\"Spec\":\"3RK15CC/3GN20K-B·10-78\",\"ErpWareHouseNo\":\"G060\",\"ErpWareHouseName\":\"东莞成品仓库\",\"Qty\":1.0,\"Unit\":\"Pcs\",\"BatchNo\":null,\"FanHao\":null,\"RandomCode\":null,\"Row\":10,\"subFlag\":0},{\"RowNo\":20,\"Type\":0,\"MaterialNo\":\"JMF1902-1560\",\"MaterialName\":\"大电机减速电机\",\"MaterialDesc\":\"大电机减速电机\",\"Spec\":\"Y22-100S2-TG-C/CV22-200B·T1\",\"ErpWareHouseNo\":\"G060\",\"ErpWareHouseName\":\"东莞成品仓库\",\"Qty\":1.0,\"Unit\":\"Pcs\",\"BatchNo\":null,\"FanHao\":null,\"RandomCode\":null,\"Row\":20,\"subFlag\":0}],\"guid\":null,\"PostUser\":null,\"batchno\":null,\"FanHao\":null,\"RandomCode\":null,\"Row\":0}]";
                //BaseInfo = JsonConvert.DeserializeObject<List<U9Zh>>(aaa);

                if (BaseInfo == null || BaseInfo.Count == 0)
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "获取失败";
                    return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <U9Zh> > >(messageModel));
                }
                else
                {
                    //获取生单物料库存
                    Stock.T_Stock_DB         stockDB   = new Stock.T_Stock_DB();
                    List <Stock.T_StockInfo> stockList = new List <Stock.T_StockInfo>();
                    //汇总本次生单的物料
                    var newModelList = from t in BaseInfo[0].detail
                                       group t by new { t1 = t.MaterialNo } into m
                        select new T_OutStockTaskDetailsInfo
                    {
                        MaterialNo = m.Key.t1
                    };
                    List <T_OutStockTaskDetailsInfo> newModelListret = newModelList.ToList();
                    newModelListret.ForEach(item => { item.StrongHoldCode = BaseInfo[0].StrongHoldCode; });
                    stockList = stockDB.GetCanStockListByMaterialNoIDToSql1(newModelListret);
                    //所有物料都没有库存,不拆分,直接返回
                    if (stockList != null && stockList.Count > 0)
                    {
                        List <T_OutStockTaskDetailsInfo> NewModelList = new List <T_OutStockTaskDetailsInfo>();

                        List <T_StockInfo> stockModelListSum = new List <T_StockInfo>();
                        string             strAreaNo         = string.Empty;

                        foreach (var item in BaseInfo[0].detail)
                        {
                            List <T_StockInfo> stockModelList = new List <T_StockInfo>();
                            //查找物料可分配库存
                            if (stockModelList.Count == 0 || stockModelList == null)
                            {
                                stockModelList = stockList.FindAll(t => t.MaterialNo == item.MaterialNo && t.WarehouseNo == item.ErpWareHouseNo && t.Qty > 0).OrderBy(t => t.BatchNo).OrderBy(t => t.SortArea).ToList();
                            }
                            var ModelListSum = from t in stockModelList
                                               group t by new
                            {
                                t1 = t.MaterialNo,
                                t2 = t.AreaNo,
                                t3 = t.StrongHoldCode
                                     //t4 = t.StrongHoldName,
                                     //t5 = t.CompanyCode,
                                     //t6 = t.BatchNo,
                                     //t7 = t.EDate
                            } into m
                                select new T_StockInfo
                            {
                                MaterialNo     = m.Key.t1,
                                AreaNo         = m.Key.t2,
                                StrongHoldCode = m.Key.t3,
                                //StrongHoldName = m.Key.t4,
                                //CompanyCode = m.Key.t5,
                                //BatchNo = m.Key.t6,
                                //EDate = m.Key.t7,
                                Qty = m.Sum(p => p.Qty),
                                //FloorType = m.FirstOrDefault().FloorType,
                                SortArea = m.FirstOrDefault().SortArea
                            };
                            stockModelListSum = ModelListSum.ToList();
                            if (stockModelListSum != null && stockModelListSum.Count > 0)
                            {
                                strAreaNo = string.Empty;
                                foreach (var itemArea in stockModelListSum)
                                {
                                    strAreaNo += itemArea.AreaNo + "|";
                                }
                                item.AreaNo = strAreaNo.TrimEnd('|');
                            }
                        }
                    }


                    messageModel.HeaderStatus = "S";
                    messageModel.ModelJson    = BaseInfo;
                    return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <U9Zh> > >(messageModel));
                }
            }
            catch (Exception ex)
            {
                messageModel.HeaderStatus = "E";
                messageModel.Message      = ex.Message;
                return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <U9Zh> > >(messageModel));
            }
        }
Ejemplo n.º 3
0
        //启用拣货拆分规则
        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);
        }