Beispiel #1
0
        /// <summary>
        /// 数据更新
        /// </summary>
        /// <param name="newValue">更新后对象</param>
        /// <returns>影响记录条数</returns>
        public int Update(ModelView.MesFbView newValue)
        {
            Model.TableModel.Mes_fb        model     = View2Model(newValue);
            List <Model.TableModel.Mes_fb> modelList = new List <Model.TableModel.Mes_fb>();

            modelList.Add(model);
            return(DbEngine.QueryInt <Model.TableModel.Mes_fb>("update", modelList));
        }
Beispiel #2
0
        /// <summary>
        /// 视图类转实体类
        /// </summary>
        /// <param name="view">视图类</param>
        /// <returns>实体类</returns>
        private Model.TableModel.Mes_fb View2Model(ModelView.MesFbView view)
        {
            Model.TableModel.Mes_fb model = new Model.TableModel.Mes_fb();
            if (string.IsNullOrEmpty(view.id))
            {
                model.id = Common.Md5Operate.CreateGuidId();
            }
            else
            {
                model.id = view.id;
            }
            model.status_name   = view.status_name;
            model.status_no     = string.IsNullOrEmpty(view.status_no) ? "310" : view.status_no;
            model.crt_user_no   = string.IsNullOrEmpty(view.crt_user_no) ? "Server" : view.crt_user_no;
            model.crt_user_name = string.IsNullOrEmpty(view.crt_user_name) ? "Server" : view.crt_user_name;
            DateTime dt = DateTime.Now;

            model.crt_time      = DateTime.TryParse(view.crt_time, out dt) ? dt : DateTime.Now;
            model.upd_user_no   = string.IsNullOrEmpty(view.upd_user_no) ? "Server" : view.upd_user_no;
            model.upd_user_name = string.IsNullOrEmpty(view.upd_user_name) ? "Server" : view.upd_user_name;
            dt             = DateTime.Now;
            model.upd_time = DateTime.TryParse(view.upd_time, out dt) ? dt : DateTime.Now;
            GlobalDataCtrl globalDataCtrl = new GlobalDataCtrl();

            model.fb_no   = string.IsNullOrEmpty(view.fb_no) ? globalDataCtrl.GetNextNoByTblName("mes_fb") : view.fb_no;
            model.mpo_no  = string.IsNullOrEmpty(view.mpo_no) ? "MpoNo" : view.mpo_no;
            model.part_no = view.part_no;
            DateTime tmpDt = DateTime.Now;

            model.fb_start_datetime = string.IsNullOrEmpty(view.fb_start_datetime) ? (DateTime?)null : (DateTime.TryParse(view.fb_start_datetime, out tmpDt) ? tmpDt : (DateTime?)null);
            model.fb_end_datetime   = string.IsNullOrEmpty(view.fb_end_datetime) ? (DateTime?)null : (DateTime.TryParse(view.fb_end_datetime, out tmpDt) ? tmpDt : (DateTime?)null);
            decimal tmpDecimal = 0;

            model.fb_end_qty_ok    = string.IsNullOrEmpty(view.fb_end_qty_ok) ? 0.0M : (decimal.TryParse(view.fb_end_qty_ok, out tmpDecimal) ? tmpDecimal : 0.0M);
            model.fb_end_qty_ng    = string.IsNullOrEmpty(view.fb_end_qty_ng) ? 0.0M : (decimal.TryParse(view.fb_end_qty_ng, out tmpDecimal) ? tmpDecimal : 0.0M);
            model.fb_end_qty_scrap = string.IsNullOrEmpty(view.fb_end_qty_scrap) ? 0.0M : (decimal.TryParse(view.fb_end_qty_scrap, out tmpDecimal) ? tmpDecimal : 0.0M);
            model.fb_end_qty_other = string.IsNullOrEmpty(view.fb_end_qty_other) ? 0.0M : (decimal.TryParse(view.fb_end_qty_other, out tmpDecimal) ? tmpDecimal : 0.0M);

            model.worker_no   = string.IsNullOrEmpty(view.worker_no) ? "Worker" : view.worker_no;
            model.worker_name = string.IsNullOrEmpty(view.worker_name) ? "Worker" : view.worker_name;

            model.fb_time              = string.IsNullOrEmpty(view.fb_time) ? (DateTime?)null : (DateTime.TryParse(view.fb_time, out tmpDt) ? tmpDt : (DateTime?)null);
            model.eqm_no               = string.IsNullOrEmpty(view.eqm_no) ? "EqmNo" : view.eqm_no;
            model.eqm_name             = string.IsNullOrEmpty(view.eqm_name) ? "EqmName" : view.eqm_name;
            model.shift_no             = view.shift_no;
            model.factory_no           = view.factory_no;
            model.fb_cfm_end_qty_ok    = string.IsNullOrEmpty(view.fb_cfm_end_qty_ok) ? 0.0M : (decimal.TryParse(view.fb_cfm_end_qty_ok, out tmpDecimal) ? tmpDecimal : 0.0M);
            model.fb_cfm_end_qty_ng    = string.IsNullOrEmpty(view.fb_cfm_end_qty_ng) ? 0.0M : (decimal.TryParse(view.fb_cfm_end_qty_ng, out tmpDecimal) ? tmpDecimal : 0.0M);
            model.fb_cfm_end_qty_scrap = string.IsNullOrEmpty(view.fb_cfm_end_qty_scrap) ? 0.0M : (decimal.TryParse(view.fb_cfm_end_qty_scrap, out tmpDecimal) ? tmpDecimal : 0.0M);
            model.fb_cfm_end_qty_other = string.IsNullOrEmpty(view.fb_cfm_end_qty_other) ? 0.0M : (decimal.TryParse(view.fb_cfm_end_qty_other, out tmpDecimal) ? tmpDecimal : 0.0M);
            model.cfm_user_no          = string.IsNullOrEmpty(view.cfm_user_no) ? "Server" : view.cfm_user_no;
            model.cfm_user_name        = string.IsNullOrEmpty(view.cfm_user_name) ? "Server" : view.cfm_user_name;
            model.cfm_time             = string.IsNullOrEmpty(view.cfm_time) ? (DateTime?)null : (DateTime.TryParse(view.cfm_time, out tmpDt) ? tmpDt : (DateTime?)null);
            return(model);
        }
Beispiel #3
0
        /// <summary>
        /// 更新操作
        /// </summary>
        /// <param name="listNewValue">更新后的视图模板类的集合</param>
        /// <returns>影响记录条数</returns>
        public int Update(List <ModelView.MesFbView> listNewValue)
        {
            List <Model.TableModel.Mes_fb> modelList = new List <Model.TableModel.Mes_fb>();

            foreach (ModelView.MesFbView item in listNewValue)
            {
                Model.TableModel.Mes_fb model = View2Model(item);
                modelList.Add(model);
            }
            return(DbEngine.QueryInt <Model.TableModel.Mes_fb>("update", modelList));
        }
Beispiel #4
0
        /// <summary>
        /// 删除操作
        /// </summary>
        /// <param name="oldValues">要删除的多个值</param>
        /// <returns>影响记录条数</returns>
        public int Delete(List <ModelView.MesFbView> oldValues)
        {
            List <Model.TableModel.Mes_fb> modelList = new List <Model.TableModel.Mes_fb>();

            foreach (ModelView.MesFbView item in oldValues)
            {
                Model.TableModel.Mes_fb model = View2Model(item);
                modelList.Add(model);
            }
            return(DbEngine.QueryInt <Model.TableModel.Mes_fb>("Delete", modelList));
        }
Beispiel #5
0
        /// <summary>
        /// 实体类转视图类
        /// </summary>
        /// <param name="model">实体类</param>
        /// <returns>视图类</returns>
        private ModelView.MesFbView Model2View(Model.TableModel.Mes_fb model)
        {
            ModelView.MesFbView view = new ModelView.MesFbView();
            view.id          = model.id;
            view.status_name = model.status_name;
            view.status_no   = model.status_no;

            view.crt_user_no   = model.crt_user_no;
            view.crt_user_name = model.crt_user_name;
            view.crt_time      = model.crt_time.ToString("yyyy-MM-dd HH:mm:ss.fff");
            view.upd_user_no   = model.upd_user_no;
            view.upd_user_name = model.upd_user_name;
            view.upd_time      = model.upd_time.ToString("yyyy-MM-dd HH:mm:ss.fff");

            view.fb_no             = model.fb_no;
            view.mpo_no            = model.mpo_no;
            view.part_no           = model.part_no;
            view.fb_start_datetime = model.fb_start_datetime.HasValue ? ((DateTime)model.fb_start_datetime).ToString("yyyy-MM-dd") : string.Empty;
            view.fb_end_datetime   = model.fb_end_datetime.HasValue ? ((DateTime)model.fb_end_datetime).ToString("yyyy-MM-dd") : string.Empty;
            view.fb_end_qty_ok     = decimal.Round(model.fb_end_qty_ok.HasValue?(decimal)model.fb_end_qty_ok:0.0M, MidpointRounding.AwayFromZero).ToString();
            view.fb_end_qty_ng     = decimal.Round(model.fb_end_qty_ng.HasValue ? (decimal)model.fb_end_qty_ng : 0.0M, MidpointRounding.AwayFromZero).ToString();
            view.fb_end_qty_scrap  = decimal.Round(model.fb_end_qty_scrap.HasValue ? (decimal)model.fb_end_qty_scrap : 0.0M, MidpointRounding.AwayFromZero).ToString();
            view.fb_end_qty_other  = decimal.Round(model.fb_end_qty_other.HasValue ? (decimal)model.fb_end_qty_other : 0.0M, MidpointRounding.AwayFromZero).ToString();

            view.worker_no   = model.worker_no;
            view.worker_name = model.worker_name;

            view.fb_time    = model.fb_time.HasValue ? ((DateTime)model.fb_time).ToString("yyyy-MM-dd HH:mm:ss.fff") : string.Empty;
            view.eqm_no     = model.eqm_no;
            view.eqm_name   = model.eqm_name;
            view.shift_no   = model.shift_no;
            view.factory_no = model.factory_no;

            view.fb_cfm_end_qty_ok    = decimal.Round(model.fb_cfm_end_qty_ok.HasValue ? (decimal)model.fb_cfm_end_qty_ok : 0.0M, MidpointRounding.AwayFromZero).ToString();
            view.fb_cfm_end_qty_ng    = decimal.Round(model.fb_cfm_end_qty_ng.HasValue ? (decimal)model.fb_cfm_end_qty_ng : 0.0M, MidpointRounding.AwayFromZero).ToString();
            view.fb_cfm_end_qty_scrap = decimal.Round(model.fb_cfm_end_qty_scrap.HasValue ? (decimal)model.fb_cfm_end_qty_scrap : 0.0M, MidpointRounding.AwayFromZero).ToString();
            view.fb_cfm_end_qty_other = decimal.Round(model.fb_cfm_end_qty_other.HasValue ? (decimal)model.fb_cfm_end_qty_other : 0.0M, MidpointRounding.AwayFromZero).ToString();
            view.cfm_user_no          = model.cfm_user_no;
            view.cfm_user_name        = model.cfm_user_name;
            view.cfm_time             = model.cfm_time.HasValue ? ((DateTime)model.cfm_time).ToString("yyyy-MM-dd HH:mm:ss.fff") : string.Empty;
            return(view);
        }
Beispiel #6
0
        /// <summary>
        /// 报工记录提交并将新提交的报工记录返回
        /// </summary>
        /// <param name="barcode">记录信息</param>
        /// <param name="eqmNo">设备编号</param>
        /// <returns>报工记录</returns>
        public Model.TableModel.Mes_fb SubmitMesFb(Model.ProductBarcode barcode, string eqmNo)
        {
            if (barcode == null)
            {
                return(null);
            }
            //如果上次报过工,就不报了
            if (barcode.IsLastSubmit)
            {
                return(null);
            }//一定不是上一次报工的记录
            DateTime actTime = DateTime.Now;

            actTime = DateTime.TryParse(barcode.ProductDate + " " + barcode.ProductTime, out actTime)?actTime:DateTime.Now;
            string userNo  = barcode.User;
            string tmpUser = DataLoadCtrl.LoadFieldByColumn("worker_no", "worker_name", barcode.User, "mes_worker");

            userNo = tmpUser == "UNKNOWN" ? userNo : tmpUser;
            if (barcode.SerialNoExist)//该序列号存在,这个序列号必定存在报工记录
            {
                Model.TableModel.Mes_fb_item mesFbItem = GetMesFbItem(barcode.ProductSerialNo, eqmNo);
                Model.TableModel.Mes_fb      mesFb     = GetMesFb(barcode.MpoNo, eqmNo);
                Model.TableModel.Mpo         mpo       = GetMpo(barcode.MpoNo);
                if (mesFbItem == null || mesFb == null || mpo == null)
                {
                    return(null);
                }
                string result = mesFbItem.quality_no == "QA01" ? "OK" : "NG";
                if (result != barcode.Result)
                {
                    if (barcode.Result == "OK")
                    {
                        mesFb.fb_end_qty_ok += 1;
                        mesFb.fb_end_qty_ng -= 1;
                        mesFbItem.quality_no = "QA01";
                        if (IsLastEqm(eqmNo))
                        {
                            mpo.procedure_finished_qty += 1;
                        }
                    }
                    else
                    {
                        mesFb.fb_end_qty_ok -= 1;
                        mesFb.fb_end_qty_ng += 1;
                        mesFbItem.quality_no = "QA04";
                        if (IsLastEqm(eqmNo))
                        {
                            mpo.procedure_finished_qty -= 1;
                        }
                    }
                    if (mpo.mpo_qty <= mpo.procedure_finished_qty)
                    {
                        mpo.procedure_status_name = "已完工";
                    }
                }
                mesFb.upd_time          = actTime;
                mesFb.upd_user_name     = barcode.User;
                mesFb.upd_user_no       = userNo;
                mesFb.fb_end_datetime   = actTime;
                mesFb.worker_no         = userNo;
                mesFb.worker_name       = barcode.User;
                mesFb.fb_time           = actTime;
                mesFbItem.upd_time      = actTime;
                mesFbItem.upd_user_name = barcode.User;
                mesFbItem.upd_user_no   = userNo;
                mesFbItem.fb_datetime   = actTime;
                mesFbItem.worker_no     = userNo;
                mesFbItem.worker_name   = barcode.User;
                mesFbItem.in_id         = barcode.ID;
                int b = DbEngine.QueryInt <Model.TableModel.Mes_fb>("update", new List <Model.TableModel.Mes_fb>()
                {
                    mesFb
                });
                if (b > 0)
                {
                    b = DbEngine.QueryInt <Model.TableModel.Mes_fb_item>("update", new List <Model.TableModel.Mes_fb_item>()
                    {
                        mesFbItem
                    });
                    if (b > 0)
                    {
                        b = DbEngine.QueryInt <Model.TableModel.Mes_fb_info>("insert", barcode.SubmitInfo);
                        if (b > 0)
                        {
                            DbEngine.QueryInt <Model.TableModel.Mpo>("update", new List <Model.TableModel.Mpo>()
                            {
                                mpo
                            });
                        }
                    }
                }
            }
            else //序列号不存在,则一定不存在报工记录
            {
                bool isNeedUpdateMpo = true;
                //检测生产订单号
                Model.TableModel.Mpo mpo = GetMpo(barcode.MpoNo);
                if (mpo == null)
                {
                    isNeedUpdateMpo             = false;
                    mpo                         = new Model.TableModel.Mpo();
                    mpo.id                      = "virtualMpo";
                    mpo.mpo_no                  = barcode.MpoNo;
                    mpo.part_no                 = barcode.ProductTypeNo;
                    mpo.mpo_qty                 = 0;
                    mpo.mpo_hope_start_datetime = DateTime.Now;
                    mpo.mpo_hope_end_datetime   = DateTime.Now;
                    mpo.commit_status_no        = "310";
                    mpo.commit_status_name      = "已下发";
                    mpo.procedure_finished_qty  = 0;
                    mpo.procedure_status_name   = "已开工";
                }
                Model.TableModel.Mes_fb mesFb = new Model.TableModel.Mes_fb();
                mesFb.id                = Common.Md5Operate.CreateGuidId();
                mesFb.status_no         = "310";
                mesFb.status_name       = "已确认";
                mesFb.crt_time          = actTime;
                mesFb.crt_user_name     = barcode.User;
                mesFb.crt_user_no       = userNo;
                mesFb.upd_time          = actTime;
                mesFb.upd_user_name     = barcode.User;
                mesFb.upd_user_no       = userNo;
                mesFb.fb_no             = DataBllCtrl.GetNextNoByTblName("mes_fb");
                mesFb.mpo_no            = mpo.mpo_no;
                mesFb.part_no           = barcode.ProductTypeNo;
                mesFb.fb_start_datetime = actTime;
                mesFb.fb_end_datetime   = actTime;
                if (barcode.Result == "OK")
                {
                    mesFb.fb_end_qty_ok = 1;
                    if (IsLastEqm(eqmNo))
                    {
                        mpo.procedure_finished_qty += 1;
                    }
                }
                else
                {
                    mesFb.fb_end_qty_ng = 1;
                }
                mesFb.worker_no   = userNo;
                mesFb.worker_name = barcode.User;
                mesFb.fb_time     = actTime;
                mesFb.eqm_no      = eqmNo;
                mesFb.eqm_name    = DataLoadCtrl.LoadFieldByColumn("eqm_name", "eqm_no", eqmNo, "pdm_eqm");
                mesFb.factory_no  = "dfs_f";
                Model.TableModel.Mes_fb_item mesFbItem = new Model.TableModel.Mes_fb_item();
                mesFbItem.id            = Common.Md5Operate.CreateGuidId();
                mesFbItem.status_no     = "310";
                mesFbItem.status_name   = "已确认";
                mesFbItem.crt_time      = actTime;
                mesFbItem.crt_user_name = barcode.User;
                mesFbItem.crt_user_no   = userNo;
                mesFbItem.upd_time      = actTime;
                mesFbItem.upd_user_name = barcode.User;
                mesFbItem.upd_user_no   = userNo;
                mesFbItem.fb_item_no    = DataBllCtrl.GetNextNoByTblName("mes_fb_item");
                mesFbItem.serial_no     = barcode.ProductSerialNo;
                mesFbItem.fb_no         = mesFb.fb_no;
                mesFbItem.mpo_no        = mpo.mpo_no;
                mesFbItem.part_no       = barcode.ProductTypeNo;
                mesFbItem.fb_datetime   = actTime;
                mesFbItem.quality_no    = barcode.Result == "OK" ? "QA01" : "QA04";
                mesFbItem.worker_no     = userNo;
                mesFbItem.worker_name   = barcode.User;
                mesFbItem.eqm_no        = eqmNo;
                mesFbItem.eqm_name      = mesFb.eqm_name;
                mesFbItem.wkc_no        = "PSH On BYD";
                mesFbItem.wkc_name      = "PSH On BYD生产线";
                mesFbItem.in_id         = barcode.ID;
                int b = DbEngine.QueryInt <Model.TableModel.Mes_fb>("insert", new List <Model.TableModel.Mes_fb>()
                {
                    mesFb
                });
                if (b > 0)
                {
                    b = DbEngine.QueryInt <Model.TableModel.Mes_fb_item>("insert", new List <Model.TableModel.Mes_fb_item>()
                    {
                        mesFbItem
                    });
                    if (b > 0)
                    {
                        b = DbEngine.QueryInt <Model.TableModel.Mes_fb_info>("insert", barcode.SubmitInfo);
                        if (b > 0 && isNeedUpdateMpo)
                        {
                            DbEngine.QueryInt <Model.TableModel.Mpo>("update", new List <Model.TableModel.Mpo>()
                            {
                                mpo
                            });
                        }
                    }
                }
            }
            return(null);
        }