Example #1
0
        public void ControlOil(string gpsCode, EnumOilCommandType commandType, GPSType type, Guid sequnceNo)
        {
            ControlOilCircuit control = new ControlOilCircuit();
            control.Data.GpsType = GPSType.YouWei;
            control.BreakOilCircuitTime = DateTime.Now;
            control.GPSCode = gpsCode;
            control.SerialNumber = sequnceNo.ToString();
            control.Data.GpsType = type;
            control.Data.IsGpsAckMsg = true;
            bool flag = false;

            if (commandType == EnumOilCommandType.BreakOil)
            {
                flag = CommandService.GetInstance().BreakOilCircuitBySmart(control);
                EnumOilCommandState state = flag == true ? EnumOilCommandState.Sended : EnumOilCommandState.SendFail;
                DACFacade.Gps.BreakOilHistoryRecordDAC.UpdateState(sequnceNo, state);
                WirteSendLog(flag, gpsCode, "智能断电.");
            }
            if (commandType == EnumOilCommandType.Support)
            {
                flag = CommandService.GetInstance().SupplyOilCircuit(control);
                EnumOilCommandState state = flag == true ? EnumOilCommandState.Sended : EnumOilCommandState.SendFail;
                DACFacade.Gps.BreakOilHistoryRecordDAC.UpdateState(sequnceNo, state);
                WirteSendLog(flag, gpsCode, "供电供油.");
            }
        }
Example #2
0
 public void ControlOil(string gpsCode, EnumOilCommandType commandType, GPSType type, Guid sequnceNo)
 {
     switch (type)
     {
         case GPSType.YouWei:
             YWGPSController ywController = new YWGPSController();
             ywController.ControlOil(gpsCode, commandType, type, sequnceNo);
             break;
         case GPSType.BuBiao:
             BBGPSController bbController = new BBGPSController();
             bbController.ControlOil(gpsCode, commandType, type, sequnceNo);
             break;
     }
     
 }
Example #3
0
        //插入命令历史记录
        private void InsertBreakOilHistoryRecord(EGPSCurrentInfo info, string tenantCode, string userCode,
            EnumOilCommandType commandType)
        {
            #region create entity
            EBreakOilHistoryRecord history = new EBreakOilHistoryRecord();
            history.ACC = info.ACCState;
            history.AntennaState = info.AntennaState;

            history.CommandType = (int)commandType;
            history.GPSCode = info.GPSCode;
            history.IsBreakOil = commandType == EnumOilCommandType.BreakOil ? true : false;

            history.Latitude = info.Latitude;
            history.Longitude = info.Longitude;

            history.OilState = info.OilState;
            history.RecordID = Guid.NewGuid();

            history.SerialNumber = Guid.NewGuid();
            history.SetTime = DateTime.Now;
            history.Speed = info.Speed;

            history.TenantCode = tenantCode;
            history.UserCode = userCode;
            history.VehicleCode = info.VehicleCode;
            #endregion

            BreakOilHistoryManager breakOilHistoryMgr = new BreakOilHistoryManager();
            breakOilHistoryMgr.Add(history);

            BreakOilLastRecordManager breakOilLastRecordMgr = new BreakOilLastRecordManager();
            EBreakOilLastRecord lastRecord = breakOilLastRecordMgr.Exists(history.VehicleCode);
            if (lastRecord == null)
            {
                lastRecord = new EBreakOilLastRecord();
                lastRecord.VehicleCode = history.VehicleCode;
                lastRecord.BreakOilHistoryRecord = history;
                breakOilLastRecordMgr.Add(lastRecord);
            }
            else
            {
                lastRecord.BreakOilHistoryRecord = history;
                breakOilLastRecordMgr.Update(lastRecord);
            }

            breakOilLastRecordMgr.VehicleControl(info.GPSCode, commandType, history.SerialNumber);
        }
Example #4
0
        public CommandResultViewModel VehicleOilControl(Guid vehicleCode, string tenantCode, string userCode, EnumOilCommandType commandType)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                IList<EGPSCurrentInfo> ltCurrent = DACFacade.Gps.GPSCurrentDAC.GetCurrentInfoList(new Guid[] { vehicleCode }.ToList());
                if (!CheckCommandCondition(ltCurrent, vm, commandType)) return vm;

                InsertBreakOilHistoryRecord(ltCurrent[0], tenantCode, userCode, commandType);
                vm.CommandResult = EnumCommandResult.Success;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
            }
            return vm;
        }
Example #5
0
        //插入命令历史记录
        private void InsertBreakOilHistoryRecord(EGPSCurrentInfo info, string tenantCode, string userCode, EnumOilCommandType commandType)
        {
            EBreakOilHistoryRecord history = new EBreakOilHistoryRecord();
            history.RecordID = Guid.NewGuid();
            history.ACC = info.ACCState;
            history.AntennaState = info.AntennaState;

            history.CommandType = (int)commandType;
            history.GPSCode = info.GPSCode;
            history.IsBreakOil = commandType == EnumOilCommandType.BreakOil ? true : false;

            history.Latitude = info.Latitude;
            history.Longitude = info.Longitude;

            history.OilState = info.OilState;

            history.SerialNumber = Guid.NewGuid();
            history.SetTime = DateTime.Now;
            history.Speed = info.Speed;

            history.TenantCode = tenantCode;
            history.UserCode = userCode;
            history.VehicleCode = info.VehicleCode;

            DACFacade.Gps.BreakOilHistoryRecordDAC.InsertSQL(history);

            EBreakOilLastRecord lastRecord = DACFacade.Gps.BreakOilHistoryRecordDAC.ExistsLast(history.VehicleCode);
            if (lastRecord == null)
            {
                lastRecord = new EBreakOilLastRecord();
                lastRecord.VehicleCode = history.VehicleCode;
                lastRecord.BreakOilHistoryRecord = history;
                DACFacade.Gps.BreakOilHistoryRecordDAC.InsertLast(lastRecord);
            }
            else
            {
                lastRecord.BreakOilHistoryRecord = history;
                DACFacade.Gps.BreakOilHistoryRecordDAC.UpdateLast(lastRecord);
            }

            this.VehicleControl(info.GPSCode, commandType, history.SerialNumber);
        }
        public void VehicleControl(string gpsCode, EnumOilCommandType commandType, Guid sequnceNo)
        {
            GPSControllerFactory factory = new GPSControllerFactory();
            string gpsPrefixCode = gpsCode.Substring(0, 4);
            IGPSController controller = factory.Create(gpsPrefixCode);

            GPSType type = GPSType.YouWei;

            switch (gpsPrefixCode)
            {
                case "0009":
                    type = GPSType.YouWei;
                    break;
                case "0007":
                    type = GPSType.KaiYan;
                    break;
                case "0001":
                    type = GPSType.XinAn;
                    break;
                case "0013":
                    type = GPSType.BoShiJie;
                    break;
                case "0014":
                    type = GPSType.DiBiao;
                    break;
                case "0016":
                    type = GPSType.LongHan;
                    break;
                default:
                    type = GPSType.YouWei;
                    break;
            }

            controller.ControlOil(gpsCode, commandType, type, sequnceNo);
        }
Example #7
0
        private bool CheckCommandCondition(IList<EGPSCurrentInfo> ltCurrent, CommandResultViewModel vm,
            EnumOilCommandType commandType)
        {
            if (ltCurrent.IsNullOrEmpty())
            {
                vm.Msg = "车辆已经离线,无法操作";
                vm.CommandResult = EnumCommandResult.MisMatchCondition;
                return false;
            }
            TimeSpan timeSpan = DateTime.Now.Subtract(ltCurrent[0].ReportTime);
            if (timeSpan.TotalMinutes > Param_OffLineTime)
            {
                vm.Msg = "车辆已经离线,无法操作";
                vm.CommandResult = EnumCommandResult.MisMatchCondition;
                return false;
            }
            if (commandType == EnumOilCommandType.BreakOil)
            {
                if (ltCurrent[0].OilState != 1)          //1 表示油电路正常
                {
                    vm.Msg = "车辆油电路已经断开";
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    return false;
                }
                if (ltCurrent[0].Speed >= 30)
                {
                    vm.Msg = "此操作在速度30公里/时才能操作";
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    return false;
                }
            }
            else if (commandType == EnumOilCommandType.Support)
            {
                if (ltCurrent[0].OilState == 1)          //1 表示油电路正常
                {
                    vm.Msg = "车辆油电路已正常";
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    return false;
                }
            }

            return true;
        }
Example #8
0
 public void ControlOil(string gpsCode, EnumOilCommandType commandType, GPSType type, Guid sequnceNo)
 {
     YWGPSController controller = new YWGPSController();
     controller.ControlOil(gpsCode, commandType, type, sequnceNo);
 }
Example #9
0
        private void VehicleControl(string gpsCode, EnumOilCommandType commandType, Guid sequnceNo)
        {
            string gpsPrefixCode = gpsCode.Substring(0, 4);
            IGPSController controller = new GPSController();

            GPSType type = GPSType.YouWei;

            switch (gpsPrefixCode)
            {
                case "0009": 
                    controller = new GPSController();
                    type = GPSType.YouWei;
                    break;
                case "0007":
                    controller = new KYGPSController();
                    type = GPSType.KaiYan;
                    break;
                case "0001":
                    type = GPSType.XinAn;
                    break;
                case "0013":
                    type = GPSType.BoShiJie;
                    break;
                case "0014":
                    type = GPSType.DiBiao;
                    break;
                case "0016":
                    type = GPSType.LongHan;
                    break;
                case "0020":
                    type = GPSType.BuBiao;
                    break;
                default:
                    controller = new GPSController();
                    type = GPSType.YouWei;
                    break;
            }

            controller.ControlOil(gpsCode, commandType, type, sequnceNo);
        }