Example #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="andonNo">安灯编号</param>
 /// <param name="andonTypeNo">安灯类型编号</param>
 /// <param name="deptNo">部门编号</param>
 /// <param name="eqmNo">设备编号</param>
 /// <param name="callerNo">呼叫者</param>
 public Andon(string andonNo, string andonTypeNo, string deptNo, string eqmNo, string callerNo)
 {
     Adn = new Model.TableModel.Adn();
     //500--未处理510--已处理520处理中
     Adn.id          = Common.Md5Operate.CreateGuidId();
     Adn.status_no   = "500";
     Adn.status_name = "待处理";
     if (string.IsNullOrEmpty(andonNo))
     {
         Adn.andon_no = DataBllCtrl.GetNextNoByTblName("adn");
     }
     else
     {
         Adn.andon_no = andonNo;
     }
     Adn.andon_type_no   = andonTypeNo;
     Adn.andon_type_name = DataLoadCtrl.LoadFieldByColumn("andon_type_name", "andon_type_no", andonTypeNo, "andon_type");
     Adn.andon_desc      = string.Empty;
     Adn.dept_no         = deptNo;
     Adn.andon_music_no  = deptNo + "_" + eqmNo + "_" + ".mp3";
     Adn.eqm_no          = eqmNo;
     Adn.call_user_no    = callerNo;
     Adn.call_user_name  = DataLoadCtrl.LoadFieldByColumn("user_name", "user_no", callerNo, "sys_user");
     Adn.call_time       = DateTime.Now;
     Adn.reply_user_no   = null;
     Adn.reply_user_name = null;
     Adn.reply_time      = null;
     Adn.ralate_no       = string.Empty;
     Adn.is_finished     = false;
     Adn.play_record     = DataLoadCtrl.LoadFieldByColumn("andon_play_eqm", "andon_type_no", andonTypeNo, "adn_type");
 }
Example #2
0
 /// <summary>
 /// 类的单例创建函数
 /// </summary>
 /// <param name="sqlConStr">sqlServer连接字符串</param>
 /// <param name="accessConStr">access连接字符串</param>
 /// <returns>创建类的构造函数</returns>
 public static DataBllCtrl CreateInstance(string sqlConStr, string accessConStr)
 {
     // 当第一个线程运行到这里时,此时会对locker对象 "加锁",
     // 当第二个线程运行该方法时,首先检测到locker对象为"加锁"状态,该线程就会挂起等待第一个线程解锁
     // lock语句运行完之后(即线程运行完之后)会对该对象"解锁"
     // 双重锁定只需要一句判断就可以了
     if (_dataBllCtrl == null)
     {
         lock (_locker)
         {
             // 如果类的实例不存在则创建,否则直接返回
             if (_dataBllCtrl == null)
             {
                 _dataBllCtrl = new DataBllCtrl();
             }
         }
     }
     _dataBllCtrl.SqlConStr    = sqlConStr;
     _dataBllCtrl.AccessConStr = accessConStr;
     return(_dataBllCtrl);
 }
Example #3
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);
        }