/// <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"); }
/// <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); }