Exemple #1
0
        public void FileShow(string fileName, string fileNo)
        {
            if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(fileNo))
            {
                return;
            }
            string path = _localDirectory + @"\current\" + fileName;

            Ctrl.DbConStrFactory      conFactory   = Ctrl.DbConStrFactory.CreateInstance();
            Ctrl.DataLoadCtrl         dataLoadCtrl = DataLoadCtrl.CreateInstance(conFactory.GetSqlConStr("defaultSqlDb"), conFactory.GetAccessConStr("defaultAccessDb"));
            Model.TableModel.Dms_file model        = dataLoadCtrl.GetDmsFile(fileNo);
            if (model == null)
            {
                return;
            }
            if (!System.IO.File.Exists(path))
            {
                string ftpFileName = model.file_md5 + "_" + fileName;
                string newPath     = _localDirectory + @"\current\" + ftpFileName;
                if (!System.IO.File.Exists(newPath))
                {
                    Common.FTPStreamHelper.DownloadFile(_localDirectory + @"\current", "current", ftpFileName, _host, _writeUser, _writePwd);
                }
                System.IO.File.Copy(newPath, path, true);
                System.IO.File.Delete(newPath);
            }
            Process proc = new Process();

            proc.StartInfo.FileName        = _localDirectory + @"\current\" + fileName;
            proc.StartInfo.UseShellExecute = true;
            proc.Start();
        }
Exemple #2
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");
 }
Exemple #3
0
        /// <summary>
        /// 安灯下一步
        /// </summary>
        /// <param name="userNo">用户编号</param>
        /// <param name="eqmNo">设备编号</param>
        /// <param name="andonNo">安灯编号</param>
        /// <returns>返回状态</returns>
        public string NextStep(string userNo, string eqmNo, string andonNo = "")
        {
            string status = string.Empty;

            if (string.IsNullOrEmpty(andonNo))
            {
                GetAdn(eqmNo);
            }
            GetAdnByNo(andonNo);
            if (Adn.status_no == "510")
            {
                status = Adn.status_no;
            }
            else
            {
                if (string.IsNullOrEmpty(userNo))
                {
                    Adn.reply_user_no   = "Server";
                    Adn.reply_user_name = "Server";
                }
                else
                {
                    string userName = DataLoadCtrl.LoadFieldByColumn("user_name", "user_no", userNo, "sys_user");
                    Adn.reply_user_no   = userNo;
                    Adn.reply_user_name = userName;
                }
                ProcessEqmAndQC(Adn.status_no, Adn.andon_type_no, Adn.eqm_no, Adn.reply_user_no, Adn.reply_user_name, DateTime.Now);
                switch (Adn.status_no)
                {
                case "500":
                    Adn.status_no   = "520";
                    Adn.status_name = "处理中";
                    status          = "520";
                    break;

                case "520":
                    Adn.reply_time  = DateTime.Now;
                    Adn.is_finished = true;
                    Adn.status_no   = "510";
                    Adn.status_name = "已处理";
                    status          = "510";
                    break;

                default:
                    status = "510";
                    break;
                }
                List <Model.TableModel.Adn> list = new List <Model.TableModel.Adn>()
                {
                    Adn
                };
                int t = DbEngine.QueryInt <Model.TableModel.Adn>("Update", list);
                if (t <= 0)
                {
                    status = "510";
                }
            }
            return(status);
        }
Exemple #4
0
        /// <summary>
        /// 通过编号获取安灯编号
        /// </summary>
        /// <param name="andonNo">安灯编号</param>
        public void GetAdnByNo(string andonNo)
        {
            List <Model.TableModel.Adn> List = DataLoadCtrl.LoadAdn(string.Format("andon_no='{0}';", andonNo));

            if (List != null && List.Count > 0)
            {
                Adn = List[0];
            }
            else
            {
                Adn = new Model.TableModel.Adn();
            }
        }
Exemple #5
0
        /// <summary>
        /// 通过工站获取安灯编号
        /// </summary>
        /// <param name="eqmNo">工位编号</param>
        public void GetAdn(string eqmNo)
        {
            List <Model.TableModel.Adn> List = DataLoadCtrl.LoadAdn(string.Format("eqm_no='{0}' and is_finished='false' order by call_time asc;", eqmNo));

            if (List != null && List.Count > 0)
            {
                Adn = List[0];
            }
            else
            {
                Adn = new Model.TableModel.Adn();
            }
        }
Exemple #6
0
 /// <summary>
 /// 类的单例创建函数
 /// </summary>
 /// <param name="sqlConStr">sqlServer连接字符串</param>
 /// <param name="accessConStr">access连接字符串</param>
 /// <returns>创建类的构造函数</returns>
 public static DataLoadCtrl CreateInstance(string sqlConStr, string accessConStr)
 {
     // 当第一个线程运行到这里时,此时会对locker对象 "加锁",
     // 当第二个线程运行该方法时,首先检测到locker对象为"加锁"状态,该线程就会挂起等待第一个线程解锁
     // lock语句运行完之后(即线程运行完之后)会对该对象"解锁"
     // 双重锁定只需要一句判断就可以了
     if (_dataLoadCtrl == null)
     {
         lock (_locker)
         {
             // 如果类的实例不存在则创建,否则直接返回
             if (_dataLoadCtrl == null)
             {
                 _dataLoadCtrl = new DataLoadCtrl();
             }
         }
     }
     _dataLoadCtrl.SqlConStr    = sqlConStr;
     _dataLoadCtrl.AccessConStr = accessConStr;
     return(_dataLoadCtrl);
 }
Exemple #7
0
        /// <summary>
        /// 重载数据
        /// </summary>
        /// <param name="state">参数对象</param>
        private void ReLoadData(string where = null)
        {
            Ctrl.DbConStrFactory conFactory   = Ctrl.DbConStrFactory.CreateInstance();
            Ctrl.DataLoadCtrl    dataloadCtrl = Ctrl.DataLoadCtrl.CreateInstance(conFactory.GetSqlConStr("defaultSqlDb"), conFactory.GetAccessConStr("defaultAccessDb"));
            DataTable            dt1          = dataloadCtrl.LoadPartBackup(where);

            dgvMaintainceInfo.Rows.Clear();
            int i = 0;

            foreach (DataRow item in dt1.Rows)
            {
                dgvMaintainceInfo.Rows.Add();
                dgvMaintainceInfo.Rows[i].Cells["dgvColumnBackupPartNo"].Value         = item[0];
                dgvMaintainceInfo.Rows[i].Cells["dgvColumnBackupPartName"].Value       = item[1];
                dgvMaintainceInfo.Rows[i].Cells["dgvColumnBackupPartDesc"].Value       = item[2];
                dgvMaintainceInfo.Rows[i].Cells["dgvColumnBackupPartQty"].Value        = item[3];
                dgvMaintainceInfo.Rows[i].Cells["dgvColumnBackupPartUnitPrice"].Value  = item[4];
                dgvMaintainceInfo.Rows[i].Cells["dgvColumnBackupPartManufacter"].Value = item[5];
                dgvMaintainceInfo.Rows[i].Cells["dgvColumnBackupPartSize"].Value       = item[6];
                dgvMaintainceInfo.Rows[i].Cells["dgvColumnBackupPartRegistime"].Value  = item[7];
                dgvMaintainceInfo.Rows[i].Cells["dgvColumnBackupPartRemark"].Value     = item[8];
                i++;
            }
        }
Exemple #8
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);
        }
Exemple #9
0
        /// <summary>
        /// 将数据行转换为序列号实体类
        /// </summary>
        /// <param name="dr">数据行</param>
        /// <param name="eqmNo">设备编号</param>
        /// <returns>报工信息</returns>
        public Model.ProductBarcode ChangeDataRowToObject(DataRow dr, string eqmNo)
        {
            Model.ProductBarcode barcode = new Model.ProductBarcode();
            barcode.SubmitInfo = new List <Model.TableModel.Mes_fb_info>();
            DataTable dt = dr.Table;

            for (int i = 0; i < dr.ItemArray.Count(); i++)
            {
                switch (dt.Columns[i].ColumnName)
                {
                case "ID":
                    barcode.ID = long.Parse((dr["ID"] ?? "0").ToString());
                    break;

                case "生产日期":
                    barcode.ProductDate = (dr["生产日期"] ?? DateTime.Now.Date).ToString();;
                    break;

                case "生产时间":
                    barcode.ProductTime = (dr["生产时间"] ?? "00:00:00").ToString();
                    break;

                case "产品型号":
                    barcode.ProductTypeNo = (dr["产品型号"] ?? "TypeNo").ToString();
                    break;

                case "产品序列号":
                    barcode.ProductSerialNo = (dr["产品序列号"] ?? "VirtualSerialNo").ToString();
                    string mpoNo = DataLoadCtrl.LoadFieldByColumn("mpo_no", "serial_no", barcode.ProductSerialNo, "mpo_item");
                    barcode.MpoNo = mpoNo == "UNKNOWN" ? "VirtualMpoNo" : mpoNo;
                    break;

                case "操作者":
                    barcode.User = (dr["操作者"] ?? "Server").ToString();
                    break;

                case "判定":
                    barcode.Result = (dr["判定"] ?? "NG").ToString().ToLower() == "ok" ? "OK" : "NG";
                    break;

                default:
                    Model.TableModel.Mes_fb_info model = new Model.TableModel.Mes_fb_info();
                    model.id                = Common.Md5Operate.CreateGuidId();
                    model.serial_no         = string.IsNullOrEmpty(barcode.ProductSerialNo) ? "VirtualSerialNo" : barcode.ProductSerialNo;
                    model.eqm_no            = eqmNo;
                    model.part_no           = barcode.ProductTypeNo;
                    model.information       = dt.Columns[i].ColumnName;
                    model.information_value = (dr[dt.Columns[i].ColumnName] ?? string.Empty).ToString();
                    DateTime dtTmp = DateTime.Now;
                    model.create_time = string.IsNullOrEmpty(barcode.ProductDate + " " + barcode.ProductTime) ? DateTime.Now : DateTime.TryParse(barcode.ProductDate + " " + barcode.ProductTime, out dtTmp) ? dtTmp : DateTime.Now;
                    barcode.SubmitInfo.Add(model);
                    break;
                }
            }
            if (string.IsNullOrEmpty(barcode.ProductSerialNo))
            {
                barcode.ProductSerialNo = "VirtualSerialNo";
            }
            long serialId = GetLastInId4SerialNo(string.IsNullOrEmpty(barcode.ProductSerialNo) ? "SerialNo" : barcode.ProductSerialNo, eqmNo);

            barcode.SerialNoExist = serialId > 0;
            barcode.IsLastSubmit  = serialId == barcode.ID;
            barcode.User          = string.IsNullOrEmpty(barcode.User) ? "Server" : barcode.User;
            barcode.MpoNo         = string.IsNullOrEmpty(barcode.MpoNo) ? "VirtualMpoNo" : barcode.MpoNo;
            return(barcode);
        }