示例#1
0
 public List<EMVehicleViewModel> SearchVehicle(string licenceNum)
 {
     EMVehicleService service = new EMVehicleService();
     List<EMVehicle> list = service.Select(licenceNum, true).ToList();
     List<EMVehicleViewModel> viewModelList = ConvertHelper.ConvertList<EMVehicle, EMVehicleViewModel>(list);
     return viewModelList;
 }
示例#2
0
 public IList<EMVehicle> GetVehicleList(List<Guid> vCodes)
 {
     EMVehicleService emvSrv = new EMVehicleService();
     return emvSrv.Select(vCodes);
 }
        public DBProcessResult TransferVehicle(string vehicleCode, string newTenantCode)
        {
            DBProcessResult result = new DBProcessResult();
            try
            {
                //查询新客户的默认车辆组
                EMVehicleGroupService VGSev = new EMVehicleGroupService();
                ulong newVehicleGroupID = VGSev.GetTopGroupID(newTenantCode);
                EMVehicleService VSev = new EMVehicleService();
                EMVehicle vehicle = VSev.Select(new Guid(vehicleCode));
                //更新车辆的车辆组和Tenantcode
                vehicle.GroupID = newVehicleGroupID;
                vehicle.TenantCode = newTenantCode;
                VSev.Update(vehicle);

                //将车辆从旧的车辆和用户组关系中删除
                EMVehicleInUserGroupService VIUSev = new EMVehicleInUserGroupService();
                VIUSev.DeleteByVehicleCode(vehicleCode);
                //删除车辆报警参数设置
                MySqlHelper.TransCommand(getCmdTextList(vehicleCode));

                result.IsSuccess = true;
                result.Message = "转移车辆成功!";
            }
            catch
            {
                result.IsSuccess = false;
                result.Message = "转移车辆失败!";                
            }
            return result;
        }
示例#4
0
        public DBProcessResult ModifyVehicle(EMVehicleViewModel view)
        {
            DBProcessResult result = new DBProcessResult();
            try
            {
                IEMVehicleService service = new EMVehicleService();
                IEMVehicleLogService logService = new EMVehicleLogService();
                IdentityNoService noService = new IdentityNoService();
                IEMGpsTypeService gpsTypeService = new EMGpsTypeService();

                EMVehicle entity = ConvertHelper.ConvertObj<EMVehicleViewModel, EMVehicle>(view);
                EMVehicle oldEntity = service.Select(view.VehicleCode);
                entity.ExpireTime = oldEntity.ExpireTime;
                entity.InstallTime = oldEntity.InstallTime;
                entity.CreateTime = oldEntity.CreateTime;
                entity.IsStop = oldEntity.IsStop;
                EMGpsType gpsTypeEntity = gpsTypeService.Get(entity.GPSTypeID);
                entity.GPSTypeName = gpsTypeEntity.TypeName;
                //如果设备号改变,要重新获取GPSCode,添加和修改日志
                if (entity.DeviceNo != oldEntity.DeviceNo)
                {
                    bool bo = service.IsExist(view.DeviceNo);
                    if (bo != true)
                    {

                        EnumGPSCodeRule codeType = (EnumGPSCodeRule)gpsTypeEntity.GPSCodeRule;

                        entity.GPSCode = GetGPSCodeHelper.GetGPSCode(gpsTypeEntity.PrefixCode, codeType, entity.SIMNo, entity.DeviceNo);
                        if (entity.DeviceNo.Length == gpsTypeEntity.MachineCodeLength)
                        {
                            //修改上一个日志
                            DateTime now = DateTime.Now;
                            EMVehicleLog lastLog = logService.GetLast(entity.VehicleCode);
                            if (lastLog != null)
                            {
                                lastLog.EndDate = now;
                                logService.Update(lastLog);
                            }

                            //新增一个日志
                            EMVehicleLog vehicleLog = new EMVehicleLog()
                            {
                                BeginDate = now,
                                LogID = noService.GetVehicleLogID(),
                                DeviceNo = entity.DeviceNo,
                                EndDate = null,
                                GPSCode = entity.GPSCode,
                                GPSTypeID = entity.GPSTypeID,
                                InitMileage = entity.InitMileage,
                                LicenceNumber = entity.LicenceNumber,
                                Operator = view.UserName,
                                SIMNo = entity.SIMNo,
                                TenantCode = entity.TenantCode,
                                GroupID = entity.GroupID,
                                VehicleCode = entity.VehicleCode
                            };
                            logService.Insert(vehicleLog);

                            entity.InstallTime = DateTime.Now;
                            service.Update(entity);
                            result.IsSuccess = true;
                        }
                        else
                        {
                            result.IsSuccess = false;
                            result.Message = "GPS设备号长度,不在指定范围内,请重新填写!";
                        }
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Message = "GPS设备号已存在,请重新填写!";
                    }
                }
                else
                {
                    service.Update(entity);
                    result.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message = ex.Message;
            }
            return result;
        }
 public DBProcessResult ChangeDeviceStopState(Guid vehicleCode, bool isStop)
 {
     DBProcessResult result = new DBProcessResult();
     try
     {
         IEMVehicleService service = new EMVehicleService();
         EMVehicle model = service.Select(vehicleCode);
         model.IsStop = isStop;
         service.Update(model);
         result.IsSuccess = true;
     }
     catch (Exception ex)
     {
         result.IsSuccess = false;
         result.Message = ex.Message;
     }
     return result;
 }
        public DBProcessResult ModifyVehicle(VehicleViewModel view)
        {
            DBProcessResult result = new DBProcessResult();
            try
            {
                IEMVehicleService service = new EMVehicleService();
                EMVehicle entity = ConvertHelper.ConvertObj<VehicleViewModel, EMVehicle>(view);

                //同一租户下车牌号码不能重复
                EMVehicle old = service.Select(view.VehicleCode);
                if (old.LicenceNumber != entity.LicenceNumber)
                {
                    bool licenceNumberIsExist = service.IsExist(entity.TenantCode, entity.LicenceNumber);
                    if (licenceNumberIsExist)
                    {
                        result.IsSuccess = false;
                        result.Message = "已经有相同车牌号的车辆";
                        return result;
                    }
                }

                service.Update(entity);
                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message = ex.Message;
            }
            return result;
        }
示例#7
0
 /// <summary>
 /// 移动车辆到指定车辆组
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="userName"></param>
 /// <returns></returns>
 public DBProcessResult MoveVehicle(Guid vehicleCode, ulong groupID)
 {
     DBProcessResult result = new DBProcessResult();
     try
     {
         IEMVehicleService service = new EMVehicleService();
         EMVehicle entity = service.Select(vehicleCode);
         if (entity == null)
         {
             result.IsSuccess = false;
             result.Message = "移动失败,车辆不存在!";
             return result;
         }
         entity.GroupID = groupID;
         service.Update(entity);
         result.IsSuccess = true;
     }
     catch (Exception ex)
     {
         result.IsSuccess = false;
         result.Message = ex.Message;
     }
     return result;
 }
示例#8
0
 /// <summary>
 /// 获取车辆信息
 /// </summary>
 /// <param name="vehicleCode"></param>
 /// <returns></returns>
 public EMVehicle GetVehicle(Guid vehicleCode)
 {
     IEMVehicleService service = new EMVehicleService();
     return service.Select(vehicleCode);
 }
 public decimal CalculateTotalMileage(Guid vehicleCode, decimal processMileage)
 {
     IEMVehicleService manager = new EMVehicleService();
     EMVehicle vehicle = manager.Select(vehicleCode);
     decimal initMileage = vehicle == null ? 0 : vehicle.InitMileage;
     return initMileage + processMileage;
 }