private void gridView6_DoubleClick(object sender, EventArgs e)
        {
            if (jc_cast_plan.Where(a => a.C_ID == lbl_id.Text).ToList().Count == 0)
            {
                return;
            }
            Point ms = Control.MousePosition;

            this.dplanl_tj.Visibility    = DevExpress.XtraBars.Docking.DockVisibility.Visible;
            this.dplanl_tj.Dock          = DevExpress.XtraBars.Docking.DockingStyle.Float;
            this.dplanl_tj.FloatLocation = new System.Drawing.Point(ms.X, ms.Y);
            Mod_TSP_CAST_PLAN mod = jc_cast_plan.Where(a => a.C_ID == lbl_id.Text).ToList()[0];

            this.txt_tjsj.Text      = mod.N_PRODUCE_TIME.ToString();
            this.txt_tj_remark.Text = mod.C_TJ_REMARK;
            this.txt_fzh.Text       = mod.N_GROUP.ToString();
        }
        /// <summary>
        /// 浇次计划焦点行改变后加载对应的炉次计划
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView6_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
        {
            try
            {
                int selectedHandle;
                selectedHandle = this.gridView6.GetSelectedRows()[0];

                if (selectedHandle >= 0)
                {
                    string c_cid = this.gridView6.GetRowCellValue(selectedHandle, "C_ID").ToString();
                    lbl_id.Text = c_cid;
                    BindLcLsbGrid(c_cid);//加载炉次计划顺序
                    Mod_TSP_CAST_PLAN mod = bll_cast_plan.GetModel(c_cid);
                    minsort = bll_plan_sms.GetMaxSort(Convert.ToInt32(mod.N_SORT), mod.C_CCM_ID);
                }
            }
            catch (Exception)
            {
                lbl_id.Text = "";
                BindLcLsbGrid("");//加载炉次计划顺序
            }
        }
        /// <summary>
        /// 完成浇次计划
        /// </summary>
        public void btnFinishOrder(string C_JC_ID)
        {
            Mod_TSP_CAST_PLAN modjc = bll_cast_plan.GetModel(C_JC_ID);

            List <Mod_TSP_PLAN_SMS> lstlc = bll_plan_sms.GetModelListByJcID(C_JC_ID);
            int a = lstlc.Count;

            if (a > 0)
            {
                int res = 0;
                for (int i = 0; i < a; i++)
                {
                    if (lstlc[i].N_CREAT_PLAN == 4)
                    {
                        res = res + 1;
                    }
                }
                if (a == res)
                {
                    modjc.N_STATUS = 3;
                    bll_cast_plan.Update(modjc);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Seave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(btnEdit_STL.Text.Trim()))
            {
                MessageBox.Show("请选择钢种!");
                return;
            }
            if (string.IsNullOrEmpty(icbo_lz3.Text.Trim()))
            {
                MessageBox.Show("请选择连铸!");
                return;
            }
            try
            {
                Mod_TSP_CAST_PLAN mod       = new Mod_TSP_CAST_PLAN();
                DataTable         dt_Max    = bll_cast_plan.GetList_Max(icbo_lz3.EditValue.ToString()).Tables[0];
                Mod_TB_MATRL_MAIN mod_matrl = bll_matrl.GetModel(str_ID);
                mod.C_CCM_ID   = icbo_lz3.EditValue.ToString();
                mod.C_CCM_CODE = icbo_lz3.Text.Trim();
                int group_max = 0;
                int sort_max  = 0;
                if (dt_Max.Rows[0]["GROUP_MAX"].ToString() == "")
                {
                    group_max = 1;
                }
                else
                {
                    group_max = (Convert.ToInt32(dt_Max.Rows[0]["GROUP_MAX"].ToString()) + 1);
                }
                if (dt_Max.Rows[0]["SORT_MAX"].ToString() == "")
                {
                    sort_max = 1;
                }
                else
                {
                    sort_max = (Convert.ToInt32(dt_Max.Rows[0]["SORT_MAX"].ToString()) + 1);
                }
                mod.C_ID        = System.Guid.NewGuid().ToString();
                mod.N_GROUP     = group_max;
                mod.N_TOTAL_WGT = Convert.ToInt32(txt_ZJCLS.Text.Trim());
                mod.N_ZJCLS     = Convert.ToInt32(txt_ZJCLS.Text.Trim());
                mod.N_ZJCLZL    = Convert.ToInt32(txt_ZJCLS.Text.Trim()) * 77;
                mod.N_MLZL      = 77;
                mod.N_SORT      = sort_max;
                mod.C_STL_GRD   = btnEdit_STL.Text.Trim();
                mod.N_JSCN      = 144;
                DataTable dt_SWL = bll_endtoend.GetSWLSteel(btnEdit_STL.Text.Trim(), txt_STD.Text.Trim(), "");
                if (dt_SWL.Rows.Count != 0)
                {
                    mod.C_BY1 = dt_SWL.Rows[0]["C_B_E_STOVE_STEEL"].ToString() + "`" + dt_SWL.Rows[0]["C_BORDER_STD_CODE"].ToString();
                }
                mod.C_BY2      = "";
                mod.C_BY3      = "";
                mod.C_STD_CODE = txt_STD.Text.Trim();
                if (icbo_lz3.Text == "5#铸机" || icbo_lz3.Text == "7#铸机")
                {
                    mod.C_SLAB_TYPE = "大方坯";
                }
                else
                {
                    mod.C_SLAB_TYPE = "小方坯";
                }

                mod.C_STL_GRD_TYPE = mod_matrl.C_PROD_KIND;
                mod.C_PROD_NAME    = mod_matrl.C_PROD_NAME;
                mod.C_REMARK       = btnEdit_STL.Text.Trim() + "`" + txt_STD.Text.Trim();

                DataTable dtgylx = bll_gylx.GetGYLX(mod.C_STL_GRD, mod.C_STD_CODE, "");
                if (dtgylx.Rows.Count > 0)
                {
                    if (dtgylx.Rows[0]["C_ROUTE_DESC"].ToString().Contains("RH"))
                    {
                        mod.C_RH = "Y";
                    }
                    else
                    {
                        mod.C_RH = "N";
                    }

                    if (dtgylx.Rows[0]["C_ROUTE_DESC"].ToString().Contains("XM"))
                    {
                        mod.C_XM = "Y";
                    }
                    else
                    {
                        mod.C_XM = "N";
                    }
                    if (dtgylx.Rows[0]["C_ROUTE_DESC"].ToString().Contains("DHL"))
                    {
                        mod.C_DFP_HL = "Y";
                    }
                    else
                    {
                        mod.C_DFP_HL = "N";
                    }
                    if (dtgylx.Rows[0]["C_ROUTE_DESC"].ToString().Contains("HL"))
                    {
                        mod.C_HL = "Y";
                    }
                    else
                    {
                        mod.C_HL = "N";
                    }
                    if (dtgylx.Rows[0]["C_ROUTE_DESC"].ToString().Contains("TL"))
                    {
                        mod.C_TL = "Y";
                    }
                    else
                    {
                        mod.C_TL = "N";
                    }
                }
                if (bll_cast_plan.Add(mod))
                {
                    for (int l = 0; l < Convert.ToInt32(txt_ZJCLS.Text.Trim()); l++)
                    {
                        Mod_TSP_PLAN_SMS mod_add_lc2 = new Mod_TSP_PLAN_SMS();
                        mod_add_lc2.C_ID          = System.Guid.NewGuid().ToString();
                        mod_add_lc2.C_FK          = mod.C_ID;
                        mod_add_lc2.N_SORT        = l;
                        mod_add_lc2.C_STATE       = "1";
                        mod_add_lc2.C_STL_GRD     = mod.C_STL_GRD;
                        mod_add_lc2.C_STD_CODE    = mod.C_STD_CODE;
                        mod_add_lc2.C_CCM_ID      = mod.C_CCM_ID;
                        mod_add_lc2.C_CCM_DESC    = mod.C_CCM_CODE;
                        mod_add_lc2.N_SLAB_WGT    = mod.N_MLZL;
                        mod_add_lc2.C_SLAB_SIZE   = mod_matrl.C_SLAB_SIZE;
                        mod_add_lc2.C_SLAB_LENGTH = mod_matrl.N_LTH.ToString();
                        mod_add_lc2.N_JC_SORT     = mod.N_SORT;
                        mod_add_lc2.C_BY1         = mod.C_BY1;
                        mod_add_lc2.C_ROUTE       = txt_GYLX.Text.Trim();
                        mod_add_lc2.C_FREE1       = txt_ZYX1.Text.Trim();
                        mod_add_lc2.C_FREE2       = txt_ZYX2.Text.Trim();
                        mod_add_lc2.C_RH          = mod.C_RH;
                        mod_add_lc2.C_DFP_HL      = mod.C_DFP_HL;
                        mod_add_lc2.C_HL          = mod.C_HL;
                        mod_add_lc2.C_XM          = mod.C_XM;
                        mod_add_lc2.C_TL          = mod.C_TL;
                        mod_add_lc2.C_BY2         = "手动添加";
                        bll_Plan_SMS.Add(mod_add_lc2);
                    }
                }

                MessageBox.Show("添加成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 调整浇次计划连铸信息
        /// </summary>
        /// <param name="c_id">浇次计划主键</param>
        /// <param name="c_ccm_id">调整后连铸主键</param>
        /// <param name="c_remark">调整说明</param>
        public string ChangeCCM(string c_id, string c_ccm_id, string c_remark)
        {
            string                  c_ccm_desc = bll_sta.GetModel(c_ccm_id).C_STA_CODE; //连铸代码
            Mod_TSP_CAST_PLAN       mod        = bll_cast_plan.GetModel(c_id);
            List <Mod_TSP_PLAN_SMS> lst_sms    = new List <Mod_TSP_PLAN_SMS>();         //新浇次的炉次计划

            if (mod.N_MLZL > 50 && mod.N_MLZL < 60)                                     //不锈钢
            {
                return("不锈钢计划只能在6#连铸生产!");
            }
            if (mod.C_RH == "Y")
            {
                return("过真空的浇次计划不能调整!");
            }
            decimal n_mlzl_e = 0;//调整后的炉次重量

            if (c_ccm_id == "77B9FDA79B884D07AA2B3601D1DA11A2")
            {
                n_mlzl_e = 77;
            }
            else
            {
                n_mlzl_e = 47;
            }
            Mod_TPB_SCLX modlx = bll_lx.GetModel(c_ccm_id);

            #region 添加新的浇次计划
            Mod_TSP_CAST_PLAN mod_cast = new Mod_TSP_CAST_PLAN();
            mod_cast                = mod;
            mod_cast.C_ID           = System.Guid.NewGuid().ToString();
            mod_cast.N_SORT         = bll_cast_plan.Max_jc_sort(c_ccm_id) + 1;
            mod_cast.C_CCM_ID       = c_ccm_id;
            mod_cast.C_CCM_CODE     = c_ccm_desc;
            mod_cast.N_PRODUCE_TIME = 0;
            mod_cast.N_MLZL         = n_mlzl_e;

            mod_cast.C_TZ_REMARK = c_remark;
            #endregion
            int lsxh = bll_plan_sms.GetMaxSort(c_ccm_id);
            int ypls = 0;
            var lcjh = bll_plan_sms.GetModelListByJcID(c_id); //当前浇次的炉次计划
                                                              //调整有计划的连铸计划
            var lst_lc = bll_plan_sms.GetModelListByJcID(c_id).Where(ba => ba.C_STATE == "0" && ba.N_CREAT_PLAN == 1).GroupBy(ca => new { ca.C_STL_GRD, ca.C_STD_CODE }).Select(ca => new { n_wgt = ca.Sum(p => p.N_SLAB_WGT), ca.First().C_STL_GRD, ca.First().C_STD_CODE }).ToList();
            if (lst_lc.Count > 0)
            {
                for (int i = 0; i < lst_lc.Count; i++)
                {
                    Mod_TSP_PLAN_SMS mod_sms = new Mod_TSP_PLAN_SMS();
                    decimal          n_wgt   = (decimal)lst_lc[i].n_wgt;          //
                    ypls                   = (int)Math.Ceiling(n_wgt / n_mlzl_e); //应排炉数
                    mod_sms                = lcjh[0];
                    mod_sms.N_SLAB_WGT     = n_mlzl_e;                            //新的每炉重量
                    mod_sms.C_STATE        = "0";
                    mod_sms.C_CCM_ID       = c_ccm_id;
                    mod_sms.C_CCM_DESC     = c_ccm_desc;
                    mod_sms.N_JC_SORT      = mod_cast.N_SORT;
                    mod_sms.C_FK           = mod_cast.C_ID;
                    mod_sms.C_LF_ID        = modlx.C_LF;
                    mod_sms.C_RH_ID        = modlx.C_RH;
                    mod_sms.C_ZL_ID        = modlx.C_ZL;
                    mod_sms.N_PRODUCE_TIME = 0;
                    mod_sms.N_USE_WGT      = n_mlzl_e;
                    List <Mod_TPB_SLAB_CAPACITY> lstjscn = bll_jscn.GetListByCCM(mod_sms.C_STL_GRD, mod_sms.C_STD_CODE, mod_sms.C_CCM_ID);
                    if (lstjscn.Count > 0)
                    {
                        mod_sms.N_JSCN = lstjscn[0].N_CAPACITY;
                    }
                    if (mod_sms.N_JSCN == 0)
                    {
                        mod_sms.N_JSCN = mod_sms.C_CCM_DESC == "5#CC" ? 114 : 88;
                    }
                    mod_cast.N_JSCN     = mod_sms.N_JSCN;            //?机时产量
                    mod_sms.N_PROD_TIME = n_mlzl_e / mod_sms.N_JSCN; //?生产时间
                    for (int j = 0; j < ypls; j++)
                    {
                        mod_sms.C_ID   = System.Guid.NewGuid().ToString();
                        mod_sms.N_SORT = lsxh + 1;
                        lsxh           = lsxh + 1;
                        bll_plan_sms.Add(mod_sms);
                    }
                }
            }
            //调整非计划的连铸计划
            var lst_lc_fjh = bll_plan_sms.GetModelListByJcID(c_id).Where(ba => ba.C_STATE == "1" && ba.N_CREAT_PLAN == 1).GroupBy(ca => new { ca.C_STL_GRD, ca.C_STD_CODE }).Select(ca => new { n_wgt = ca.Sum(p => p.N_SLAB_WGT), ca.First().C_STL_GRD, ca.First().C_STD_CODE }).ToList();
            if (lst_lc_fjh.Count > 0)
            {
                for (int i = 0; i < lst_lc_fjh.Count; i++)
                {
                    Mod_TSP_PLAN_SMS mod_sms = new Mod_TSP_PLAN_SMS();
                    decimal          n_wgt   = (decimal)lst_lc_fjh[i].n_wgt;      //
                    ypls                   = (int)Math.Ceiling(n_wgt / n_mlzl_e); //应排炉数
                    mod_sms                = lcjh[0];
                    mod_sms.N_SLAB_WGT     = n_mlzl_e;                            //新的每炉重量
                    mod_sms.C_STATE        = "1";
                    mod_sms.C_CCM_ID       = c_ccm_id;
                    mod_sms.C_CCM_DESC     = c_ccm_desc;
                    mod_sms.N_JC_SORT      = mod_cast.N_SORT;
                    mod_sms.C_FK           = mod_cast.C_ID;
                    mod_sms.C_LF_ID        = modlx.C_LF;
                    mod_sms.C_RH_ID        = modlx.C_RH;
                    mod_sms.C_ZL_ID        = modlx.C_ZL;
                    mod_sms.N_PRODUCE_TIME = 0;
                    mod_sms.N_USE_WGT      = n_mlzl_e;
                    List <Mod_TPB_SLAB_CAPACITY> lstjscn = bll_jscn.GetListByCCM(mod_sms.C_STL_GRD, mod_sms.C_STD_CODE, mod_sms.C_CCM_ID);
                    if (lstjscn.Count > 0)
                    {
                        mod_sms.N_JSCN = lstjscn[0].N_CAPACITY;
                    }
                    if (mod_sms.N_JSCN == 0)
                    {
                        mod_sms.N_JSCN = mod_sms.C_CCM_DESC == "5#CC" ? 114 : 88;
                    }
                    mod_cast.N_JSCN     = mod_sms.N_JSCN;            //?机时产量
                    mod_sms.N_PROD_TIME = n_mlzl_e / mod_sms.N_JSCN; //?生产时间
                    for (int j = 0; j < ypls; j++)
                    {
                        mod_sms.C_ID   = System.Guid.NewGuid().ToString();
                        mod_sms.N_SORT = lsxh + 1;
                        lsxh           = lsxh + 1;
                        bll_plan_sms.Add(mod_sms);
                    }
                }
            }

            bll_cast_plan.Add(mod_cast);

            int yls = lcjh.Where(a => a.N_CREAT_PLAN > 1).ToList().Count;//已排产炉数
            bll_plan_sms.DeleteByjcid(c_id);
            if (yls == 0)
            {
                bll_cast_plan.Delete(c_id);//删除当前浇次计划
            }
            else
            {
                bll_cast_plan.Update(c_id, yls);//修改当前浇次计划
            }


            return("调整连铸成功!");
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Mod_TSP_CAST_PLAN model)
 {
     return(dal.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Mod_TSP_CAST_PLAN model)
 {
     return(dal.Add(model));
 }