/// <summary> /// 回收 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { if (this.CurrCmcsEPCCard != null && this.CurrCmcsAutotruck != null) { CmcsUnFinishTransport unFinishTransport = CarTransportDAO.GetInstance().GetUnFinishTransportByAutotruckId(this.CurrCmcsAutotruck.Id, this.CurrCmcsAutotruck.CarType); if (unFinishTransport != null) { FrmTransport_Confirm frm = new FrmTransport_Confirm(unFinishTransport.TransportId, unFinishTransport.CarType); if (frm.ShowDialog() == DialogResult.Yes) { this.CurrCmcsAutotruck.EPCCardId = string.Empty; Dbers.GetInstance().SelfDber.Update(this.CurrCmcsAutotruck); MessageBoxEx.Show("回收成功"); Reset(); } } else { this.CurrCmcsAutotruck.EPCCardId = string.Empty; Dbers.GetInstance().SelfDber.Update(this.CurrCmcsAutotruck); MessageBoxEx.Show("回收成功"); Reset(); } } else { MessageBoxEx.Show("没有需要回收的卡"); } }
private void btnSubmit_Click(object sender, EventArgs e) { if (this.EditMode == eEditMode.修改) { CmcsGoodsTransport.FirstWeight = (decimal)dbi_FirstWeight.Value; CmcsGoodsTransport.SecondWeight = (decimal)dbi_SecondWeight.Value; CmcsGoodsTransport.SuttleWeight = (decimal)dbi_SuttleWeight.Value; if (this.SupplyUnit != null) { CmcsGoodsTransport.SupplyUnitId = this.SupplyUnit.Id; CmcsGoodsTransport.SupplyUnitName = this.SupplyUnit.Name; } if (cmcsGoodsType != null) { CmcsGoodsTransport.GoodsTypeId = cmcsGoodsType.Id; CmcsGoodsTransport.GoodsTypeName = cmcsGoodsType.GoodsName; } txt_Remark.Text = CmcsGoodsTransport.Remark; CmcsGoodsTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); CmcsGoodsTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); CmcsGoodsTransport.StepName = cmbStepName.Text; CmcsGoodsTransport.DeductWeight = (decimal)dbi_DeductWeight.Value; CmcsGoodsTransport.FromMC = ((DataItem)cmbMineName_GoodsType.SelectedItem).Value; CmcsGoodsTransport.ToMC = ((DataItem)cmbUpload_GoodsType.SelectedItem).Value; CmcsGoodsTransport.FuelKindName = ((DataItem)cmbFuelName_GoodsTye.SelectedItem).Value; CmcsUnFinishTransport unfinishTransport = Dbers.GetInstance().SelfDber.Entity <CmcsUnFinishTransport>(" where TransportId= '" + CmcsGoodsTransport.Id + "'"); //有效并且未完成时需要存在[未完成运输记录] if (chb_IsUse.Checked && !chb_IsFinish.Checked) { if (unfinishTransport == null) { unfinishTransport = new CmcsUnFinishTransport() { TransportId = CmcsGoodsTransport.Id, CarType = eCarType.其他物资.ToString(), AutotruckId = CmcsGoodsTransport.AutotruckId, PrevPlace = CommonAppConfig.GetInstance().AppIdentifier }; Dbers.GetInstance().SelfDber.Insert(unfinishTransport); } } //无效或者是完成时需要删除[未完成运输记录] if (!chb_IsUse.Checked || chb_IsFinish.Checked) { if (unfinishTransport != null) { Dbers.GetInstance().SelfDber.Delete <CmcsUnFinishTransport>(unfinishTransport.Id); } } if (CmcsGoodsTransport.FirstWeight > 0 && CmcsGoodsTransport.SecondWeight > 0 && CmcsGoodsTransport.DeductWeight > 0) { CmcsGoodsTransport.SuttleWeight = Math.Abs(CmcsGoodsTransport.FirstWeight - CmcsGoodsTransport.SecondWeight) - CmcsGoodsTransport.DeductWeight; } Dbers.GetInstance().SelfDber.Update(CmcsGoodsTransport); } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 删除出厂煤运输记录 /// </summary> /// <param name="transportId">汽车出厂煤运输记录Id</param> /// <returns></returns> private bool SyncDelSalesTransport(Action <string, eOutputType> output, string transportId) { bool res = true; CmcsUnFinishTransport transport = commonDAO.SelfDber.Entity <CmcsUnFinishTransport>("where TransportId=:TransportId order by createdate desc", new { TransportId = transportId }); if (transport != null) { res = commonDAO.SelfDber.Delete <CmcsUnFinishTransport>(transport.Id) > 0; } res = commonDAO.SelfDber.Delete <CmcsSaleFuelTransport>(transportId) > 0; return(res); }
/// <summary> /// 保存运输记录 /// </summary> /// <returns></returns> bool SaveBuyFuelTransport() { CmcsAutotruck autoTruck = commonDAO.SelfDber.Entity <CmcsAutotruck>("where CarNumber=:CarNumber", new { CarNumber = this.txt_CarNumber.Text }); if (autoTruck == null) { autoTruck = new CmcsAutotruck() { CarNumber = this.txt_CarNumber.Text }; commonDAO.SelfDber.Insert(autoTruck); } this.CurrentAutotruck = autoTruck; try { if (this.CurrentBuyFuelTransport == null) { // 查找该车未完成的运输记录 CmcsUnFinishTransport unFinishTransport = carTransportDAO.GetUnFinishTransportByAutotruckId(this.CurrentAutotruck.Id, eCarType.入场煤.ToString()); if (unFinishTransport != null) { this.CurrentBuyFuelTransport = commonDAO.SelfDber.Get <CmcsBuyFuelTransport>(unFinishTransport.TransportId); } else { CmcsBuyFuelTransport transport = new CmcsBuyFuelTransport(); QueuerDAO.GetInstance().JoinQueueBuyFuelTransport(autoTruck, this.SelectedMine_BuyFuel, this.SelectedFuelKind_BuyFuel, Convert.ToDecimal(this.txtTicketWeight_BuyFuel.Value), DateTime.Now, "", ref transport); this.CurrentBuyFuelTransport = transport; } } this.CurrentBuyFuelTransport.KgWeight = (decimal)this.txtKgWeight_BuyFuel.Value; this.CurrentBuyFuelTransport.KsWeight = (decimal)this.txtKsWeight_BuyFuel.Value; this.CurrentBuyFuelTransport.DeductWeight = (decimal)this.txtKgWeight_BuyFuel.Value + (decimal)this.txtKsWeight_BuyFuel.Value; if (weighterDAO.SaveBuyFuelTransportHand(this.CurrentBuyFuelTransport, (decimal)Hardwarer.Wber.Weight, DateTime.Now, CommonAppConfig.GetInstance().AppIdentifier)) { this.CurrentBuyFuelTransport = commonDAO.SelfDber.Get <CmcsBuyFuelTransport>(this.CurrentBuyFuelTransport.Id); LoadTodayUnFinishBuyFuelTransport(); LoadTodayFinishBuyFuelTransport(); return(true); } } catch (Exception ex) { MessageBoxEx.Show("保存失败\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); Log4Neter.Error("保存运输记录", ex); } return(false); }
/// <summary> /// 保存入厂煤运输记录 /// </summary> /// <param name="transportId"></param> /// <param name="weight">重量</param> /// <param name="place"></param> /// <returns></returns> public bool SaveBuyFuelTransport(string transportId, decimal weight, DateTime dt, string place) { CmcsBuyFuelTransport transport = SelfDber.Get <CmcsBuyFuelTransport>(transportId); if (transport == null) { return(false); } //根据当前流程节点名称判断 if (transport.StepName != eTruckInFactoryStep.重车.ToString() && transport.StepName != eTruckInFactoryStep.采样.ToString()) { transport.StepName = eTruckInFactoryStep.重车.ToString(); transport.GrossWeight = weight; transport.GrossPlace = place; transport.GrossTime = dt; } else if (transport.StepName == eTruckInFactoryStep.重车.ToString() || transport.StepName == eTruckInFactoryStep.采样.ToString()) { transport.StepName = eTruckInFactoryStep.轻车.ToString(); transport.TareWeight = weight; transport.TarePlace = place; transport.TareTime = dt; //扣吨量 transport.DeductWeight = GetDeductWeight(transport.Id); transport.SuttleWeight = transport.GrossWeight - transport.TareWeight - transport.DeductWeight; // 回皮即完结 transport.IsFinish = 1; //流程结束时删除临时运输记录 CmcsUnFinishTransport unFinishTransport = SelfDber.Entity <CmcsUnFinishTransport>("where TransportId=:TransportId", new { TransportId = transportId }); if (unFinishTransport != null) { SelfDber.Delete <CmcsUnFinishTransport>(unFinishTransport.Id); } } else { return(false); } return(SelfDber.Update(transport) > 0); }
/// <summary> /// 更新流程 /// </summary> private void UpdateGoodsTransports() { if (goodsTransport != null) { //完成流程 goodsTransport.IsFinish = 1; goodsTransport.IsPrint = 1; if (Dbers.GetInstance().SelfDber.Update(goodsTransport) > 0) { //打印磅单时删除临时运输记录 CmcsUnFinishTransport unFinishTransport = Dbers.GetInstance().SelfDber.Entity <CmcsUnFinishTransport>("where TransportId=:TransportId", new { TransportId = this.id }); if (unFinishTransport != null) { Dbers.GetInstance().SelfDber.Delete <CmcsUnFinishTransport>(unFinishTransport.Id); } } } }
/// <summary> /// 保存其他物资运输记录 /// </summary> /// <param name="transportId"></param> /// <param name="weight">重量</param> /// <param name="place"></param> /// <returns></returns> public bool SaveGoodsTransport(string transportId, decimal weight, DateTime dt, string place) { CmcsGoodsTransport transport = SelfDber.Get <CmcsGoodsTransport>(transportId); if (transport == null) { return(false); } //根据当前流程节点名称判断 if (transport.StepName != eTruckInFactoryStep.第一次称重.ToString()) { transport.StepName = eTruckInFactoryStep.第一次称重.ToString(); transport.FirstWeight = weight; transport.FirstPlace = place; transport.FirstTime = dt; } else if (transport.StepName == eTruckInFactoryStep.第一次称重.ToString()) { transport.StepName = eTruckInFactoryStep.第二次称重.ToString(); transport.SecondWeight = weight; transport.SecondPlace = place; transport.SecondTime = dt; transport.SuttleWeight = Math.Abs(transport.FirstWeight - transport.SecondWeight); // 回皮即完结 transport.IsFinish = 1; //流程结束时删除临时运输记录 CmcsUnFinishTransport unFinishTransport = SelfDber.Entity <CmcsUnFinishTransport>("where TransportId=:TransportId", new { TransportId = transportId }); if (unFinishTransport != null) { SelfDber.Delete <CmcsUnFinishTransport>(unFinishTransport.Id); } } else { return(false); } return(SelfDber.Update(transport) > 0); }
private void btnSubmit_Click(object sender, EventArgs e) { if (txt_SerialNumber.Text.Length == 0) { MessageBoxEx.Show("该标车牌号不能为空!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if ((CmcsSaleFuelTransport == null || CmcsSaleFuelTransport.CarNumber != txt_SerialNumber.Text) && Dbers.GetInstance().SelfDber.Entities <CmcsSaleFuelTransport>(" where CarNumber=:CarNumber", new { CarNumber = txt_SerialNumber.Text }).Count > 0) { MessageBoxEx.Show("该标车牌号不可重复!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.EditMode == eEditMode.修改) { CmcsSaleFuelTransport.SerialNumber = txt_SerialNumber.Text; CmcsSaleFuelTransport.CarNumber = txt_CarNumber.Text; if (cmcsSupplier != null) { CmcsSaleFuelTransport.SupplierId = cmcsSupplier.Id; CmcsSaleFuelTransport.SupplierName = cmcsSupplier.Name; } if (cmcsTransportCompany != null) { CmcsSaleFuelTransport.TransportCompanyId = cmcsTransportCompany.Id; CmcsSaleFuelTransport.TransportCompanyName = cmcsTransportCompany.Name; } if (cmcsFuelKind != null) { CmcsSaleFuelTransport.FuelKindId = cmcsFuelKind.Id; CmcsSaleFuelTransport.FuelKindName = cmcsFuelKind.Name; } CmcsSaleFuelTransport.GrossWeight = (decimal)dbi_GrossWeight.Value; CmcsSaleFuelTransport.TareWeight = (decimal)dbi_TareWeight.Value; CmcsSaleFuelTransport.SuttleWeight = (decimal)dbi_SuttleWeight.Value; CmcsSaleFuelTransport.Remark = txt_Remark.Text; CmcsSaleFuelTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); CmcsSaleFuelTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); CmcsSaleFuelTransport.StepName = cmbStepName.Text; if (cmcsTransportSales != null) { CmcsSaleFuelTransport.SupplierId = cmcsTransportSales.SaleSorderId; CmcsSaleFuelTransport.SupplierName = cmcsTransportSales.Consignee; CmcsSaleFuelTransport.TransportCompanyId = cmcsTransportSales.TransportCompayId; CmcsSaleFuelTransport.TransportCompanyName = cmcsTransportSales.TransportCompayName; } CmcsUnFinishTransport unfinishTransport = Dbers.GetInstance().SelfDber.Entity <CmcsUnFinishTransport>(" where TransportId= '" + CmcsSaleFuelTransport.Id + "'"); //有效并且未完成时需要存在[未完成运输记录] if (chb_IsUse.Checked && !chb_IsFinish.Checked) { if (unfinishTransport == null) { unfinishTransport = new CmcsUnFinishTransport() { TransportId = CmcsSaleFuelTransport.Id, CarType = eCarType.销售煤.ToString(), AutotruckId = CmcsSaleFuelTransport.AutotruckId, PrevPlace = CommonAppConfig.GetInstance().AppIdentifier }; Dbers.GetInstance().SelfDber.Insert(unfinishTransport); } } //无效或者是完成时需要删除[未完成运输记录] if (!chb_IsUse.Checked || chb_IsFinish.Checked) { if (unfinishTransport != null) { Dbers.GetInstance().SelfDber.Delete <CmcsUnFinishTransport>(unfinishTransport.Id); } } Dbers.GetInstance().SelfDber.Update(CmcsSaleFuelTransport); } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 保存入厂煤运输记录 /// </summary> /// <param name="transportId"></param> /// <param name="weight">重量</param> /// <param name="dt">时间</param> /// <param name="rfid">rfid卡号</param> /// <param name="place"></param> /// <returns></returns> public bool SaveBuyFuelTransport(string transportId, decimal weight, decimal deductWeight, string catagory, DateTime dt, string rfid, string place) { if (weight <= 0) { throw new Exception("重量异常"); } CmcsBuyFuelTransport transport = SelfDber.Get <CmcsBuyFuelTransport>(transportId); if (transport == null) { return(false); } //根据当前流程节点名称判断 if (transport.StepName != eTruckInFactoryStep.重车.ToString()) { transport.StepName = eTruckInFactoryStep.重车.ToString(); transport.GrossWeight = weight; transport.GrossPlace = place; transport.GrossTime = dt; if (weight < transport.TicketWeight) { throw new Exception("毛重异常"); } try { SelfDber.Insert <View_rlgl_jlgl_mz>(new View_rlgl_jlgl_mz() { Mztime = dt, Chph = transport.CarNumber, Rfid_xlh = rfid, Mpph = transport.Mpph, Mz = weight.ToString(), Issync = 0 }); } catch (Exception ex) { Log4Neter.Error("向全过程反馈重车验票结果", ex); } } else if (transport.StepName == eTruckInFactoryStep.重车.ToString()) { transport.StepName = eTruckInFactoryStep.轻车.ToString(); transport.TareWeight = weight; transport.TarePlace = place; transport.TareTime = dt; transport.DeductWeight = deductWeight; ////净重大于票重以票重为准 //if (transport.GrossWeight - weight > transport.TicketWeight) // transport.TareWeight = transport.GrossWeight - transport.TicketWeight; transport.SuttleWeight = transport.GrossWeight - transport.TareWeight - transport.DeductWeight; //卸煤点信息 try { if (!string.IsNullOrWhiteSpace(catagory)) { string xmd = catagory.Substring(catagory.Length - 1, 1); transport.UnLoadArea = xmd == "1" ? "南煤场东段" : (xmd == "2" ? "南煤场西段" : (xmd == "3" ? "北煤场东段" : (xmd == "4" ? "北煤场西段" : "卸煤沟"))); } } catch (Exception ex) { Log4Neter.Error("卸煤点解析错误", ex); } transport.Catagory = catagory; // 回皮即完结 transport.IsFinish = 1; //流程结束时删除临时运输记录 CmcsUnFinishTransport unFinishTransport = SelfDber.Entity <CmcsUnFinishTransport>("where TransportId=:TransportId", new { TransportId = transportId }); if (unFinishTransport != null) { SelfDber.Delete <CmcsUnFinishTransport>(unFinishTransport.Id); } try { SelfDber.Insert <View_rlgl_jlgl_pz>(new View_rlgl_jlgl_pz() { Mztime = dt, Chph = transport.CarNumber, Rfid_xlh = rfid, Mpph = transport.Mpph, Pz = weight.ToString(), Issync = 0 }); } catch (Exception ex) { Log4Neter.Error("向全过程反馈轻车验票结果", ex); } } else { return(false); } return(SelfDber.Update(transport) > 0); }
private void superGridControl1_CellMouseDown(object sender, DevComponents.DotNetBar.SuperGrid.GridCellMouseEventArgs e) { CmcsGoodsTransport entity = Dbers.GetInstance().SelfDber.Get <CmcsGoodsTransport>(superGridControl1.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, superGridControl1.PrimaryGrid.Columns["clmId"].ColumnIndex).Value.ToString()); switch (superGridControl1.PrimaryGrid.Columns[e.GridCell.ColumnIndex].Name) { case "clmShow": FrmGoodsTransport_Oper frmShow = new FrmGoodsTransport_Oper(entity.Id, false); if (frmShow.ShowDialog() == DialogResult.OK) { BindData(); } break; case "clmEdit": FrmGoodsTransport_Oper frmEdit = new FrmGoodsTransport_Oper(entity.Id, true); if (frmEdit.ShowDialog() == DialogResult.OK) { BindData(); } break; case "clmDelete": // 查询正在使用该记录的车数 if (MessageBoxEx.Show("确定要删除该记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { CmcsUnFinishTransport cmcsunfinishtransport = Dbers.GetInstance().SelfDber.Entity <CmcsUnFinishTransport>(" where TransportId=:TransportId", new { TransportId = entity.Id }); if (cmcsunfinishtransport != null) { Dbers.GetInstance().SelfDber.Delete <CmcsUnFinishTransport>(cmcsunfinishtransport.Id); } Dbers.GetInstance().SelfDber.Delete <CmcsGoodsTransport>(entity.Id); } catch (Exception) { MessageBoxEx.Show("该记录正在使用中,禁止删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } BindData(); } break; case "clmPic": if (Dbers.GetInstance().SelfDber.Entities <CmcsTransportPicture>(String.Format(" where TransportId='{0}'", entity.Id)).Count > 0) { FrmTransportPicture frmPic = new FrmTransportPicture(entity.Id, entity.CarNumber); if (frmPic.ShowDialog() == DialogResult.OK) { BindData(); } } else { MessageBoxEx.Show("暂无抓拍图片!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } break; } }
/// <summary> /// 保存入厂煤运输记录 /// </summary> /// <param name="transportId"></param> /// <param name="weight">重量</param> /// <param name="place"></param> /// <returns></returns> public bool SaveBuyFuelTransport(string transportId, decimal weight, DateTime dt, string place) { CmcsBuyFuelTransport transport = SelfDber.Get <CmcsBuyFuelTransport>(transportId); if (transport == null) { return(false); } if (weight <= 0) { Log4Neter.Error("称重失败", new Exception("称重时重量为0")); return(false); } //根据当前流程节点名称判断 if (transport.GrossWeight == 0) { transport.StepName = eTruckInFactoryStep.重车.ToString(); transport.GrossWeight = weight; transport.GrossPlace = place; transport.GrossTime = dt; transport.SerialNumber = carTransportDAO.CreateNewTransportSerialNumber(eCarType.入厂煤, dt); if (transport.InFactoryTime.Date < dt.Date) { transport.InFactoryTime = dt; carTransportDAO.GCQCInFactoryBatchByBuyFuelTransport(transport); } } else if (transport.TareWeight == 0) { transport.StepName = eTruckInFactoryStep.轻车.ToString(); transport.TareWeight = weight; transport.TarePlace = place; transport.TareTime = dt; transport.SuttleWeight = transport.GrossWeight - transport.TareWeight; ////验收量大于票重时多余的量算到扣吨 if (transport.TicketWeight != 0) { decimal deduct = transport.SuttleWeight > transport.TicketWeight ? (transport.SuttleWeight - transport.TicketWeight) : 0; decimal letterdeduct = 0; //抹去的小数位 //transport.SuttleWeight -= deduct; transport.CheckWeight = OneDigit(transport.SuttleWeight - deduct - transport.KsWeight - transport.KgWeight, ref letterdeduct); deduct += letterdeduct; transport.AutoKsWeight = deduct; transport.DeductWeight = transport.AutoKsWeight + transport.KsWeight + transport.KgWeight; } else { transport.DeductWeight = transport.KsWeight + transport.KgWeight; transport.CheckWeight = transport.SuttleWeight - transport.DeductWeight; } transport.ProfitAndLossWeight = transport.CheckWeight - transport.TicketWeight; // 回皮即完结 transport.IsFinish = 1; transport.IsSyncBatch = 0; //流程结束时删除临时运输记录 CmcsUnFinishTransport unFinishTransport = SelfDber.Entity <CmcsUnFinishTransport>("where TransportId=:TransportId", new { TransportId = transportId }); if (unFinishTransport != null) { SelfDber.Delete <CmcsUnFinishTransport>(unFinishTransport.Id); } } else { return(false); } transport.IsSynch = 0; return(SelfDber.Update(transport) > 0); }
/// <summary> /// 手动保存重量 /// </summary> /// <param name="transport"></param> /// <returns></returns> public bool SaveBuyFuelTransportHand(CmcsBuyFuelTransport transport) { if (transport == null) { return(false); } if (transport.GrossWeight > 0) { if (transport.GrossTime.Year < 2000) { transport.GrossTime = DateTime.Now; transport.InFactoryTime = DateTime.Now; } if (transport.InFactoryTime.Date < transport.GrossTime.Date) { transport.InFactoryTime = transport.GrossTime; carTransportDAO.GCQCInFactoryBatchByBuyFuelTransport(transport); } if (transport.TareWeight > 0) { if (transport.TareTime.Year < 2000) { transport.TareTime = DateTime.Now; } transport.SuttleWeight = transport.GrossWeight - transport.TareWeight; ////验收量大于票重时多余的量算到扣吨 if (transport.TicketWeight != 0) { decimal deduct = transport.SuttleWeight > transport.TicketWeight ? (transport.SuttleWeight - transport.TicketWeight) : 0; decimal letterdeduct = 0; //抹去的小数位 //transport.SuttleWeight -= deduct; transport.CheckWeight = OneDigit(transport.SuttleWeight - deduct - transport.KsWeight - transport.KgWeight, ref letterdeduct); deduct += letterdeduct; transport.AutoKsWeight = deduct; transport.DeductWeight = transport.AutoKsWeight + transport.KsWeight + transport.KgWeight; } else { transport.AutoKsWeight = 0; transport.DeductWeight = transport.KsWeight + transport.KgWeight; transport.CheckWeight = transport.SuttleWeight - transport.DeductWeight; } transport.ProfitAndLossWeight = transport.CheckWeight - transport.TicketWeight; transport.IsFinish = 1; transport.IsSyncBatch = 0; //流程结束时删除临时运输记录 SelfDber.DeleteBySQL <CmcsUnFinishTransport>("where TransportId=:TransportId", new { TransportId = transport.Id }); } } if (transport.IsFinish == 0) { CmcsUnFinishTransport unFinishTransport = SelfDber.Entity <CmcsUnFinishTransport>("where TransportId=:TransportId", new { TransportId = transport.Id }); if (unFinishTransport == null) { unFinishTransport = new CmcsUnFinishTransport(); unFinishTransport.TransportId = transport.Id; unFinishTransport.CarType = eCarType.入厂煤.ToString(); unFinishTransport.AutotruckId = transport.AutotruckId; unFinishTransport.PrevPlace = "未知"; SelfDber.Insert(unFinishTransport); } } transport.IsSynch = 0; return(SelfDber.Update(transport) > 0); }
/// <summary> /// 读卡、车号识别任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); timer1.Interval = 2000; try { // 执行远程命令 ExecAppRemoteControlCmd(); switch (this.CurrentFlowFlag) { case eFlowFlag.等待车辆: #region if (this.InductorCoil1) { // 当读卡区域地感有信号,触发读卡或者车号识别 List <string> tags = Hardwarer.Rwer1.ScanTags(); if (tags.Count > 0) { passCarQueuer.Enqueue(tags[0]); } } if (passCarQueuer.Count > 0) { this.CurrentFlowFlag = eFlowFlag.验证车辆; } #endregion break; case eFlowFlag.验证车辆: #region // 队列中无车时,等待车辆 if (passCarQueuer.Count == 0) { this.CurrentFlowFlag = eFlowFlag.等待车辆; break; } this.CurrentImperfectCar = passCarQueuer.Dequeue(); // 方式一:根据识别的车牌号查找车辆信息 this.CurrentAutotruck = carTransportDAO.GetAutotruckByCarNumber(this.CurrentImperfectCar.Voucher); if (this.CurrentAutotruck == null) { //// 方式二:根据识别的标签卡查找车辆信息 this.CurrentAutotruck = carTransportDAO.GetAutotruckByTagId(this.CurrentImperfectCar.Voucher); } if (this.CurrentAutotruck != null) { UpdateLedShow(this.CurrentAutotruck.CarNumber + "读卡成功"); this.voiceSpeaker.Speak(this.CurrentAutotruck.CarNumber + " 读卡成功", 1, false); if (this.CurrentAutotruck.IsUse == 1) { if (this.CurrentAutotruck.CarriageLength > 0 && this.CurrentAutotruck.CarriageWidth > 0 && this.CurrentAutotruck.CarriageBottomToFloor > 0) { // 未完成运输记录 CmcsUnFinishTransport unFinishTransport = carTransportDAO.GetUnFinishTransportByAutotruckId(this.CurrentAutotruck.Id, eCarType.入厂煤.ToString()); if (unFinishTransport != null) { this.CurrentBuyFuelTransport = carTransportDAO.GetBuyFuelTransportById(unFinishTransport.TransportId); if (this.CurrentBuyFuelTransport != null) { // 判断路线设置 string nextPlace; if (carTransportDAO.CheckNextTruckInFactoryWay(this.CurrentAutotruck.CarType, this.CurrentBuyFuelTransport.StepName, "采样", CommonAppConfig.GetInstance().AppIdentifier, out nextPlace)) { BackGateUp(); btnSendSamplingPlan.Enabled = true; this.CurrentFlowFlag = eFlowFlag.发送计划; UpdateLedShow(this.CurrentAutotruck.CarNumber, "采样请下车"); this.voiceSpeaker.Speak(this.CurrentAutotruck.CarNumber + " 采样请下车", 1, false); } else { UpdateLedShow("路线错误", "禁止通过"); this.voiceSpeaker.Speak("路线错误 禁止通过 " + (!string.IsNullOrEmpty(nextPlace) ? "请前往" + nextPlace : ""), 1, false); timer1.Interval = 8000; this.CurrentFlowFlag = eFlowFlag.异常重置; break; } } else { commonDAO.SelfDber.Delete <CmcsUnFinishTransport>(unFinishTransport.Id); } } else { this.UpdateLedShow(this.CurrentAutotruck.CarNumber, "未排队"); this.voiceSpeaker.Speak("车牌号 " + this.CurrentAutotruck.CarNumber + " 未找到排队记录", 1, false); timer1.Interval = 8000; this.CurrentFlowFlag = eFlowFlag.异常重置; break; } } else { this.UpdateLedShow(this.CurrentAutotruck.CarNumber, "车厢未测量"); this.voiceSpeaker.Speak("车牌号 " + this.CurrentAutotruck.CarNumber + " 车厢未测量", 1, false); timer1.Interval = 8000; this.CurrentFlowFlag = eFlowFlag.异常重置; break; } } else { UpdateLedShow(this.CurrentAutotruck.CarNumber, "已停用"); this.voiceSpeaker.Speak("车牌号 " + this.CurrentAutotruck.CarNumber + " 已停用,禁止通过", 1, false); timer1.Interval = 8000; this.CurrentFlowFlag = eFlowFlag.异常重置; break; } } else { UpdateLedShow(this.CurrentImperfectCar.Voucher, "未登记"); // 方式一:车号识别 this.voiceSpeaker.Speak("车牌号 " + this.CurrentImperfectCar.Voucher + " 未登记,禁止通过", 1, false); //// 方式二:刷卡方式 //this.voiceSpeaker.Speak("卡号未登记,禁止通过", 1, false); timer1.Interval = 8000; this.CurrentFlowFlag = eFlowFlag.异常重置; break; } #endregion break; case eFlowFlag.发送计划: #region if (this.SamplerSystemStatus == eEquInfSamplerSystemStatus.就绪待机) { CmcsRCSampling sampling = carTransportDAO.GetRCSamplingById(this.CurrentBuyFuelTransport.SamplingId); if (sampling != null) { txtSampleCode.Text = sampling.SampleCode; this.CurrentSampleCMD = new InfQCJXCYSampleCMD() { MachineCode = this.SamplerMachineCode, CarNumber = this.CurrentBuyFuelTransport.CarNumber, InFactoryBatchId = this.CurrentBuyFuelTransport.InFactoryBatchId, SampleCode = sampling.SampleCode, Mt = 0, // 根据预报 TicketWeight = 0, // 根据预报 CarCount = 0, // 采样点数根据相关逻辑计算 PointCount = 3, CarriageLength = this.CurrentAutotruck.CarriageLength, CarriageWidth = this.CurrentAutotruck.CarriageWidth, CarriageHeight = this.CurrentAutotruck.CarriageHeight, CarriageBottomToFloor = this.CurrentAutotruck.CarriageBottomToFloor, Obstacle1 = this.CurrentAutotruck.LeftObstacle1, Obstacle2 = this.CurrentAutotruck.LeftObstacle2, Obstacle3 = this.CurrentAutotruck.LeftObstacle3, Obstacle4 = this.CurrentAutotruck.LeftObstacle4, Obstacle5 = this.CurrentAutotruck.LeftObstacle5, Obstacle6 = this.CurrentAutotruck.LeftObstacle6, ResultCode = eEquInfCmdResultCode.默认.ToString(), DataFlag = 0 }; // 发送采样计划 if (commonDAO.SelfDber.Insert <InfQCJXCYSampleCMD>(CurrentSampleCMD) > 0) { this.CurrentFlowFlag = eFlowFlag.等待采样; } } else { this.UpdateLedShow("未找到采样单信息"); this.voiceSpeaker.Speak("未找到采样单信息,请联系管理员", 1, false); timer1.Interval = 5000; } } else { this.UpdateLedShow("采样机未就绪"); this.voiceSpeaker.Speak("采样机未就绪", 1, false); timer1.Interval = 5000; } #endregion break; case eFlowFlag.等待采样: #region // 判断采样是否完成 InfQCJXCYSampleCMD qCJXCYSampleCMD = commonDAO.SelfDber.Get <InfQCJXCYSampleCMD>(this.CurrentSampleCMD.Id); if (qCJXCYSampleCMD.ResultCode == eEquInfCmdResultCode.成功.ToString()) { if (jxSamplerDAO.SaveBuyFuelTransport(this.CurrentBuyFuelTransport.Id, DateTime.Now, CommonAppConfig.GetInstance().AppIdentifier)) { FrontGateUp(); this.UpdateLedShow("采样完毕", " 请离开"); this.voiceSpeaker.Speak("采样完毕,请离开", 1, false); this.CurrentFlowFlag = eFlowFlag.等待离开; } } // 降低灵敏度 timer1.Interval = 4000; #endregion break; case eFlowFlag.等待离开: BackGateUp(); // 采样区域及道闸 地感无信号 ResetBuyFuel(); // 降低灵敏度 timer1.Interval = 4000; break; } //// 所有地感无信号时重置 //if (this.AutoHandMode && !this.InductorCoil1 && !this.InductorCoil2 && !this.InductorCoil3 && !this.InductorCoil4 && this.CurrentFlowFlag != eFlowFlag.等待车辆 // && this.CurrentImperfectCar != null) ResetBuyFuel(); RefreshEquStatus(); } catch (Exception ex) { Log4Neter.Error("timer1_Tick", ex); } finally { timer1.Start(); } timer1.Start(); }
private void btnSubmit_Click(object sender, EventArgs e) { if (txt_SerialNumber.Text.Length == 0) { MessageBoxEx.Show("该标车牌号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if ((cmcsSaleFuelTransport == null || cmcsSaleFuelTransport.CarNumber != txt_SerialNumber.Text) && Dbers.GetInstance().SelfDber.Entities <CmcsSaleFuelTransport>(" where CarNumber=:CarNumber", new { CarNumber = txt_SerialNumber.Text }).Count > 0) { MessageBoxEx.Show("该标车牌号不可重复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cmcsSaleFuelTransport != null) { //if (!CompareClass.CompareClassValue(this.cmcsSaleFuelTransport, Dbers.GetInstance().SelfDber.Get<CmcsSaleFuelTransport>(this.id))) //{ // MessageBoxEx.Show("数据已更改请重新打开页面修改保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} if (cmcsSaleFuelTransport.CarNumber != txt_CarNumber.Text) { CmcsAutotruck autotruck = Dbers.GetInstance().SelfDber.Entity <CmcsAutotruck>(" where CarNumber=:CarNumber", new { CarNumber = this.txt_CarNumber.Text }); if (autotruck != null) { cmcsSaleFuelTransport.AutotruckId = autotruck.Id; CmcsUnFinishTransport unfinish = Dbers.GetInstance().SelfDber.Entity <CmcsUnFinishTransport>(" where TransportId=:TransportId", new { TransportId = cmcsSaleFuelTransport.Id }); if (unfinish != null) { unfinish.AutotruckId = autotruck.Id; Dbers.GetInstance().SelfDber.Update(unfinish); } } } cmcsSaleFuelTransport.SerialNumber = txt_SerialNumber.Text; cmcsSaleFuelTransport.CarNumber = txt_CarNumber.Text; cmcsSaleFuelTransport.GrossWeight = (decimal)dbi_GrossWeight.Value; cmcsSaleFuelTransport.TareWeight = (decimal)dbi_TareWeight.Value; cmcsSaleFuelTransport.FuelKindId = cmbFuelName_SaleFuel.SelectedValue.ToString(); cmcsSaleFuelTransport.Remark = txt_Remark.Text; cmcsSaleFuelTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); cmcsSaleFuelTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); cmcsSaleFuelTransport.IsSynch = "0"; if (cmcsTransportSales != null) { cmcsSaleFuelTransport.TransportSalesId = cmcsTransportSales.Id; cmcsSaleFuelTransport.SupplierId = cmcsTransportSales.SupplierId; cmcsSaleFuelTransport.TransportCompanyId = cmcsTransportSales.TransportCompanyId; } WeighterDAO.GetInstance().SaveSaleFuelTransport(cmcsSaleFuelTransport); } else { cmcsSaleFuelTransport = new CmcsSaleFuelTransport(); cmcsSaleFuelTransport.SerialNumber = txt_SerialNumber.Text; cmcsSaleFuelTransport.CarNumber = txt_CarNumber.Text; cmcsSaleFuelTransport.GrossWeight = (decimal)dbi_GrossWeight.Value; cmcsSaleFuelTransport.TareWeight = (decimal)dbi_TareWeight.Value; cmcsSaleFuelTransport.SuttleWeight = (decimal)dbi_SuttleWeight.Value; txt_Remark.Text = cmcsSaleFuelTransport.Remark; cmcsSaleFuelTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); cmcsSaleFuelTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); Dbers.GetInstance().SelfDber.Insert(cmcsSaleFuelTransport); //SaveAndUpdate(cmcsSaleFuelTransport, cmcsSaleFueltransportdeducts); } this.DialogResult = DialogResult.OK; this.Close(); }
private void btnSubmit_Click(object sender, EventArgs e) { if (txt_SerialNumber.Text.Length == 0) { MessageBoxEx.Show("该标车牌号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if ((cmcsGoodsTransport == null || cmcsGoodsTransport.CarNumber != txt_SerialNumber.Text) && Dbers.GetInstance().SelfDber.Entities <CmcsGoodsTransport>(" where CarNumber=:CarNumber", new { CarNumber = txt_SerialNumber.Text }).Count > 0) { MessageBoxEx.Show("该标车牌号不可重复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cmcsGoodsTransport != null) { if (!CompareClass.CompareClassValue(this.cmcsGoodsTransport, Dbers.GetInstance().SelfDber.Get <CmcsGoodsTransport>(this.id))) { MessageBoxEx.Show("数据已更改请重新打开页面修改保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cmcsGoodsTransport.CarNumber != txt_CarNumber.Text) { CmcsAutotruck autotruck = Dbers.GetInstance().SelfDber.Entity <CmcsAutotruck>(" where CarNumber=:CarNumber", new { CarNumber = this.txt_CarNumber.Text }); if (autotruck != null) { cmcsGoodsTransport.AutotruckId = autotruck.Id; CmcsUnFinishTransport unfinish = Dbers.GetInstance().SelfDber.Entity <CmcsUnFinishTransport>(" where TransportId=:TransportId", new { TransportId = cmcsGoodsTransport.Id }); if (unfinish != null) { unfinish.AutotruckId = autotruck.Id; Dbers.GetInstance().SelfDber.Update(unfinish); } } } cmcsGoodsTransport.CarNumber = txt_CarNumber.Text; cmcsGoodsTransport.FirstWeight = (decimal)dbi_FirstWeight.Value; cmcsGoodsTransport.SecondWeight = (decimal)dbi_SecondWeight.Value; if (dbi_FirstWeight.Value != 0 && (decimal)dbi_SecondWeight.Value != 0) { cmcsGoodsTransport.SuttleWeight = Math.Abs((decimal)dbi_FirstWeight.Value - (decimal)dbi_SecondWeight.Value); } if (supplyUnit != null) { cmcsGoodsTransport.ReceiveUnitId = receiveUnit.Id; } if (receiveUnit != null) { cmcsGoodsTransport.SupplyUnitId = supplyUnit.Id; } if (cmcsGoodsType != null) { cmcsGoodsTransport.GoodsTypeId = cmcsGoodsType.Id; } txt_Remark.Text = cmcsGoodsTransport.Remark; cmcsGoodsTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); cmcsGoodsTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); cmcsGoodsTransport.IsSynch = "0"; Dbers.GetInstance().SelfDber.Update(cmcsGoodsTransport); } else { cmcsGoodsTransport = new CmcsGoodsTransport(); cmcsGoodsTransport.FirstWeight = (decimal)dbi_FirstWeight.Value; cmcsGoodsTransport.SecondWeight = (decimal)dbi_SecondWeight.Value; if (dbi_FirstWeight.Value != 0 && (decimal)dbi_SecondWeight.Value != 0) { cmcsGoodsTransport.SuttleWeight = Math.Abs((decimal)dbi_FirstWeight.Value - (decimal)dbi_SecondWeight.Value); } if (supplyUnit != null) { cmcsGoodsTransport.ReceiveUnitId = receiveUnit.Id; } if (receiveUnit != null) { cmcsGoodsTransport.SupplyUnitId = supplyUnit.Id; } if (cmcsGoodsType != null) { cmcsGoodsTransport.GoodsTypeId = cmcsGoodsType.Id; } txt_Remark.Text = cmcsGoodsTransport.Remark; cmcsGoodsTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); cmcsGoodsTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); Dbers.GetInstance().SelfDber.Insert(cmcsGoodsTransport); } this.DialogResult = DialogResult.OK; this.Close(); }
private void btnSubmit_Click(object sender, EventArgs e) { if (txt_SerialNumber.Text.Length == 0) { MessageBoxEx.Show("该标车牌号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if ((cmcsBuyFuelTransport == null || cmcsBuyFuelTransport.CarNumber != txt_CarNumber.Text) && Dbers.GetInstance().SelfDber.Entities <CmcsBuyFuelTransport>(" where CarNumber=:CarNumber and IsFinish=0", new { CarNumber = txt_CarNumber.Text }).Count > 0) { MessageBoxEx.Show("该标车牌号不可重复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cmcsBuyFuelTransport != null) { if (!CompareClass.CompareClassValue(this.cmcsBuyFuelTransport, Dbers.GetInstance().SelfDber.Get <CmcsBuyFuelTransport>(this.id))) { MessageBoxEx.Show("数据已更改请重新打开页面修改保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cmcsBuyFuelTransport.CarNumber != txt_CarNumber.Text) { CmcsAutotruck autotruck = Dbers.GetInstance().SelfDber.Entity <CmcsAutotruck>(" where CarNumber=:CarNumber", new { CarNumber = this.txt_CarNumber.Text }); if (autotruck != null) { cmcsBuyFuelTransport.AutotruckId = autotruck.Id; CmcsUnFinishTransport unfinish = Dbers.GetInstance().SelfDber.Entity <CmcsUnFinishTransport>(" where TransportId=:TransportId", new { TransportId = cmcsBuyFuelTransport.Id }); if (unfinish != null) { unfinish.AutotruckId = autotruck.Id; Dbers.GetInstance().SelfDber.Update(unfinish); } } } cmcsBuyFuelTransport.SerialNumber = txt_SerialNumber.Text; cmcsBuyFuelTransport.CarNumber = txt_CarNumber.Text; if (cmcsSupplier != null) { cmcsBuyFuelTransport.SupplierId = cmcsSupplier.Id; cmcsBuyFuelTransport.SupplierName = cmcsSupplier.Name; } if (cmcsTransportCompany != null) { cmcsBuyFuelTransport.TransportCompanyId = cmcsTransportCompany.Id; } if (cmcsMine != null) { cmcsBuyFuelTransport.MineId = cmcsMine.Id; cmcsBuyFuelTransport.MineName = cmcsMine.Name; } if (cmcsFuelKind != null) { cmcsBuyFuelTransport.FuelKindId = cmcsFuelKind.Id; cmcsBuyFuelTransport.FuelKindName = cmcsFuelKind.FuelName; } cmcsBuyFuelTransport.SamplingType = (string)cmb_SampingType.Text; cmcsBuyFuelTransport.TicketWeight = (decimal)dbi_TicketWeight.Value; cmcsBuyFuelTransport.GrossWeight = (decimal)dbi_GrossWeight.Value; cmcsBuyFuelTransport.KsWeight = (decimal)dbi_KsWeight.Value; cmcsBuyFuelTransport.KgWeight = (decimal)dbi_KgWeight.Value; cmcsBuyFuelTransport.AutoKsWeight = (decimal)dbi_AutoKsWeight.Value; cmcsBuyFuelTransport.DeductWeight = cmcsBuyFuelTransport.KsWeight + cmcsBuyFuelTransport.KgWeight + cmcsBuyFuelTransport.AutoKsWeight; cmcsBuyFuelTransport.TareWeight = (decimal)dbi_TareWeight.Value; cmcsBuyFuelTransport.SuttleWeight = (decimal)dbi_SuttleWeight.Value; txt_Remark.Text = cmcsBuyFuelTransport.Remark; cmcsBuyFuelTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); cmcsBuyFuelTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); CmcsInFactoryBatch inFactoryBatch = CarTransportDAO.GetInstance().GCQCInFactoryBatchByBuyFuelTransport(cmcsBuyFuelTransport, null); if (inFactoryBatch != null) { cmcsBuyFuelTransport.InFactoryBatchId = inFactoryBatch.Id; } else { MessageBoxEx.Show("供应商、矿点、煤种不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } cmcsBuyFuelTransport.IsSynch = "0"; WeighterDAO.GetInstance().SaveBuyFuelTransport(cmcsBuyFuelTransport); SaveAndUpdate(cmcsBuyFuelTransport, cmcsbuyfueltransportdeducts); } else { cmcsBuyFuelTransport = new CmcsBuyFuelTransport(); cmcsBuyFuelTransport.SerialNumber = txt_SerialNumber.Text; cmcsBuyFuelTransport.CarNumber = txt_CarNumber.Text; if (cmcsSupplier != null) { cmcsBuyFuelTransport.SupplierId = cmcsSupplier.Id; } if (cmcsTransportCompany != null) { cmcsBuyFuelTransport.TransportCompanyId = cmcsTransportCompany.Id; } if (cmcsMine != null) { cmcsBuyFuelTransport.MineId = cmcsMine.Id; } if (cmcsFuelKind != null) { cmcsBuyFuelTransport.FuelKindId = cmcsFuelKind.Id; } cmcsBuyFuelTransport.SamplingType = (string)cmb_SampingType.SelectedItem; cmcsBuyFuelTransport.TicketWeight = (decimal)dbi_TicketWeight.Value; cmcsBuyFuelTransport.GrossWeight = (decimal)dbi_GrossWeight.Value; cmcsBuyFuelTransport.DeductWeight = (decimal)dbi_DeductWeight.Value; cmcsBuyFuelTransport.TareWeight = (decimal)dbi_TareWeight.Value; txt_Remark.Text = cmcsBuyFuelTransport.Remark; cmcsBuyFuelTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); cmcsBuyFuelTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); WeighterDAO.GetInstance().SaveBuyFuelTransport(cmcsBuyFuelTransport); SaveAndUpdate(cmcsBuyFuelTransport, cmcsbuyfueltransportdeducts); } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 保存数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { if (this.EditMode == eEditMode.修改) { CmcsBuyFuelTransport.SerialNumber = txt_SerialNumber.Text; CmcsBuyFuelTransport.CarNumber = txt_CarNumber.Text; if (cmcsSupplier != null) { CmcsBuyFuelTransport.SupplierId = cmcsSupplier.Id; CmcsBuyFuelTransport.SupplierName = cmcsSupplier.Name; } if (cmcsTransportCompany != null) { CmcsBuyFuelTransport.TransportCompanyId = cmcsTransportCompany.Id; CmcsBuyFuelTransport.TransportCompanyName = cmcsTransportCompany.Name; } if (cmcsMine != null) { CmcsBuyFuelTransport.MineId = cmcsMine.Id; CmcsBuyFuelTransport.MineName = cmcsMine.Name; } if (cmcsFuelKind != null) { CmcsBuyFuelTransport.FuelKindId = cmcsFuelKind.Id; CmcsBuyFuelTransport.FuelKindName = cmcsFuelKind.Name; } CmcsBuyFuelTransport.TicketWeight = (decimal)dbi_TicketWeight.Value; CmcsBuyFuelTransport.GrossWeight = (decimal)dbi_GrossWeight.Value; CmcsBuyFuelTransport.DeductWeight = (decimal)dbi_DeductWeight.Value; CmcsBuyFuelTransport.TareWeight = (decimal)dbi_TareWeight.Value; CmcsBuyFuelTransport.SuttleWeight = (decimal)dbi_SuttleWeight.Value; CmcsBuyFuelTransport.Remark = txt_Remark.Text; CmcsBuyFuelTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); CmcsBuyFuelTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); CmcsBuyFuelTransport.StepName = cmbStepName.Text; CmcsUnFinishTransport unfinishTransport = Dbers.GetInstance().SelfDber.Entity <CmcsUnFinishTransport>(" where TransportId= '" + CmcsBuyFuelTransport.Id + "'"); //有效并且未完成时需要存在[未完成运输记录] if (chb_IsUse.Checked && !chb_IsFinish.Checked) { if (unfinishTransport == null) { unfinishTransport = new CmcsUnFinishTransport() { TransportId = CmcsBuyFuelTransport.Id, CarType = eCarType.入厂煤.ToString(), AutotruckId = CmcsBuyFuelTransport.AutotruckId, PrevPlace = CommonAppConfig.GetInstance().AppIdentifier }; Dbers.GetInstance().SelfDber.Insert(unfinishTransport); } } //无效或者是完成时需要删除[未完成运输记录] if (!chb_IsUse.Checked || chb_IsFinish.Checked) { if (unfinishTransport != null) { Dbers.GetInstance().SelfDber.Delete <CmcsUnFinishTransport>(unfinishTransport.Id); } } // 生成批次以及采制化三级编码数据 CmcsInFactoryBatch inFactoryBatch = carTransportDAO.GCQCInFactoryBatchByBuyFuelTransport(CmcsBuyFuelTransport); if (inFactoryBatch != null) { //扣吨量 CmcsBuyFuelTransport.DeductWeight = WeighterDAO.GetInstance().GetDeductWeightWithOutAuto(CmcsBuyFuelTransport.Id); if (CmcsBuyFuelTransport.GrossWeight > 0 && CmcsBuyFuelTransport.TareWeight > 0) { CmcsBuyFuelTransport.SuttleWeight = CmcsBuyFuelTransport.GrossWeight - CmcsBuyFuelTransport.TareWeight - CmcsBuyFuelTransport.DeductWeight; if (CmcsBuyFuelTransport.TheMine.PurcHaseType == "地方煤") { CmcsBuyFuelTransport.TicketWeight = CmcsBuyFuelTransport.SuttleWeight; } else if (CmcsBuyFuelTransport.TheMine.PurcHaseType == "厂矿直供" && CmcsBuyFuelTransport.TicketWeight > 0 && CmcsBuyFuelTransport.TicketWeight <= (CmcsBuyFuelTransport.GrossWeight - CmcsBuyFuelTransport.TareWeight)) { CmcsBuyFuelTransportDeduct deduct = commonDAO.SelfDber.Entity <CmcsBuyFuelTransportDeduct>("where TransportId=:TransportId and DeductType = '磅差'", new { TransportId = CmcsBuyFuelTransport.Id }); decimal KgWeight = CmcsBuyFuelTransport.GrossWeight - CmcsBuyFuelTransport.TareWeight - CmcsBuyFuelTransport.TicketWeight + 0.1m; CmcsBuyFuelTransport.SuttleWeight = CmcsBuyFuelTransport.TicketWeight - 0.1m - CmcsBuyFuelTransport.DeductWeight; if (deduct == null) { deduct = new CmcsBuyFuelTransportDeduct(); deduct.TransportId = CmcsBuyFuelTransport.Id; deduct.DeductType = "磅差"; deduct.DeductWeight = KgWeight; Dbers.GetInstance().SelfDber.Insert(deduct); } else if (deduct != null && deduct.DeductWeight != KgWeight) { deduct.DeductWeight = KgWeight; Dbers.GetInstance().SelfDber.Update(deduct); } CmcsBuyFuelTransport.DeductWeight += KgWeight; } } CmcsBuyFuelTransport.IsSyncBatch = 0; Dbers.GetInstance().SelfDber.Update(CmcsBuyFuelTransport, GlobalVars.LoginUser != null ? GlobalVars.LoginUser.UserName : "******"); } } this.DialogResult = DialogResult.OK; this.Close(); }
private void btnSubmit_Click(object sender, EventArgs e) { if (cmcsBuyFuelTransport == null) { MessageBoxEx.Show("当前记录为空,请返回列表页面重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_CarNumber.Text.Length == 0) { MessageBoxEx.Show("车牌号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //if ((cmcsBuyFuelTransport == null || cmcsBuyFuelTransport.CarNumber != txt_CarNumber.Text) && Dbers.GetInstance().SelfDber.Entities<CmcsBuyFuelTransport>(" where CarNumber=:CarNumber and IsFinish='1'", new { CarNumber = txt_CarNumber.Text }).Count > 0) //{ // MessageBoxEx.Show("车牌号不可重复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} //if ((decimal)dbi_TicketWeight.Value <= 0) //{ // MessageBoxEx.Show("请填写正确的矿发量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} if (cmcsBuyFuelTransport != null) { CmcsAutotruck autoTruck = commonDAO.SelfDber.Entity <CmcsAutotruck>("where CarNumber=:CarNumber", new { CarNumber = this.txt_CarNumber.Text }); if (autoTruck == null) { autoTruck = new CmcsAutotruck() { CarNumber = this.txt_CarNumber.Text }; commonDAO.SelfDber.Insert(autoTruck); } //车号发生改变 if (cmcsBuyFuelTransport.CarNumber != txt_CarNumber.Text) { cmcsBuyFuelTransport.AutotruckId = autoTruck.Id; CmcsUnFinishTransport unFinishTransprot = CarTransportDAO.GetInstance().GetUnFinishTransportByAutotruckId(cmcsBuyFuelTransport.Id); if (unFinishTransprot != null) { unFinishTransprot.AutotruckId = autoTruck.Id; commonDAO.SelfDber.Update(unFinishTransprot); } } cmcsBuyFuelTransport.SerialNumber = txt_SerialNumber.Text; cmcsBuyFuelTransport.CarNumber = txt_CarNumber.Text; if (this.SelectedMine_BuyFuel != null) { cmcsBuyFuelTransport.MineId = this.SelectedMine_BuyFuel.Id; cmcsBuyFuelTransport.MineName = this.SelectedMine_BuyFuel.Name; } if (this.SelectedFuelKind_BuyFuel != null) { cmcsBuyFuelTransport.FuelKindId = this.SelectedFuelKind_BuyFuel.Id; cmcsBuyFuelTransport.FuelKindName = this.SelectedFuelKind_BuyFuel.FuelName; } if (cmcsBuyFuelTransport.GrossWeight != (decimal)dbi_GrossWeight.Value || cmcsBuyFuelTransport.TareWeight != (decimal)dbi_TareWeight.Value) { Log4Neter.Info(string.Format("{0}修改,修改前毛重:{1},修改前皮重:{2}", SelfVars.LoginUser.UserName, cmcsBuyFuelTransport.GrossWeight, cmcsBuyFuelTransport.TareWeight)); commonDAO.SaveAppletLog(eAppletLogLevel.Info, "修改运输记录", string.Format("{0}修改,修改前毛重:{1},修改前皮重:{2}", SelfVars.LoginUser.UserName, cmcsBuyFuelTransport.GrossWeight, cmcsBuyFuelTransport.TareWeight)); } cmcsBuyFuelTransport.Remark = txt_Remark.Text; cmcsBuyFuelTransport.TicketWeight = (decimal)dbi_TicketWeight.Value; cmcsBuyFuelTransport.GrossWeight = (decimal)dbi_GrossWeight.Value; cmcsBuyFuelTransport.DeductWeight = (decimal)dbi_DeductWeight.Value; cmcsBuyFuelTransport.TareWeight = (decimal)dbi_TareWeight.Value; cmcsBuyFuelTransport.SuttleWeight = (decimal)dbi_SuttleWeight.Value; txt_Remark.Text = cmcsBuyFuelTransport.Remark; cmcsBuyFuelTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); cmcsBuyFuelTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); cmcsBuyFuelTransport.KsWeight = (decimal)dbi_KsWeight.Value; cmcsBuyFuelTransport.KgWeight = (decimal)dbi_KgWeight.Value; WeighterDAO.GetInstance().SaveBuyFuelTransport(cmcsBuyFuelTransport); } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 读卡、车号识别任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); timer1.Interval = 2000; try { switch (this.CurrentFlowFlag) { case eFlowFlag.等待车辆: #region //if (this.InductorCoil1) //{ // // 当读卡区域地感有信号,触发读卡或者车号识别 // List<string> tags = Hardwarer.Rwer1.ScanTags(); // if (tags.Count > 0) passCarQueuer.Enqueue(tags[0]); //} //if (passCarQueuer.Count > 0) this.CurrentFlowFlag = eFlowFlag.验证车辆; #endregion break; case eFlowFlag.验证车辆: #region // 队列中无车时,等待车辆 if (passCarQueuer.Count == 0) { this.CurrentFlowFlag = eFlowFlag.等待车辆; break; } this.CurrentImperfectCar = passCarQueuer.Dequeue(); panCurrentCarNumber.Text = this.CurrentImperfectCar.Voucher; // 方式一:根据识别的车牌号查找车辆信息 this.CurrentAutotruck = carTransportDAO.GetAutotruckByCarNumber(this.CurrentImperfectCar.Voucher); if (this.CurrentAutotruck != null) { UpdateLedShow(this.CurrentAutotruck.CarNumber + "读卡成功"); this.voiceSpeaker.Speak(this.CurrentAutotruck.CarNumber + " 读卡成功", 1, false); if (this.CurrentAutotruck.IsUse == 1) { //if (this.CurrentAutotruck.CarriageLength > 0 && this.CurrentAutotruck.CarriageWidth > 0 && this.CurrentAutotruck.CarriageBottomToFloor > 0) //{ // 未完成运输记录 CmcsUnFinishTransport unFinishTransport = carTransportDAO.GetUnFinishTransportByAutotruckId(this.CurrentAutotruck.Id, eCarType.入厂煤.ToString()); if (unFinishTransport != null) { this.CurrentBuyFuelTransport = carTransportDAO.GetBuyFuelTransportById(unFinishTransport.TransportId); if (this.CurrentBuyFuelTransport != null) { CmcsNoSampler noSampler = commonDAO.SelfDber.Entity <CmcsNoSampler>("where MineId=:MineId and StartTime<=:CreateDate and EndTime>=:CreateDate order by CreateDate desc", new { MineId = this.CurrentBuyFuelTransport.MineId, CreateDate = DateTime.Now }); if (noSampler != null) { UpdateLedShow(this.CurrentAutotruck.CarNumber, "无需采样"); this.voiceSpeaker.Speak(this.CurrentAutotruck.CarNumber + " 无需采样 直接离开", 1, false); this.CurrentFlowFlag = eFlowFlag.等待离开; break; } //if (this.CurrentBuyFuelTransport.InFactoryTime.Date < DateTime.Now.Date) //{ this.CurrentBuyFuelTransport.InFactoryTime = DateTime.Now; carTransportDAO.GCQCInFactoryBatchByBuyFuelTransport(this.CurrentBuyFuelTransport); commonDAO.SelfDber.Update(this.CurrentBuyFuelTransport); //} // 判断路线设置 string nextPlace; if (carTransportDAO.CheckNextTruckInFactoryWay(this.CurrentAutotruck.CarType, this.CurrentBuyFuelTransport.StepName, "采样", CommonAppConfig.GetInstance().AppIdentifier, out nextPlace)) { btnSendSamplingPlan.Enabled = true; this.CurrentFlowFlag = eFlowFlag.发送计划; timer1.Interval = 200; UpdateLedShow(this.CurrentAutotruck.CarNumber, "等待驶入"); this.voiceSpeaker.Speak(this.CurrentAutotruck.CarNumber + " 等待驶入", 1, false); } else { UpdateLedShow("路线错误", "禁止通过"); this.voiceSpeaker.Speak("路线错误 禁止通过 " + (!string.IsNullOrEmpty(nextPlace) ? "请前往" + nextPlace : ""), 1, false); timer1.Interval = 20000; } } else { commonDAO.SelfDber.Delete <CmcsUnFinishTransport>(unFinishTransport.Id); } } else { this.UpdateLedShow(this.CurrentAutotruck.CarNumber, "未排队"); this.voiceSpeaker.Speak("车牌号 " + this.CurrentAutotruck.CarNumber + " 未找到排队记录", 1, false); timer1.Interval = 20000; } //} //else //{ // this.UpdateLedShow(this.CurrentAutotruck.CarNumber, "车厢未测量"); // this.voiceSpeaker.Speak("车牌号 " + this.CurrentAutotruck.CarNumber + " 车厢未测量", 1, false); // timer1.Interval = 20000; //} } else { UpdateLedShow(this.CurrentAutotruck.CarNumber, "已停用"); this.voiceSpeaker.Speak("车牌号 " + this.CurrentAutotruck.CarNumber + " 已停用,禁止通过", 1, false); timer1.Interval = 20000; } } else { UpdateLedShow(this.CurrentImperfectCar.Voucher, "未登记"); // 方式一:车号识别 this.voiceSpeaker.Speak("车牌号 " + this.CurrentImperfectCar.Voucher + " 未登记,禁止通过", 1, false); timer1.Interval = 20000; } #endregion break; case eFlowFlag.发送计划: #region if (this.SamplerSystemStatus == eEquInfSamplerSystemStatus.就绪待机) { CmcsRCSampling sampling = carTransportDAO.GetRCSamplingById(this.CurrentBuyFuelTransport.SamplingId); if (sampling != null) { txtSampleCode.Text = sampling.SampleCode; if (this.CurrentAutotruck.CarriageLength == 0) { this.CurrentAutotruck.CarriageTotalLength = 16000; this.CurrentAutotruck.CarriageLength = 13000; this.CurrentAutotruck.CarriageWidth = 2400; this.CurrentAutotruck.CarriageHeight = 1800; this.CurrentAutotruck.CarriageBottomToFloor = 1500; } this.CurrentSampleCMD = new InfQCJXCYSampleCMD() { MachineCode = this.SamplerMachineCode, CarNumber = this.CurrentBuyFuelTransport.CarNumber, InFactoryBatchId = this.CurrentBuyFuelTransport.InFactoryBatchId, SampleCode = sampling.SampleCode, Mt = 0, // 根据预报 TicketWeight = 0, // 根据预报 CarCount = 0, // 采样点数根据相关逻辑计算 PointCount = Convert.ToInt32(dbtxtSampleCount.Value), CarriageTotalLength = this.CurrentAutotruck.CarriageTotalLength, CarriageLength = this.CurrentAutotruck.CarriageLength, CarriageWidth = this.CurrentAutotruck.CarriageWidth, CarriageHeight = this.CurrentAutotruck.CarriageHeight, CarriageBottomToFloor = this.CurrentAutotruck.CarriageBottomToFloor, Obstacle1 = this.CurrentAutotruck.LeftObstacle1.ToString(), Obstacle2 = this.CurrentAutotruck.LeftObstacle2.ToString(), Obstacle3 = this.CurrentAutotruck.LeftObstacle3.ToString(), Obstacle4 = this.CurrentAutotruck.LeftObstacle4.ToString(), Obstacle5 = this.CurrentAutotruck.LeftObstacle5.ToString(), Obstacle6 = this.CurrentAutotruck.LeftObstacle6.ToString(), ResultCode = eEquInfCmdResultCode.默认.ToString(), DataFlag = 0 }; // 发送采样计划 if (commonDAO.SelfDber.Insert <InfQCJXCYSampleCMD>(CurrentSampleCMD) > 0) { this.CurrentFlowFlag = eFlowFlag.等待采样; this.UpdateLedShow("等待采样"); this.voiceSpeaker.Speak("等待采样", 1, false); } } else { this.UpdateLedShow("未找到采样单信息"); this.voiceSpeaker.Speak("未找到采样单信息,请联系管理员", 1, false); timer1.Interval = 5000; } } else { this.UpdateLedShow("采样机未就绪"); this.voiceSpeaker.Speak("采样机未就绪", 1, false); timer1.Interval = 5000; } #endregion break; case eFlowFlag.等待采样: #region // 判断采样是否完成 InfQCJXCYSampleCMD qCJXCYSampleCMD = commonDAO.SelfDber.Get <InfQCJXCYSampleCMD>(this.CurrentSampleCMD.Id); if (qCJXCYSampleCMD.ResultCode == eEquInfCmdResultCode.成功.ToString()) { if (jxSamplerDAO.SaveBuyFuelTransport(this.CurrentBuyFuelTransport.Id, DateTime.Now, CommonAppConfig.GetInstance().AppIdentifier)) { this.UpdateLedShow("采样完毕", " 请离开"); this.voiceSpeaker.Speak("采样完毕,请离开", 1, false); this.CurrentFlowFlag = eFlowFlag.等待离开; } } // 降低灵敏度 timer1.Interval = 4000; #endregion break; case eFlowFlag.等待离开: ResetBuyFuel(); // 降低灵敏度 timer1.Interval = 4000; break; } RefreshEquStatus(); } catch (Exception ex) { Log4Neter.Error("timer1_Tick", ex); } finally { timer1.Start(); } timer1.Start(); }
/// <summary> /// 保存数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { if (this.EditMode == eEditMode.修改) { CmcsBuyFuelTransport.SerialNumber = txt_SerialNumber.Text; CmcsBuyFuelTransport.CarNumber = txt_CarNumber.Text; if (cmcsSupplier != null) { CmcsBuyFuelTransport.SupplierId = cmcsSupplier.Id; CmcsBuyFuelTransport.SupplierName = cmcsSupplier.Name; } if (cmcsTransportCompany != null) { CmcsBuyFuelTransport.TransportCompanyId = cmcsTransportCompany.Id; CmcsBuyFuelTransport.TransportCompanyName = cmcsTransportCompany.Name; } if (cmcsMine != null) { CmcsBuyFuelTransport.MineId = cmcsMine.Id; CmcsBuyFuelTransport.MineName = cmcsMine.Name; } if (cmcsFuelKind != null) { CmcsBuyFuelTransport.FuelKindId = cmcsFuelKind.Id; CmcsBuyFuelTransport.FuelKindName = cmcsFuelKind.Name; } CmcsBuyFuelTransport.TicketWeight = (decimal)dbi_TicketWeight.Value; CmcsBuyFuelTransport.GrossWeight = (decimal)dbi_GrossWeight.Value; CmcsBuyFuelTransport.DeductWeight = (decimal)dbi_DeductWeight.Value; CmcsBuyFuelTransport.TareWeight = (decimal)dbi_TareWeight.Value; CmcsBuyFuelTransport.SuttleWeight = (decimal)dbi_SuttleWeight.Value; CmcsBuyFuelTransport.InFactoryTime = txt_InFactoryTime.Value; CmcsBuyFuelTransport.SamplingTime = txt_SamplingTime.Value; CmcsBuyFuelTransport.GrossTime = txt_GrossTime.Value; CmcsBuyFuelTransport.UploadTime = txt_UploadTime.Value; CmcsBuyFuelTransport.TareTime = txt_TareTime.Value; CmcsBuyFuelTransport.OutFactoryTime = txt_OutFactoryTime.Value; CmcsBuyFuelTransport.Remark = txt_Remark.Text; CmcsBuyFuelTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); CmcsBuyFuelTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); CmcsBuyFuelTransport.StepName = cmbStepName.Text; CmcsUnFinishTransport unfinishTransport = Dbers.GetInstance().SelfDber.Entity <CmcsUnFinishTransport>(" where TransportId= '" + CmcsBuyFuelTransport.Id + "'"); //有效并且未完成时需要存在[未完成运输记录] if (chb_IsUse.Checked && !chb_IsFinish.Checked) { if (unfinishTransport == null) { unfinishTransport = new CmcsUnFinishTransport() { TransportId = CmcsBuyFuelTransport.Id, CarType = eCarType.入厂煤.ToString(), AutotruckId = CmcsBuyFuelTransport.AutotruckId, PrevPlace = CommonAppConfig.GetInstance().AppIdentifier }; Dbers.GetInstance().SelfDber.Insert(unfinishTransport); } } //无效或者是完成时需要删除[未完成运输记录] if (!chb_IsUse.Checked || chb_IsFinish.Checked) { if (unfinishTransport != null) { Dbers.GetInstance().SelfDber.Delete <CmcsUnFinishTransport>(unfinishTransport.Id); } } // 生成批次以及采制化三级编码数据 //CmcsInFactoryBatch inFactoryBatch = carTransportDAO.GCQCInFactoryBatchByBuyFuelTransport(CmcsBuyFuelTransport); //if (inFactoryBatch != null) //{ //commonDAO.SaveModifyLog<CmcsBuyFuelTransport>(CmcsBuyFuelTransport, CmcsBuyFuelTransport.Id, "入厂煤运输记录", GlobalVars.LoginUser != null ? GlobalVars.LoginUser.UserName : "******"); Dbers.GetInstance().SelfDber.Update(CmcsBuyFuelTransport, GlobalVars.LoginUser != null ? GlobalVars.LoginUser.UserName : "******"); //} } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 其他物资运输记录业务定时器 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer_Goods_Tick(object sender, EventArgs e) { if (this.timer_Goods_Cancel) { return; } timer_Goods.Stop(); timer_Goods.Interval = 2000; try { switch (this.CurrentFlowFlag) { case eFlowFlag.验证信息: #region // 查找该车未完成的运输记录 CmcsUnFinishTransport unFinishTransport = carTransportDAO.GetUnFinishTransportByAutotruckId(this.CurrentAutotruck.Id, eCarType.其他物资.ToString()); if (unFinishTransport != null) { this.CurrentGoodsTransport = commonDAO.SelfDber.Get <CmcsGoodsTransport>(unFinishTransport.TransportId); if (this.CurrentGoodsTransport != null) { // 判断路线设置 string nextPlace; if (carTransportDAO.CheckNextTruckInFactoryWay(this.CurrentAutotruck.CarType, this.CurrentBuyFuelTransport.StepName, "出厂", CommonAppConfig.GetInstance().AppIdentifier, out nextPlace)) { if (this.CurrentGoodsTransport.SuttleWeight > 0) { this.CurrentFlowFlag = eFlowFlag.保存信息; } else { this.voiceSpeaker.Speak("车牌号 " + this.CurrentAutotruck.CarNumber + " 称重未完成", 1, false); timer_Goods.Interval = 20000; } } else { this.voiceSpeaker.Speak("路线错误 禁止通过 " + (!string.IsNullOrEmpty(nextPlace) ? "请前往" + nextPlace : ""), 1, false); timer_Goods.Interval = 20000; } } else { commonDAO.SelfDber.Delete <CmcsUnFinishTransport>(unFinishTransport.Id); } } else { this.voiceSpeaker.Speak("车牌号 " + this.CurrentAutotruck.CarNumber + " 未找到排队记录", 1, false); timer_Goods.Interval = 20000; } #endregion break; case eFlowFlag.保存信息: #region if (this.AutoHandMode) { // 自动模式 if (!SaveGoodsTransport()) { this.voiceSpeaker.Speak("车牌号 " + this.CurrentAutotruck.CarNumber + " 保存失败,请联系管理员", 1, false); } } else { // 手动模式 } #endregion break; case eFlowFlag.等待离开: #region // 当前道路地感无信号时重置 if (!HasCarOnCurrentWay()) { ResetGoods(); } // 降低灵敏度 timer_Goods.Interval = 4000; #endregion break; } // 当前道路地感无信号时重置 if (!HasCarOnCurrentWay() && this.CurrentFlowFlag != eFlowFlag.等待车辆 && (this.CurrentImperfectCar != null && this.CurrentImperfectCar.IsFromDevice)) { ResetGoods(); } } catch (Exception ex) { Log4Neter.Error("timer_Goods_Tick", ex); } finally { timer_Goods.Start(); } }
private void btnSubmit_Click(object sender, EventArgs e) { if (this.EditMode == eEditMode.修改) { CmcsGoodsTransport.FirstWeight = (decimal)dbi_FirstWeight.Value; CmcsGoodsTransport.SecondWeight = (decimal)dbi_SecondWeight.Value; CmcsGoodsTransport.SuttleWeight = (decimal)dbi_SuttleWeight.Value; if (this.SupplyUnit != null) { CmcsGoodsTransport.SupplyUnitId = this.SupplyUnit.Id; CmcsGoodsTransport.SupplyUnitName = this.SupplyUnit.Name; } if (this.ReceiveUnit != null) { CmcsGoodsTransport.ReceiveUnitId = this.ReceiveUnit.Id; CmcsGoodsTransport.ReceiveUnitName = this.ReceiveUnit.Name; } if (cmcsGoodsType != null) { CmcsGoodsTransport.GoodsTypeId = cmcsGoodsType.Id; CmcsGoodsTransport.GoodsTypeName = cmcsGoodsType.GoodsName; } CmcsGoodsTransport.InFactoryTime = txt_InFactoryTime.Value; CmcsGoodsTransport.OutFactoryTime = txt_OutFactoryTime.Value; CmcsGoodsTransport.FirstTime = txt_FirstTime.Value; CmcsGoodsTransport.SecondTime = txt_SecondTime.Value; CmcsGoodsTransport.Remark = txt_Remark.Text; CmcsGoodsTransport.IsFinish = (chb_IsFinish.Checked ? 1 : 0); CmcsGoodsTransport.IsUse = (chb_IsUse.Checked ? 1 : 0); CmcsGoodsTransport.StepName = cmbStepName.Text; CmcsUnFinishTransport unfinishTransport = Dbers.GetInstance().SelfDber.Entity <CmcsUnFinishTransport>(" where TransportId= '" + CmcsGoodsTransport.Id + "'"); //有效并且未完成时需要存在[未完成运输记录] if (chb_IsUse.Checked && !chb_IsFinish.Checked) { if (unfinishTransport == null) { unfinishTransport = new CmcsUnFinishTransport() { TransportId = CmcsGoodsTransport.Id, CarType = eCarType.其他物资.ToString(), AutotruckId = CmcsGoodsTransport.AutotruckId, PrevPlace = CommonAppConfig.GetInstance().AppIdentifier }; Dbers.GetInstance().SelfDber.Insert(unfinishTransport); } } //无效或者是完成时需要删除[未完成运输记录] if (!chb_IsUse.Checked || chb_IsFinish.Checked) { if (unfinishTransport != null) { Dbers.GetInstance().SelfDber.Delete <CmcsUnFinishTransport>(unfinishTransport.Id); } } Dbers.GetInstance().SelfDber.Update(CmcsGoodsTransport); } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 保存入厂煤运输记录 /// </summary> /// <param name="transportId"></param> /// <param name="weight">重量</param> /// <param name="place"></param> /// <returns></returns> public bool SaveBuyFuelTransport(string transportId, decimal weight, DateTime dt, string place) { CmcsBuyFuelTransport transport = SelfDber.Get <CmcsBuyFuelTransport>(transportId); if (transport == null) { return(false); } //根据当前流程节点名称判断 if (transport.StepName != eTruckInFactoryStep.重车.ToString()) { transport.StepName = eTruckInFactoryStep.重车.ToString(); transport.GrossWeight = weight; transport.GrossPlace = place; transport.GrossTime = dt; CmcsInNetTransport inNetTransport = SelfDber.Get <CmcsInNetTransport>(transport.OutNetTransportId); if (inNetTransport != null) { inNetTransport.StepName = eTruckInFactoryStep.重车.ToString(); SelfDber.Update(inNetTransport); } } else if (transport.StepName == eTruckInFactoryStep.重车.ToString()) { transport.StepName = eTruckInFactoryStep.轻车.ToString(); transport.TareWeight = weight; transport.TarePlace = place; transport.TareTime = dt; transport.OutFactoryTime = dt; CmcsInNetTransport inNetTransport = SelfDber.Get <CmcsInNetTransport>(transport.OutNetTransportId); if (inNetTransport != null) { inNetTransport.StepName = eTruckInFactoryStep.轻车.ToString(); inNetTransport.IsFinish = 1; SelfDber.Update(inNetTransport); } //扣吨量 transport.DeductWeight = GetDeductWeightWithOutAuto(transport.Id); transport.SuttleWeight = transport.GrossWeight - transport.TareWeight - transport.DeductWeight; if (transport.GrossWeight > 0 && transport.TareWeight > 0) { if (transport.TheMine.PurcHaseType == "地方煤") { transport.TicketWeight = transport.SuttleWeight; } else if (transport.TheMine.PurcHaseType == "厂矿直供" && transport.TicketWeight > 0 && transport.TicketWeight <= (transport.GrossWeight - transport.TareWeight)) { CmcsBuyFuelTransportDeduct deduct = commonDAO.SelfDber.Entity <CmcsBuyFuelTransportDeduct>("where TransportId=:TransportId and DeductType = '磅差'", new { TransportId = transport.Id }); decimal KgWeight = transport.GrossWeight - transport.TareWeight - transport.TicketWeight + 0.1m; transport.SuttleWeight = transport.TicketWeight - 0.1m - transport.DeductWeight; if (deduct == null) { deduct = new CmcsBuyFuelTransportDeduct(); deduct.TransportId = transport.Id; deduct.DeductType = "磅差"; deduct.DeductWeight = KgWeight; Dbers.GetInstance().SelfDber.Insert(deduct); } else if (deduct != null && deduct.DeductWeight != KgWeight) { deduct.DeductWeight = KgWeight; Dbers.GetInstance().SelfDber.Update(deduct); } transport.DeductWeight += KgWeight; } } // 回皮即完结 transport.IsFinish = 1; //流程结束时删除临时运输记录 CmcsUnFinishTransport unFinishTransport = SelfDber.Entity <CmcsUnFinishTransport>("where TransportId=:TransportId", new { TransportId = transportId }); if (unFinishTransport != null) { SelfDber.Delete <CmcsUnFinishTransport>(unFinishTransport.Id); } } else { return(false); } return(SelfDber.Update(transport) > 0); }