using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pms.UserEvent.Model
{
    public class FunMaterials
    {
        public static string funMaterials()
        {
            string materials = "";
            var listMaterialts = (from DataRow s in StationInformationDAL.GetList("").Tables[0].AsEnumerable()
                                  where s.Field<string>("Materials") != "0"
                                  select new { materials = s.Field<string>("Materials"), status = s.Field<int>("Status") }).ToDictionary(x => x.materials, x => x.status);

            foreach (var m in Variable.listNeedMaterial)
            {
                if (listMaterialts.ContainsKey(m))  //库位包含需要物料状态正确 就派车
                {
                    if (listMaterialts[m] == Global.StationFill)
                    {
                        materials = m;
                        break;
                    }
                }
            }
            return materials;
        }

        public static string funNoContainNeedMaterials()
        {
            string materials = "";
            Dictionary<string, int> listMaterialts = (from DataRow s in StationInformationDAL.GetList("").Tables[0].AsEnumerable()
                                                      where s.Field<string>("Materials") != "0"
                                                      select new { materials = s.Field<string>("Materials"), status = s.Field<int>("Status") }).ToDictionary(x => x.materials, x => x.status);

            foreach (var kw in listMaterialts)
            {
                if (!Variable.listNeedMaterial.Contains(kw.Key))  //库位包含需要物料状态正确 就派车
                {
                    if (listMaterialts[kw.Key] == Global.StationFill)
                    {
                        materials = kw.Key;
                        break;
                    }
                }
            }
            return materials;
        }
    }
}
