コード例 #1
0
ファイル: JFHunyang.cs プロジェクト: rcw0125/vehic
        public void jsdtgs1()
        {
            dtgs = 0;
            int fzcs = 0;
            //组抽样的
            DbEntityTable <cheshu> cheshucy = new DbEntityTable <cheshu>();

            cheshucy.LoadDataBySql("select SUPPLIERCODE as cj,MATCODE as wl,WPCODE as dd,COUNT(*) as num from QC_Sample_Veh where sample_mix_id=0 and sample_tbzd=1 and SampleState=@SampleState and WLLX='精粉' group by SUPPLIERCODE,MATCODE,WPCODE", SampleState.开始组批);
            foreach (var x in cheshucy)
            {
                dtgs = dtgs + x.num;
            }

            DbEntityTable <cheshu> cheshufl = new DbEntityTable <cheshu>();

            cheshufl.LoadDataBySql("select SUPPLIERCODE as cj,MATCODE as wl,WPCODE as dd,COUNT(*) as num from QC_Sample_Veh where sample_mix_id=0 and (sample_jy is null or sample_jy<>1) and sample_tbzd<>1 and SampleState=@SampleState and WLLX='精粉' group by SUPPLIERCODE,MATCODE,WPCODE", SampleState.开始组批);
            foreach (var x in cheshufl)
            {
                fzcs = 0;
                QC_Material matInfo = QC_Material.GetByCode(x.wl);
                if (matInfo != null)
                {
                    //  if (matInfo.InUse)
                    //  {

                    DbEntityTable <QC_MixRule> labrule = new DbEntityTable <QC_MixRule>();
                    labrule.LoadDataByWhere("MatNcId=@MatNcId and (CustCode=@CustCode or CustCode='' or CustCode is null) and VehNumber<=@VehNumber", matInfo.MatNcId, x.cj, x.num);
                    if (labrule.Count > 0)
                    {
                        if (labrule[0].PlanMixCount > 0)
                        {
                            fzcs = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(x.num) / labrule[0].PlanMixCount));
                        }
                    }
                    if (fzcs > 0)
                    {
                        dtgs = fzcs + dtgs;
                    }
                    else
                    {
                        dtgs = dtgs + Convert.ToInt32(Math.Ceiling(Convert.ToDouble(x.num) / matInfo.BatchNum));
                    }
                    //  }
                }
            }
        }
コード例 #2
0
ファイル: JFHunyang.cs プロジェクト: rcw0125/vehic
        public void zupi()
        {
            //按厂家,地点,物料分类
            int dtmax = 0;

            //组抽样的
            DbEntityTable <cheshu> cheshucy = new DbEntityTable <cheshu>();

            cheshucy.LoadDataBySql("select SUPPLIERCODE as cj,MATCODE as wl,WPCODE as dd  from QC_Sample_Veh where sample_mix_id=0 and sample_tbzd=1 and SampleState=@SampleState and WLLX='精粉'", SampleState.开始组批);
            foreach (var x in cheshucy)
            {
                dtmax = 1;
                zupiduoche(x.cj, x.wl, x.dd, dtmax, "抽样");
            }

            DbEntityTable <cheshu> cheshufl = new DbEntityTable <cheshu>();

            cheshufl.LoadDataBySql("select SUPPLIERCODE as cj,MATCODE as wl,WPCODE as dd,COUNT(*) as num from QC_Sample_Veh where sample_mix_id=0 and (sample_jy is null or sample_jy<>1) and sample_tbzd<>1 and SampleState=@SampleState and WLLX='精粉' group by SUPPLIERCODE,MATCODE,WPCODE ", SampleState.开始组批);

            foreach (var x in cheshufl)
            {
                //判定是否有车数比较多

                QC_Material matInfo = QC_Material.GetByCode(x.wl);
                if (matInfo != null)
                {
//                    if (matInfo.InUse)
//                  {
                    dtmax = matInfo.BatchNum;
                    DbEntityTable <QC_MixRule> labrule = new DbEntityTable <QC_MixRule>();
                    labrule.LoadDataByWhere("MatNcId=@MatNcId and (CustCode=@CustCode or CustCode='' or CustCode is null) and VehNumber<=@VehNumber", matInfo.MatNcId, x.cj, x.num);
                    if (labrule.Count > 0)
                    {
                        if (labrule[0].PlanMixCount > 0)
                        {
                            dtmax = labrule[0].PlanMixCount;
                        }
                    }

                    //                  }
                }
                zupiduoche(x.cj, x.wl, x.dd, dtmax, "正常样");
            }
        }
コード例 #3
0
ファイル: HJHeyang.cs プロジェクト: rcw0125/vehic
        private void 组批_Click(object sender, EventArgs e)
        {
            this.hjvehs.Save();

            if (MessageBox.Show("确实要组批吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                Dictionary <string, List <QC_Sample_Veh> > vehFenzu = new Dictionary <string, List <QC_Sample_Veh> >();
                vehFenzu.Clear();

                foreach (var veh in hjvehs)
                {
                    if (veh.zp)
                    {
                        string key = veh.MatPK + "_" + veh.SupplierCode;
                        if (vehFenzu.ContainsKey(key))
                        {
                            vehFenzu[key].Add(veh);
                        }
                        else
                        {
                            vehFenzu.Add(key, new List <QC_Sample_Veh>()
                            {
                                veh
                            });
                        }
                    }
                }

                foreach (var item in vehFenzu)
                {
                    int           xiaotongshu = item.Value.Count;
                    int           datongshu   = 1;
                    QC_Sample_Veh tempVeh     = item.Value[0];

                    QC_Material matInfo = QC_Material.GetByCode(tempVeh.MatCode);
                    if (matInfo != null)
                    {
                        if (xiaotongshu <= matInfo.BatchNum)
                        {
                            datongshu = 1;
                        }
                        else if (xiaotongshu % matInfo.BatchNum == 0)
                        {
                            datongshu = item.Value.Count / matInfo.BatchNum;
                        }
                        else if (xiaotongshu % matInfo.BatchNum != 0)
                        {
                            datongshu = item.Value.Count / matInfo.BatchNum + 1;
                        }
                    }



                    if (datongshu > xiaotongshu)
                    {
                        datongshu = xiaotongshu;
                    }

                    Dictionary <int, List <int> > fp = FenZu(xiaotongshu, datongshu);
                    foreach (var fpItem in fp)
                    {
                        List <QC_Sample_Veh> vehs = new List <QC_Sample_Veh>();
                        foreach (var xtHao in fpItem.Value)
                        {
                            QC_Sample_Veh tempVeh2 = item.Value[xtHao];

                            vehs.Add(tempVeh2);
                        }
                        if (vehs.Count > 0)
                        {
                            QC_Sample_Mix mix = new QC_Sample_Mix();
                            mix.WpCode        = "0083";
                            mix.MatCode       = vehs[0].MatCode;
                            mix.MatPK         = vehs[0].MatPK;
                            mix.Mix_Time      = DateTime.Now;
                            mix.FangTong_Time = DateTime.Now;
                            mix.ShouTong_Time = DateTime.Now;
                            mix.ShouTong_User = LocalInfo.Current.user.ID;
                            mix.FangTong_User = LocalInfo.Current.user.ID;
                            mix.MixCount      = vehs.Count;
                            mix.MixPlanCount  = vehs.Count;
                            mix.SupplierCode  = vehs[0].SupplierCode;
                            mix.MixUser       = LocalInfo.Current.user.ID;
                            mix.SampleState   = SampleState.组批完成;
                            mix.SampleType    = SampleType.普通样;
                            mix.WLLX          = vehs[0].WLLX;
                            mix.CardID        = Zhc.Data.DbContext.GetSeq("HB" + DateTime.Now.Date.ToString("yyyyMMdd"), 2);
                            mix.Save();
                            hjmixs.Add(mix);
                            foreach (var veh in vehs)
                            {
                                veh.Sample_Mix_ID = mix.Sample_Mix_ID;
                                veh.Mix_Time      = DateTime.Now;
                                veh.SampleState   = SampleState.组批完成;
                                veh.Save();
                            }
                            QC_Sample_Mix mixpb = new QC_Sample_Mix();
                            mixpb.MatCode         = vehs[0].MatCode;
                            mixpb.MatPK           = vehs[0].MatPK;
                            mixpb.WpCode          = "0083";
                            mixpb.WLLX            = vehs[0].WLLX;
                            mixpb.Mix_Time        = DateTime.Now;
                            mixpb.FangTong_Time   = DateTime.Now;
                            mixpb.ShouTong_Time   = DateTime.Now;
                            mixpb.ShouTong_User   = LocalInfo.Current.user.ID;
                            mixpb.FangTong_User   = LocalInfo.Current.user.ID;
                            mixpb.MixCount        = vehs.Count;
                            mixpb.MixPlanCount    = vehs.Count;
                            mixpb.SupplierCode    = vehs[0].SupplierCode;
                            mixpb.MixUser         = LocalInfo.Current.user.ID;
                            mixpb.CardID          = "PB" + mix.CardID.Remove(0, 2);
                            mixpb.MainSampleMixId = mix.Sample_Mix_ID;
                            mixpb.SampleType      = SampleType.破包样;
                            mixpb.SampleState     = SampleState.组批完成;
                            mixpb.Save();
                        }
                    }
                }

                PrintZupi();
            }
        }