public ActionResult Excluir(int id, TipoAgendamento tipoAgendamento) { try { var agendamento = _agendamentoRepositorio.ObterAgendamentoPorId(id, tipoAgendamento); if (agendamento == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Agendamento não encontrado")); } if (agendamento.TransportadoraId != User.ObterTransportadoraId()) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Agendamento não pertence a transportadora")); } if (agendamento.DataEntrada != null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Exclusão não permitida. A Carga já entrou no Terminal")); } _agendamentoRepositorio.Excluir(agendamento.Id, agendamento.TipoAgendamento); } catch { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(new HttpStatusCodeResult(HttpStatusCode.NoContent)); }
public ActionResult AtualizarVeiculo(int agendamentoId, int veiculoId, TipoAgendamento tipoAgendamento) { var agendamentoBusca = _agendamentoRepositorio.ObterAgendamentoPorId(agendamentoId, tipoAgendamento); if (agendamentoBusca == null) { return(RetornarErro("Agendamento inexistente")); } var veiculoBusca = _veiculoRepositorio.ObterVeiculoPorId(veiculoId); if (veiculoBusca == null) { return(RetornarErro("Veículo inexistente")); } if (agendamentoBusca.TransportadoraId != User.ObterTransportadoraId()) { return(RetornarErro("Este agendamento não pertence a esta Transportadora")); } ValidarBDCCVeiculo(veiculoBusca); _agendamentoRepositorio.AtualizarVeiculoAgendamento(agendamentoId, veiculoId, agendamentoBusca.TipoAgendamento); return(new HttpStatusCodeResult(HttpStatusCode.NoContent)); }
public ActionResult AtualizarMotorista(int agendamentoId, int motoristaId, TipoAgendamento tipoAgendamento) { var agendamentoBusca = _agendamentoRepositorio.ObterAgendamentoPorId(agendamentoId, tipoAgendamento); if (agendamentoBusca == null) { return(RetornarErro("Agendamento inexistente")); } var motoristaBusca = _motoristaRepositorio.ObterMotoristaPorId(motoristaId); if (motoristaBusca == null) { return(RetornarErro("Motorista inexistente")); } if (agendamentoBusca.TransportadoraId != User.ObterTransportadoraId()) { return(RetornarErro("Este agendamento não pertence a esta Transportadora")); } ValidarBDCCMotorista(motoristaBusca); _agendamentoRepositorio.AtualizarMotoristaAgendamento(agendamentoId, motoristaId, agendamentoBusca.TipoAgendamento); return(new HttpStatusCodeResult(HttpStatusCode.NoContent)); }
public Agendamento( int motoristaId, int veiculoId, string cte, int transportadoraId, int periodoId, int recintoTRA, string recintoDEPOT, TipoOperacao tipoOperacao, TipoAgendamento tipoAgendamento, int quantidade, bool imo, bool excesso, int usuarioId) { MotoristaId = motoristaId; VeiculoId = veiculoId; CTE = cte; TransportadoraId = transportadoraId; PeriodoId = periodoId; RecintoTRA = recintoTRA; RecintoDEPOT = recintoDEPOT; TipoOperacao = tipoOperacao; TipoAgendamento = tipoAgendamento; Quantidade = quantidade; IMO = imo; Excesso = excesso; UsuarioId = usuarioId; }
public PartialViewResult ObterPeriodos(TipoAgendamento tipoAgendamento) { var viewModel = new AgendamentoViewModel(); viewModel.TipoAgendamento = tipoAgendamento; ObterPeriodos(viewModel); return(PartialView("_Periodos", viewModel.Periodos)); }
public IEnumerable <Janela> ObterPeriodos(TipoAgendamento tipoAgendamento) { using (OracleConnection con = new OracleConnection(AppConfig.StringConexao())) { var parametros = new DynamicParameters(); if (tipoAgendamento == TipoAgendamento.TRA) { return(con.Query <Janela>(@" SELECT AUTONUM_GD_RESERVA As Id, PERIODO_INICIAL As PeriodoInicial, PERIODO_FINAL As PeriodoFinal, LIMITE_MOVIMENTOS - (SELECT TO_NUMBER(COUNT(1)) FROM OPERADOR.TB_AGENDAMENTO_TRA WHERE AUTONUM_PERIODO = AUTONUM_GD_RESERVA) AS Saldo FROM OPERADOR.TB_GD_RESERVA WHERE SERVICO_GATE = 'T' AND PERIODO_INICIAL > SYSDATE AND (LIMITE_MOVIMENTOS - (SELECT TO_NUMBER(COUNT(1)) FROM OPERADOR.TB_AGENDAMENTO_TRA WHERE AUTONUM_PERIODO = AUTONUM_GD_RESERVA)) > 0 ORDER BY PERIODO_INICIAL ASC", parametros)); } else { return(con.Query <Janela>(@" SELECT AUTONUM_GD_RESERVA As Id, PERIODO_INICIAL As PeriodoInicial, PERIODO_FINAL As PeriodoFinal, LIMITE_MOVIMENTOS - (SELECT TO_NUMBER(COUNT(1)) FROM OPERADOR.TB_AGENDAMENTO_DEPOT WHERE AUTONUM_PERIODO = AUTONUM_GD_RESERVA) AS Saldo FROM OPERADOR.TB_GD_RESERVA WHERE SERVICO_GATE = 'D' AND PERIODO_INICIAL > SYSDATE AND (LIMITE_MOVIMENTOS - (SELECT TO_NUMBER(COUNT(1)) FROM OPERADOR.TB_AGENDAMENTO_DEPOT WHERE AUTONUM_PERIODO = AUTONUM_GD_RESERVA)) > 0 ORDER BY PERIODO_INICIAL ASC", parametros)); } } }
public Agendamento( int motivoId, DateTime dataPrevista, string clienteCpfCnpj, int novaViagemId, TipoAgendamento tipoAgendamento, int despachanteId) { MotivoId = motivoId; DataPrevista = dataPrevista; ClienteCpfCnpj = clienteCpfCnpj; NovaViagemId = novaViagemId; TipoAgendamento = tipoAgendamento; DespachanteId = despachanteId; }
public ActionResult Protocolo(int id, TipoAgendamento tipoAgendamento) { var agendamento = _agendamentoRepositorio.ObterDadosProtocolo(id, tipoAgendamento); if (agendamento == null) { return(RedirectToAction(nameof(Index))); } var empresaBusca = _empresaRepositorio.ObterEmpresaPorId(1); if (empresaBusca == null) { throw new Exception($"Empresa não encontrada"); } var viewModel = new AgendamentoViewModel { Protocolo = string.Concat(agendamento.Protocolo.PadLeft(6, '0'), "/", agendamento.AnoProtocolo), MotoristaDescricao = agendamento.MotoristaDescricao, MotoristaCPF = agendamento.MotoristaCPF, MotoristaCNH = agendamento.MotoristaCNH, VeiculoDescricao = agendamento.VeiculoDescricao, PeriodoDescricao = agendamento.PeriodoDescricao, TransportadoraDescricao = agendamento.TransportadoraDescricao, TransportadoraDocumento = agendamento.TransportadoraDocumento, RecintoDescricao = agendamento.RecintoDescricao, CTE = agendamento.CTE, Empresa = empresaBusca, Quantidade = agendamento.Quantidade, IMO = agendamento.IMO, Excesso = agendamento.Excesso, DataCadastro = agendamento.DataCriacao, TipoAgendamento = agendamento.TipoAgendamento }; viewModel.RecintosTRA = _recintoRepositorio .ObterRecintos(User.ObterTransportadoraId(), TipoAgendamento.TRA) .ToList(); viewModel.RecintosDEPOT = _recintoRepositorio .ObterRecintos(User.ObterTransportadoraId(), TipoAgendamento.DEPOT) .ToList(); _agendamentoRepositorio.AtualizarProtocoloImpresso(agendamento.Id, agendamento.TipoAgendamento); return(new PdfActionResult(viewModel)); }
public IEnumerable <Recinto> ObterRecintos(int transportadoraId, TipoAgendamento tipoAgendamento) { using (OracleConnection con = new OracleConnection(AppConfig.StringConexao())) { var parametros = new DynamicParameters(); parametros.Add(name: "TransportadoraId", value: transportadoraId, direction: ParameterDirection.Input); if (tipoAgendamento == TipoAgendamento.TRA) { return(con.Query <Recinto>($@" SELECT DISTINCT B.CODE As Id, TRIM(B.DESCR) || ' (' || B.CGC || ')' As Descricao FROM OPERADOR.TB_TRANSPORTE_RECINTO A INNER JOIN OPERADOR.DTE_TB_RECINTOS B ON A.RECINTO = B.CODE WHERE A.TRANSPORTADORA = :TransportadoraId AND NVL(A.FLAG_ATIVO, 0) = 1 AND B.CODE IN (SELECT CODRECINTO FROM OPERADOR.VW_ESTOQUE_OP_CNTR_RECINTO)", parametros)); } else { return(con.Query <Recinto>($@" SELECT DISTINCT B.AUTONUM As Id, B.ID As Codigo, TRIM(B.NOME) || ' (' || B.CNPJ || ')' As Descricao FROM OPERADOR.TB_TRANSPORTE_DEPOT A INNER JOIN OPERADOR.VW_NAVIS_DEPOT B ON A.RECINTO = B.AUTONUM WHERE A.TRANSPORTADORA = :TransportadoraId AND NVL(A.FLAG_ATIVO, 0) = 1 AND B.ID IN (SELECT DISTINCT DEPOT FROM OPERADOR.VW_ESTOQUE_OP_CNTR_VZ_IMP)", parametros)); } } }
public void AtualizarProtocoloImpresso(int id, TipoAgendamento tipoAgendamento) { using (OracleConnection con = new OracleConnection(AppConfig.StringConexao())) { var parametros = new DynamicParameters(); parametros.Add(name: "AgendamentoId", value: id, direction: ParameterDirection.Input); if (tipoAgendamento == TipoAgendamento.TRA) { con.Execute(@"UPDATE OPERADOR.TB_AGENDAMENTO_TRA SET FLAG_IMPRESSO = 1 WHERE AUTONUM = :AgendamentoId", parametros); } else { con.Execute(@"UPDATE OPERADOR.TB_AGENDAMENTO_DEPOT SET FLAG_IMPRESSO = 1 WHERE AUTONUM = :AgendamentoId", parametros); } } }
public ActionResult Visualizar(int?id, TipoAgendamento tipoAgendamento) { if (id == null) { return(RedirectToAction(nameof(Index))); } var agendamento = _agendamentoRepositorio.ObterDetalhesAgendamento(id.Value, tipoAgendamento); if (agendamento == null) { return(RegistroNaoEncontrado()); } var viewModel = CarregarDadosAgendamento(agendamento); return(View(viewModel)); }
public void AtualizarVeiculoAgendamento(int agendamentoId, int veiculoId, TipoAgendamento tipoAgendamento) { using (OracleConnection con = new OracleConnection(AppConfig.StringConexao())) { var parametros = new DynamicParameters(); parametros.Add(name: "AgendamentoId", value: agendamentoId, direction: ParameterDirection.Input); parametros.Add(name: "VeiculoId", value: veiculoId, direction: ParameterDirection.Input); if (tipoAgendamento == TipoAgendamento.TRA) { con.Execute("UPDATE OPERADOR.TB_AGENDAMENTO_TRA SET AUTONUM_VEICULO = :VeiculoId WHERE AUTONUM = :AgendamentoId", parametros); } else { con.Execute("UPDATE OPERADOR.TB_AGENDAMENTO_DEPOT SET AUTONUM_VEICULO = :VeiculoId WHERE AUTONUM = :AgendamentoId", parametros); } } }
public ActionResult Concluido(int id, TipoAgendamento tipoAgendamento) { var agendamento = _agendamentoRepositorio.ObterDetalhesAgendamento(id, tipoAgendamento); if (agendamento == null) { return(RedirectToAction(nameof(Index))); } return(View(new AgendamentoViewModel { Id = agendamento.Id, Protocolo = string.Concat(agendamento.Protocolo.PadLeft(6, '0'), "/", agendamento.AnoProtocolo), MotoristaDescricao = agendamento.MotoristaDescricao, VeiculoDescricao = agendamento.VeiculoDescricao, PeriodoDescricao = agendamento.PeriodoDescricao, TransportadoraDescricao = agendamento.TransportadoraDescricao, RecintoDescricao = agendamento.RecintoDescricao, DataCadastro = agendamento.DataCriacao, TipoAgendamento = tipoAgendamento })); }
public Agendamento( int motoristaId, int veiculoId, string cte, int periodoId, int recintoTRA, string recintoDEPOT, int quantidade, bool imo, bool excesso, TipoAgendamento tipoAgendamento) { MotoristaId = motoristaId; VeiculoId = veiculoId; CTE = cte; PeriodoId = periodoId; RecintoTRA = recintoTRA; RecintoDEPOT = recintoDEPOT; Quantidade = quantidade; IMO = imo; Excesso = excesso; TipoAgendamento = tipoAgendamento; }
public void Excluir(int id, TipoAgendamento tipoAgendamento) { using (OracleConnection con = new OracleConnection(AppConfig.StringConexao())) { con.Open(); using (var transaction = con.BeginTransaction()) { var parametros = new DynamicParameters(); parametros.Add(name: "Id", value: id, direction: ParameterDirection.Input); if (tipoAgendamento == TipoAgendamento.TRA) { con.Execute(@"DELETE FROM OPERADOR.TB_AGENDAMENTO_TRA WHERE AUTONUM = :Id", parametros, transaction); } else { con.Execute(@"DELETE FROM OPERADOR.TB_AGENDAMENTO_DEPOT WHERE AUTONUM = :Id", parametros, transaction); } transaction.Commit(); } } }
public ActionResult ObterTotais(string recinto, TipoAgendamento tipoAgendamento) { var totalAgendado = 0; var totalEstoque = 0; if (tipoAgendamento == TipoAgendamento.TRA) { totalEstoque = _recintoRepositorio .ObterTotalEstoqueTRA(recinto.ToInt()); totalAgendado = _agendamentoRepositorio .ObterTotalAgendadoTRA(recinto.ToInt()); } else { totalEstoque = _recintoRepositorio .ObterTotalEstoqueDEPOT(recinto); totalAgendado = _agendamentoRepositorio .ObterTotalAgendadoDEPOT(recinto); } var disponiveis = totalEstoque - totalAgendado; if (disponiveis < 0) { disponiveis = 0; } return(Json(new { Total = totalEstoque, TotalAgendado = totalAgendado, Disponiveis = disponiveis }, JsonRequestBehavior.AllowGet)); }
public AgendamentoDTO ObterDadosProtocolo(int id, TipoAgendamento tipoAgendamento) { using (OracleConnection con = new OracleConnection(AppConfig.StringConexao())) { var parametros = new DynamicParameters(); parametros.Add(name: "Id", value: id, direction: ParameterDirection.Input); if (tipoAgendamento == TipoAgendamento.TRA) { return(con.Query <AgendamentoDTO>($@" SELECT A.AUTONUM As Id, B.AUTONUM As MotoristaId, B.NOME As MotoristaDescricao, B.CPF As MotoristaCPF, B.CNH As MotoristaCNH, C.AUTONUM AS VeiculoId, 'Cavalo: ' || C.PLACA_CAVALO || ' | Carreta: ' || C.PLACA_CARRETA As VeiculoDescricao, D.AUTONUM As TransportadoraId, D.RAZAO As TransportadoraDescricao, D.CGC As TransportadoraDocumento, F.DESCR As RecintoDescricao, A.AUTONUM_PERIODO AS PeriodoId, TO_CHAR(E.PERIODO_INICIAL, 'DD/MM/YYYY HH24:MI') || ' - ' || TO_CHAR(E.PERIODO_FINAL, 'HH24:MI') PeriodoDescricao, A.Protocolo, A.ANO_PROTOCOLO As AnoProtocolo, A.AUTONUM_USUARIO AS UsuarioId, A.FLAG_IMPRESSO AS Impresso, A.DATA_HORA As DataCriacao, A.AUTONUM_RECINTO As RecintoTRA, NULL As RecintoDEPOT, A.QUANTIDADE, NVL(A.IMO, 0) IMO, NVL(A.EXCESSO, 0) EXCESSO, A.CTE, 1 As TipoAgendamento FROM OPERADOR.TB_AGENDAMENTO_TRA A INNER JOIN OPERADOR.TB_AG_MOTORISTAS B ON A.AUTONUM_MOTORISTA = B.AUTONUM INNER JOIN OPERADOR.TB_AG_VEICULOS C ON A.AUTONUM_VEICULO = C.AUTONUM INNER JOIN OPERADOR.TB_CAD_TRANSPORTADORAS D ON A.AUTONUM_TRANSPORTADORA = D.AUTONUM INNER JOIN OPERADOR.TB_GD_RESERVA E ON A.AUTONUM_PERIODO = E.AUTONUM_GD_RESERVA INNER JOIN OPERADOR.DTE_TB_RECINTOS F ON A.AUTONUM_RECINTO = F.CODE WHERE A.AUTONUM = :Id", parametros).FirstOrDefault()); } else { return(con.Query <AgendamentoDTO>($@" SELECT A.AUTONUM As Id, B.AUTONUM As MotoristaId, B.NOME As MotoristaDescricao, B.CPF As MotoristaCPF, B.CNH As MotoristaCNH, C.AUTONUM AS VeiculoId, 'Cavalo: ' || C.PLACA_CAVALO || ' | Carreta: ' || C.PLACA_CARRETA As VeiculoDescricao, D.AUTONUM As TransportadoraId, D.RAZAO As TransportadoraDescricao, D.CGC As TransportadoraDocumento, F.NOME As RecintoDescricao, A.AUTONUM_PERIODO AS PeriodoId, TO_CHAR(E.PERIODO_INICIAL, 'DD/MM/YYYY HH24:MI') || ' - ' || TO_CHAR(E.PERIODO_FINAL, 'HH24:MI') PeriodoDescricao, A.Protocolo, A.ANO_PROTOCOLO As AnoProtocolo, A.AUTONUM_USUARIO AS UsuarioId, A.FLAG_IMPRESSO AS Impresso, A.DATA_HORA As DataCriacao, NULL As RecintoTRA, A.RECINTO As RecintoDEPOT, A.QUANTIDADE, NULL IMO, NULL EXCESSO, A.CTE, 2 As TipoAgendamento FROM OPERADOR.TB_AGENDAMENTO_DEPOT A INNER JOIN OPERADOR.TB_AG_MOTORISTAS B ON A.AUTONUM_MOTORISTA = B.AUTONUM INNER JOIN OPERADOR.TB_AG_VEICULOS C ON A.AUTONUM_VEICULO = C.AUTONUM INNER JOIN OPERADOR.TB_CAD_TRANSPORTADORAS D ON A.AUTONUM_TRANSPORTADORA = D.AUTONUM INNER JOIN OPERADOR.TB_GD_RESERVA E ON A.AUTONUM_PERIODO = E.AUTONUM_GD_RESERVA INNER JOIN OPERADOR.VW_NAVIS_DEPOT F ON A.RECINTO = F.ID WHERE A.AUTONUM = :Id", parametros).FirstOrDefault()); } } }
public Agendamento ObterAgendamentoPorId(int id, TipoAgendamento tipoAgendamento) { using (OracleConnection con = new OracleConnection(AppConfig.StringConexao())) { var parametros = new DynamicParameters(); parametros.Add(name: "Id", value: id, direction: ParameterDirection.Input); if (tipoAgendamento == TipoAgendamento.TRA) { return(con.Query <Agendamento>($@" SELECT A.AUTONUM As Id, B.AUTONUM As MotoristaId, C.AUTONUM AS VeiculoId, D.AUTONUM As TransportadoraId, E.AUTONUM_GD_RESERVA AS PeriodoId, A.Protocolo, A.AUTONUM_USUARIO AS UsuarioId, A.FLAG_IMPRESSO AS Impresso, A.DT_ENTRADA AS DataEntrada, A.Quantidade, 1 As TipoAgendamento FROM OPERADOR.TB_AGENDAMENTO_TRA A INNER JOIN OPERADOR.TB_AG_MOTORISTAS B ON A.AUTONUM_MOTORISTA = B.AUTONUM INNER JOIN OPERADOR.TB_AG_VEICULOS C ON A.AUTONUM_VEICULO = C.AUTONUM INNER JOIN OPERADOR.TB_CAD_TRANSPORTADORAS D ON A.AUTONUM_TRANSPORTADORA = D.AUTONUM INNER JOIN OPERADOR.TB_GD_RESERVA E ON A.AUTONUM_PERIODO = E.AUTONUM_GD_RESERVA WHERE A.AUTONUM = :Id", parametros).FirstOrDefault()); } else { return(con.Query <Agendamento>($@" SELECT A.AUTONUM As Id, B.AUTONUM As MotoristaId, C.AUTONUM AS VeiculoId, D.AUTONUM As TransportadoraId, E.AUTONUM_GD_RESERVA AS PeriodoId, A.Protocolo, A.AUTONUM_USUARIO AS UsuarioId, A.FLAG_IMPRESSO AS Impresso, A.DT_ENTRADA AS DataEntrada, A.Quantidade, 2 As TipoAgendamento FROM OPERADOR.TB_AGENDAMENTO_DEPOT A INNER JOIN OPERADOR.TB_AG_MOTORISTAS B ON A.AUTONUM_MOTORISTA = B.AUTONUM INNER JOIN OPERADOR.TB_AG_VEICULOS C ON A.AUTONUM_VEICULO = C.AUTONUM INNER JOIN OPERADOR.TB_CAD_TRANSPORTADORAS D ON A.AUTONUM_TRANSPORTADORA = D.AUTONUM INNER JOIN OPERADOR.TB_GD_RESERVA E ON A.AUTONUM_PERIODO = E.AUTONUM_GD_RESERVA WHERE A.AUTONUM = :Id", parametros).FirstOrDefault()); } } }
public IEnumerable <AgendamentoDTO> ObterAgendamentosPorPeriodoEVeiculo(int transportadoraId, int periodoId, int veiculoId, TipoAgendamento tipoAgendamento) { using (OracleConnection con = new OracleConnection(AppConfig.StringConexao())) { var parametros = new DynamicParameters(); parametros.Add(name: "TransportadoraId", value: transportadoraId, direction: ParameterDirection.Input); parametros.Add(name: "PeriodoId", value: periodoId, direction: ParameterDirection.Input); parametros.Add(name: "VeiculoId", value: veiculoId, direction: ParameterDirection.Input); var tabela = tipoAgendamento == TipoAgendamento.TRA ? "TB_AGENDAMENTO_TRA" : "TB_AGENDAMENTO_DEPOT"; return(con.Query <AgendamentoDTO>($@" SELECT A.AUTONUM As Id, B.AUTONUM As MotoristaId, B.NOME As MotoristaDescricao, C.AUTONUM AS VeiculoId, C.PLACA_CAVALO || ' / ' || C.PLACA_CARRETA As VeiculoDescricao, A.AUTONUM As TransportadoraId, D.RAZAO As TransportadoraDescricao, E.AUTONUM_GD_RESERVA AS PeriodoId, TO_CHAR(E.PERIODO_INICIAL, 'DD/MM HH24:MI') || ' - ' || TO_CHAR(E.PERIODO_FINAL, 'HH24:MI') PeriodoDescricao, A.Protocolo, TO_CHAR(A.DATA_HORA, 'YYYY') As AnoProtocolo, A.AUTONUM_USUARIO AS UsuarioId, A.FLAG_IMPRESSO AS Impresso, A.DT_ENTRADA AS DataEntrada FROM OPERADOR.{tabela} A INNER JOIN OPERADOR.TB_AG_MOTORISTAS B ON A.AUTONUM_MOTORISTA = B.AUTONUM INNER JOIN OPERADOR.TB_AG_VEICULOS C ON A.AUTONUM_VEICULO = C.AUTONUM INNER JOIN OPERADOR.TB_CAD_TRANSPORTADORAS D ON A.AUTONUM_TRANSPORTADORA = D.AUTONUM INNER JOIN OPERADOR.TB_GD_RESERVA E ON A.AUTONUM_PERIODO = E.AUTONUM_GD_RESERVA WHERE A.AUTONUM_TRANSPORTADORA = :TransportadoraId AND A.AUTONUM_VEICULO = :VeiculoId AND A.AUTONUM_PERIODO = :PeriodoId ORDER BY A.AUTONUM DESC", parametros)); } }
public void Update(TipoAgendamento obj) { throw new NotImplementedException(); }