Search in sources :

Example 1 with SolicitacaoPacespDTO

use of com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO in project trainning by fernandotomasio.

the class PacespController method saveSolicitacao.

@RequestMapping("/save_solicitacao_pacesp")
public String saveSolicitacao(Model model, @Valid SolicitacaoPacesp solicitacao, BindingResult bindingResult, WebRequest request) {
    String operation = request.getParameter("operation");
    solicitacao.setRascunho(true);
    if (operation.equals("salvar")) {
        solicitacao.setRascunho(false);
        if (bindingResult.hasErrors()) {
            model.addAttribute("solicitacao", solicitacao);
            return "form_solicitacao_pacesp";
        }
    }
    SolicitacaoPacespDTO dto = new SolicitacaoPacespDTO();
    if (solicitacao.getCustoUnitario() != null && !solicitacao.getCustoUnitario().equals("")) {
        dto.setCustoUnitario(Float.parseFloat(solicitacao.getCustoUnitario().replace(".", "").replace(",", ".")));
        if (dto.getCustoUnitario() < 1) {
            bindingResult.reject("custoUnitario", "erro");
            model.addAttribute("solicitacao", solicitacao);
            return "form_solicitacao_pacesp";
        }
    }
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    dto.setAno(2018);
    dto.setOrganizacaoProponente(organizationalService.findOrganizacao(solicitacao.getOrganizacaoProponenteId()));
    dto.setOrganizacaoSolicitante(organizationalService.findOrganizacao(solicitacao.getOrganizacaoSolicitanteId()));
    dto.setRascunho(solicitacao.isRascunho());
    dto.setAno(solicitacao.getAno());
    dto.setCidade(solicitacao.getCidade());
    dto.setCurso(solicitacao.getCurso());
    dto.setEstado(solicitacao.getEstado());
    dto.setJustificativa(solicitacao.getJustificativa());
    dto.setLocal(solicitacao.getLocal());
    dto.setPrioridade(solicitacao.getPrioridade());
    dto.setQuantidadeVagasCivil(solicitacao.getQuantidadeVagasCivil());
    dto.setQuantidadeVagasMilitar(solicitacao.getQuantidadeVagasMilitar());
    dto.setDuracao(solicitacao.getDuracao());
    dto.setObservacao(solicitacao.getObservacao());
    dto.setAprovado(solicitacao.isAprovado());
    dto.setQuantidadeVagasCivilAprovado(solicitacao.getQuantidadeVagasCivilAprovado());
    dto.setQuantidadeVagasMilitarAprovado(solicitacao.getQuantidadeVagasMilitarAprovado());
    if (solicitacao.getId() > 0) {
        dto.setId(solicitacao.getId());
        planningService.updateSolicitacaoPacesp(dto);
    } else {
        planningService.createSolicitacaoPacesp(dto);
    }
    return "redirect:solicitacoes_pacesp";
}
Also used : SolicitacaoPacespDTO(com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SolicitacaoPacespDTO

use of com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO in project trainning by fernandotomasio.

the class PacespController method editSolicitacao.

@RequestMapping("/edit_solicitacao_pacesp")
public String editSolicitacao(Model model, WebRequest request) {
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    SolicitacaoPacespDTO dto = planningService.findSolicitacaoPacesp(Long.parseLong(request.getParameter("solicitacaoId")));
    SolicitacaoPacesp solicitacao = new SolicitacaoPacesp();
    solicitacao.setId(dto.getId());
    solicitacao.setAno(dto.getAno());
    solicitacao.setCidade(dto.getCidade());
    solicitacao.setCurso(dto.getCurso());
    solicitacao.setCustoUnitario(dto.getCustoUnitarioFormatted());
    solicitacao.setObservacao(dto.getObservacao());
    solicitacao.setEstado(dto.getEstado());
    solicitacao.setJustificativa(dto.getJustificativa());
    solicitacao.setLocal(dto.getLocal());
    solicitacao.setOrganizacaoProponenteId(dto.getOrganizacaoProponente().getId());
    solicitacao.setOrganizacaoSolicitanteId(dto.getOrganizacaoSolicitante().getId());
    solicitacao.setPrioridade(dto.getPrioridade());
    solicitacao.setQuantidadeVagasCivil(dto.getQuantidadeVagasCivil());
    solicitacao.setQuantidadeVagasMilitar(dto.getQuantidadeVagasMilitar());
    solicitacao.setDuracao(dto.getDuracao());
    solicitacao.setQuantidadeVagasCivilAprovado(dto.getQuantidadeVagasCivilAprovado());
    solicitacao.setQuantidadeVagasMilitarAprovado(dto.getQuantidadeVagasMilitarAprovado());
    solicitacao.setAprovado(dto.isAprovado());
    model.addAttribute("solicitacao", solicitacao);
    return "form_solicitacao_pacesp";
}
Also used : SolicitacaoPacespDTO(com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO) SolicitacaoPacesp(com.tomasio.projects.trainning.form.SolicitacaoPacesp) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with SolicitacaoPacespDTO

use of com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO in project trainning by fernandotomasio.

the class HibernateSolicitacaoPacespDAO method findAll.

@SuppressWarnings("unchecked")
@Override
public List<SolicitacaoPacespDTO> findAll(int ano, Long organizacaoProponenteId, Long organizacaoSolicitanteId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Criteria criteria = session.createCriteria(SolicitacaoPacesp.class);
        if (ano > 0) {
            criteria.add(Restrictions.eq("ano", ano));
        }
        if (organizacaoProponenteId != null && organizacaoProponenteId > 0L) {
            criteria.add(Restrictions.eq("organizacaoProponente.id", organizacaoProponenteId));
        }
        if (organizacaoSolicitanteId != null && organizacaoSolicitanteId > 0L) {
            criteria.add(Restrictions.eq("organizacaoSolicitante.id", organizacaoSolicitanteId));
        }
        criteria.addOrder(Order.asc("organizacaoSolicitante.id"));
        criteria.addOrder(Order.asc("prioridade"));
        List<SolicitacaoPacesp> solicitacoes = criteria.list();
        List<SolicitacaoPacespDTO> dto = new ArrayList<SolicitacaoPacespDTO>();
        for (SolicitacaoPacesp solicitacao : solicitacoes) {
            dto.add(solicitacao.createDTO());
        }
        return dto;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateTreinamentoSolicitadoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("solicitacoes.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) SolicitacaoPacespDTO(com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO) HibernateException(org.hibernate.HibernateException) SolicitacaoPacesp(com.tomasio.projects.trainning.model.SolicitacaoPacesp) ArrayList(java.util.ArrayList) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 4 with SolicitacaoPacespDTO

use of com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO in project trainning by fernandotomasio.

the class PLN002XLS method makeReport.

@Override
public void makeReport() {
    PlanningService planningService = (PlanningService) services.get("planningService");
    int ano = (Integer) params.get("ano");
    try {
        WritableWorkbook workbook = Workbook.createWorkbook(os);
        WritableSheet sheet = workbook.createSheet("PLAMENS", 0);
        SolicitacaoPacespDTO[] solicitacoes = planningService.findAllSolicitacoesPacesp(ano, null, null);
        int i = 0;
        for (SolicitacaoPacespDTO dto : solicitacoes) {
            Label numeroMissaoLabel = new Label(0, i, "XX");
            sheet.addCell(numeroMissaoLabel);
            Label organizacaoProponenteLabel = null;
            if (dto.getOrganizacaoProponente() != null) {
                organizacaoProponenteLabel = new Label(1, i, dto.getOrganizacaoProponente().getSigla());
            } else {
                organizacaoProponenteLabel = new Label(1, i, "");
            }
            sheet.addCell(organizacaoProponenteLabel);
            Label anoLabel = new Label(2, i, Integer.toString(dto.getAno()));
            sheet.addCell(anoLabel);
            Label cursoLabel = new Label(3, i, dto.getCurso());
            sheet.addCell(cursoLabel);
            Label localLabel = new Label(4, i, dto.getLocal());
            sheet.addCell(localLabel);
            Label cidadeLabel = new Label(5, i, dto.getCidade());
            sheet.addCell(cidadeLabel);
            Label estadoLabel = new Label(6, i, dto.getEstado());
            sheet.addCell(estadoLabel);
            Label paisLabel = new Label(7, i, "");
            sheet.addCell(paisLabel);
            Label dataInicioLabel = null;
            dataInicioLabel = new Label(8, i, "");
            sheet.addCell(dataInicioLabel);
            Label dataTerminoLabel = null;
            dataTerminoLabel = new Label(9, i, "");
            sheet.addCell(dataTerminoLabel);
            Label duracaoLabel = new Label(10, i, String.valueOf(dto.getDuracao()));
            sheet.addCell(duracaoLabel);
            Label organizacaoSolicitanteLabel = null;
            if (dto.getOrganizacaoSolicitante() != null) {
                organizacaoSolicitanteLabel = new Label(11, i, dto.getOrganizacaoSolicitante().getSigla());
            } else {
                organizacaoSolicitanteLabel = new Label(11, i, "");
            }
            sheet.addCell(organizacaoSolicitanteLabel);
            Label quantidadeVagasLabel = new Label(12, i, String.valueOf(dto.getQuantidadeVagasCivil() + dto.getQuantidadeVagasMilitar()));
            sheet.addCell(quantidadeVagasLabel);
            Label postoIndicadosLabel = new Label(13, i, "");
            sheet.addCell(postoIndicadosLabel);
            Label destinoAposMissaoLabel = new Label(14, i, "");
            sheet.addCell(destinoAposMissaoLabel);
            Label funcaoAposMissaoLabel = new Label(15, i, "");
            sheet.addCell(funcaoAposMissaoLabel);
            Label quantidadeCursosLabel = new Label(16, i, "");
            sheet.addCell(quantidadeCursosLabel);
            Label ajudaCursoLabel = new Label(17, i, "");
            sheet.addCell(ajudaCursoLabel);
            Label diariasLabel = new Label(18, i, "");
            sheet.addCell(diariasLabel);
            Label custoCursoLabel = new Label(19, i, dto.getCustoTotalFormatted());
            sheet.addCell(custoCursoLabel);
            Label transportePessoaLabel = new Label(20, i, "");
            sheet.addCell(transportePessoaLabel);
            Label bagagemLabel = new Label(21, i, "");
            sheet.addCell(bagagemLabel);
            Label outrosLabel = new Label(22, i, "");
            sheet.addCell(outrosLabel);
            Label custoTotalLabel = new Label(23, i, dto.getCustoTotalFormatted());
            sheet.addCell(custoTotalLabel);
            Label anoTomadaPrecosLabel = new Label(24, i, "");
            sheet.addCell(anoTomadaPrecosLabel);
            Label preRequisitosLabel = new Label(25, i, "");
            sheet.addCell(preRequisitosLabel);
            Label justificativaLabel = new Label(26, i, dto.getJustificativa().toUpperCase());
            sheet.addCell(justificativaLabel);
            Label sistemaLabel = new Label(27, i, "");
            sheet.addCell(sistemaLabel);
            Label planoTransmissaoLabel = new Label(28, i, "");
            sheet.addCell(planoTransmissaoLabel);
            Label observacaoLabel = null;
            if (dto.getObservacao() != null) {
                observacaoLabel = new Label(29, i, dto.getObservacao().toUpperCase());
            } else {
                observacaoLabel = new Label(29, i, "");
            }
            sheet.addCell(observacaoLabel);
            Label tipoLabel = new Label(30, i, "");
            sheet.addCell(tipoLabel);
            i++;
        }
        workbook.write();
        workbook.close();
    } catch (RowsExceededException ex) {
        Logger.getLogger(PLN002XLS.class.getName()).log(Level.SEVERE, null, ex);
    } catch (WriteException ex) {
        Logger.getLogger(PLN002XLS.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(PLN002XLS.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : WritableWorkbook(jxl.write.WritableWorkbook) WriteException(jxl.write.WriteException) SolicitacaoPacespDTO(com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO) PlanningService(com.tomasio.projects.trainning.interfaces.PlanningService) Label(jxl.write.Label) WritableSheet(jxl.write.WritableSheet) IOException(java.io.IOException) RowsExceededException(jxl.write.biff.RowsExceededException)

Example 5 with SolicitacaoPacespDTO

use of com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO in project trainning by fernandotomasio.

the class PacespController method showIndex.

@RequestMapping("/solicitacoes_pacesp")
public String showIndex(Model model, @ModelAttribute("userOrganization") OrganizacaoDTO userOrganization, WebRequest request) {
    String organizacaoId = request.getParameter("organizacaoId");
    Set<OrganizacaoDTO> organizacoes = new HashSet<OrganizacaoDTO>();
    NumberFormat nf = NumberFormat.getCurrencyInstance();
    SolicitacaoPacespDTO[] solicitacoes;
    if (userOrganization instanceof ComandoDTO) {
        if (organizacaoId != null && !organizacaoId.equals("NULL")) {
            solicitacoes = planningService.findAllSolicitacoesPacesp(2018, userOrganization.getId(), Long.parseLong(organizacaoId));
        } else {
            solicitacoes = planningService.findAllSolicitacoesPacesp(2018, userOrganization.getId(), null);
        }
    } else {
        solicitacoes = planningService.findAllSolicitacoesPacesp(2018, null, userOrganization.getId());
    }
    for (SolicitacaoPacespDTO solicitacaoPacespDTO : solicitacoes) {
        organizacoes.add(solicitacaoPacespDTO.getOrganizacaoSolicitante());
    }
    model.addAttribute("solicitacoes", solicitacoes);
    model.addAttribute("organizacoes", organizacoes);
    float somaCustoTotal = 0;
    for (SolicitacaoPacespDTO solicitacaoPacespDTO : solicitacoes) {
        somaCustoTotal += solicitacaoPacespDTO.getCustoTotal();
    }
    model.addAttribute("somaCustoTotal", nf.format(somaCustoTotal).split(" ")[1]);
    return "solicitacoes_pacesp";
}
Also used : SolicitacaoPacespDTO(com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO) OrganizacaoDTO(com.tomasio.projects.trainning.dto.OrganizacaoDTO) ComandoDTO(com.tomasio.projects.trainning.dto.ComandoDTO) HashSet(java.util.HashSet) NumberFormat(java.text.NumberFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SolicitacaoPacespDTO (com.tomasio.projects.trainning.dto.SolicitacaoPacespDTO)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 NumberFormat (java.text.NumberFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ComandoDTO (com.tomasio.projects.trainning.dto.ComandoDTO)1 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)1 DAOException (com.tomasio.projects.trainning.exception.DAOException)1 SolicitacaoPacesp (com.tomasio.projects.trainning.form.SolicitacaoPacesp)1 PlanningService (com.tomasio.projects.trainning.interfaces.PlanningService)1 SolicitacaoPacesp (com.tomasio.projects.trainning.model.SolicitacaoPacesp)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Label (jxl.write.Label)1 WritableSheet (jxl.write.WritableSheet)1 WritableWorkbook (jxl.write.WritableWorkbook)1 WriteException (jxl.write.WriteException)1 RowsExceededException (jxl.write.biff.RowsExceededException)1 Criteria (org.hibernate.Criteria)1 HibernateException (org.hibernate.HibernateException)1