Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- con = new Conexion();
- query = "SELECT Nro_Documento,Nombres,Horas_registradas_en_jira,Proyecto,Horas_laboradas_sin_extras_y_sin_novedades FROM tbljira ORDER BY Proyecto";
- st = con.getConn().prepareStatement(query);
- res = st.executeQuery();
- while (res.next()) {
- TablaJira j = new TablaJira();
- j.setNro_Documento(res.getString("Nro_Documento"));
- j.setNombres(res.getString("Nombres"));
- j.setHoras_registradas_en_jira(res.getDouble("Horas_registradas_en_jira"));
- j.setProyecto(res.getString("proyecto"));
- j.setHoras_laboradas_sin_extras_sin_novedades(res.getDouble("Horas_laboradas_sin_extras_y_sin_novedades"));
- Jira.add(j);
- }
- for (int j = 0; j < Jira.size(); j++) {
- String ide = Jira.get(j).getNro_Documento();
- String name = Jira.get(j).getNombres();
- Double h = Jira.get(j).getHoras_registradas_en_jira();
- String proyec = Jira.get(j).getProyecto();
- Double time = Jira.get(j).getHoras_laboradas_sin_extras_sin_novedades();
- if (j == 0) {
- idean = ide;
- nombrean = name;
- timea = h;
- proan = proyec;
- horat = time;
- } else if (ide.equals(idean) & proyec.equals(proan)) {
- suma = suma + h;
- idean = ide;
- proan = proyec;
- nombrean = name;
- horat = time;
- } else {
- det = new Detalle_Servicios();
- if (suma == 0) {
- total = timea / horat;
- totalco = total * 100;
- BigDecimal bd = new BigDecimal(totalco);
- bd = bd.setScale(2, RoundingMode.HALF_UP);
- det.setPorcentaje_dedicacion(bd.doubleValue());
- det.setHoras_laboradas_mes(horat);
- det.setNombre_empleado(nombrean);
- det.setNro_Documento(idean);
- det.setHoras_dedicadas_Servicio(timea);
- det.setNombre_proyecto(proan);
- lst.add(det);
- nombrean = name;
- horat = time;
- idean = ide;
- proan = proyec;
- timea = 0.0;
- suma = h;
- } else {
- total = suma / horat;
- totalco = total * 100;
- BigDecimal bd = new BigDecimal(totalco);
- bd = bd.setScale(2, RoundingMode.HALF_UP);
- det.setPorcentaje_dedicacion(bd.doubleValue());
- det.setHoras_laboradas_mes(horat);
- det.setNombre_empleado(nombrean);
- det.setNro_Documento(idean);
- det.setHoras_dedicadas_Servicio(suma);
- det.setNombre_proyecto(proan);
- lst.add(det);
- nombrean = name;
- horat = time;
- idean = ide;
- proan = proyec;
- suma = h;
- }
- if (j + 1 == Jira.size()) {
- if (ide.equals(idean) & proyec.equals(proan)) {
- det = new Detalle_Servicios();
- total = suma / horat;
- totalco = total * 100;
- BigDecimal bd = new BigDecimal(totalco);
- bd = bd.setScale(2, RoundingMode.HALF_UP);
- det.setNombre_proyecto(proan);
- det.setPorcentaje_dedicacion(bd.doubleValue());
- det.setHoras_laboradas_mes(horat);
- det.setNombre_empleado(nombrean);
- det.setNro_Documento(idean);
- det.setHoras_dedicadas_Servicio(suma);
- lst.add(det);
- }
- }
- }
- }
- XSSFWorkbook wb = new XSSFWorkbook();
- XSSFSheet sheet = wb.createSheet();
- CellStyle style = wb.createCellStyle();
- DataFormat forma = wb.createDataFormat();
- Font font = wb.createFont();
- font.setFontName("Arial");
- style.setFillForegroundColor((short) 30);
- style.setBottomBorderColor((short) 8);
- style.setFillPattern(CellStyle.SOLID_FOREGROUND);
- style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
- style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- style.setWrapText(true);
- font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
- font.setColor(HSSFColor.WHITE.index);
- style.setFont(font);
- XSSFRow row = sheet.createRow(1);
- XSSFCell cell;
- row.createCell(1).setCellValue("Nombre Empleado");
- row.getCell(1).setCellStyle(style);
- row.createCell(2).setCellValue("Proyecto");
- row.getCell(2).setCellStyle(style);
- row.createCell(3).setCellValue("Horas Dedicadas al servicios");
- row.getCell(3).setCellStyle(style);
- row.createCell(4).setCellValue("Horas laboradas");
- row.getCell(4).setCellStyle(style);
- row.createCell(5).setCellValue("Porcentaje de dedicacion");
- row.getCell(5).setCellStyle(style);
- int i = 2;
- for (int n = 0; n < lst.size(); n++) {
- nom = lst.get(n).getNombre_empleado();
- pro = lst.get(n).getNombre_proyecto();
- sum = lst.get(n).getHoras_dedicadas_Servicio();
- to = lst.get(n).getPorcentaje_dedicacion();
- horat = lst.get(n).getHoras_laboradas_mes();
- row = sheet.createRow(i++);
- cell = row.createCell(1);
- cell.setCellValue(nom);
- cell = row.createCell(2);
- cell.setCellValue(pro);
- cell = row.createCell(3);
- cell.setCellValue(sum);
- cell = row.createCell(4);
- cell.setCellValue(horat);
- cell = row.createCell(5);
- cell.setCellValue(to);
- }
- try {
- String ex = "ensayo";
- try (FileOutputStream archivo = new FileOutputStream("E:/copia/" + ex + ".xlsx")) {
- wb.write(archivo);
- archivo.close();
- }
- } catch (IOException e) {
- System.out.println(e);
- }
- } catch (SQLException ex) {
- System.out.println(ex);
- Logger.getLogger(Detalle_ServiciosDao.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement