Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.10 KB | None | 0 0
  1. try {
  2.  
  3. con = new Conexion();
  4. query = "SELECT Nro_Documento,Nombres,Horas_registradas_en_jira,Proyecto,Horas_laboradas_sin_extras_y_sin_novedades FROM tbljira ORDER BY Proyecto";
  5. st = con.getConn().prepareStatement(query);
  6.  
  7. res = st.executeQuery();
  8.  
  9. while (res.next()) {
  10. TablaJira j = new TablaJira();
  11. j.setNro_Documento(res.getString("Nro_Documento"));
  12. j.setNombres(res.getString("Nombres"));
  13. j.setHoras_registradas_en_jira(res.getDouble("Horas_registradas_en_jira"));
  14. j.setProyecto(res.getString("proyecto"));
  15. j.setHoras_laboradas_sin_extras_sin_novedades(res.getDouble("Horas_laboradas_sin_extras_y_sin_novedades"));
  16. Jira.add(j);
  17.  
  18. }
  19.  
  20. for (int j = 0; j < Jira.size(); j++) {
  21.  
  22. String ide = Jira.get(j).getNro_Documento();
  23. String name = Jira.get(j).getNombres();
  24. Double h = Jira.get(j).getHoras_registradas_en_jira();
  25. String proyec = Jira.get(j).getProyecto();
  26. Double time = Jira.get(j).getHoras_laboradas_sin_extras_sin_novedades();
  27.  
  28. if (j == 0) {
  29. idean = ide;
  30. nombrean = name;
  31. timea = h;
  32. proan = proyec;
  33. horat = time;
  34.  
  35. } else if (ide.equals(idean) & proyec.equals(proan)) {
  36.  
  37. suma = suma + h;
  38. idean = ide;
  39. proan = proyec;
  40. nombrean = name;
  41.  
  42. horat = time;
  43. } else {
  44. det = new Detalle_Servicios();
  45. if (suma == 0) {
  46. total = timea / horat;
  47. totalco = total * 100;
  48. BigDecimal bd = new BigDecimal(totalco);
  49. bd = bd.setScale(2, RoundingMode.HALF_UP);
  50.  
  51. det.setPorcentaje_dedicacion(bd.doubleValue());
  52. det.setHoras_laboradas_mes(horat);
  53. det.setNombre_empleado(nombrean);
  54. det.setNro_Documento(idean);
  55. det.setHoras_dedicadas_Servicio(timea);
  56. det.setNombre_proyecto(proan);
  57. lst.add(det);
  58.  
  59. nombrean = name;
  60. horat = time;
  61. idean = ide;
  62. proan = proyec;
  63. timea = 0.0;
  64. suma = h;
  65.  
  66. } else {
  67. total = suma / horat;
  68. totalco = total * 100;
  69. BigDecimal bd = new BigDecimal(totalco);
  70. bd = bd.setScale(2, RoundingMode.HALF_UP);
  71. det.setPorcentaje_dedicacion(bd.doubleValue());
  72. det.setHoras_laboradas_mes(horat);
  73. det.setNombre_empleado(nombrean);
  74. det.setNro_Documento(idean);
  75. det.setHoras_dedicadas_Servicio(suma);
  76. det.setNombre_proyecto(proan);
  77. lst.add(det);
  78.  
  79. nombrean = name;
  80. horat = time;
  81. idean = ide;
  82. proan = proyec;
  83.  
  84. suma = h;
  85.  
  86. }
  87. if (j + 1 == Jira.size()) {
  88. if (ide.equals(idean) & proyec.equals(proan)) {
  89. det = new Detalle_Servicios();
  90. total = suma / horat;
  91. totalco = total * 100;
  92. BigDecimal bd = new BigDecimal(totalco);
  93. bd = bd.setScale(2, RoundingMode.HALF_UP);
  94. det.setNombre_proyecto(proan);
  95. det.setPorcentaje_dedicacion(bd.doubleValue());
  96. det.setHoras_laboradas_mes(horat);
  97. det.setNombre_empleado(nombrean);
  98. det.setNro_Documento(idean);
  99. det.setHoras_dedicadas_Servicio(suma);
  100.  
  101. lst.add(det);
  102. }
  103. }
  104. }
  105. }
  106. XSSFWorkbook wb = new XSSFWorkbook();
  107. XSSFSheet sheet = wb.createSheet();
  108. CellStyle style = wb.createCellStyle();
  109. DataFormat forma = wb.createDataFormat();
  110. Font font = wb.createFont();
  111. font.setFontName("Arial");
  112. style.setFillForegroundColor((short) 30);
  113. style.setBottomBorderColor((short) 8);
  114.  
  115. style.setFillPattern(CellStyle.SOLID_FOREGROUND);
  116. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  117. style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
  118. style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  119. style.setWrapText(true);
  120. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  121. font.setColor(HSSFColor.WHITE.index);
  122. style.setFont(font);
  123.  
  124. XSSFRow row = sheet.createRow(1);
  125. XSSFCell cell;
  126.  
  127. row.createCell(1).setCellValue("Nombre Empleado");
  128. row.getCell(1).setCellStyle(style);
  129.  
  130. row.createCell(2).setCellValue("Proyecto");
  131. row.getCell(2).setCellStyle(style);
  132.  
  133. row.createCell(3).setCellValue("Horas Dedicadas al servicios");
  134. row.getCell(3).setCellStyle(style);
  135.  
  136. row.createCell(4).setCellValue("Horas laboradas");
  137. row.getCell(4).setCellStyle(style);
  138.  
  139. row.createCell(5).setCellValue("Porcentaje de dedicacion");
  140. row.getCell(5).setCellStyle(style);
  141.  
  142. int i = 2;
  143. for (int n = 0; n < lst.size(); n++) {
  144. nom = lst.get(n).getNombre_empleado();
  145.  
  146. pro = lst.get(n).getNombre_proyecto();
  147. sum = lst.get(n).getHoras_dedicadas_Servicio();
  148. to = lst.get(n).getPorcentaje_dedicacion();
  149. horat = lst.get(n).getHoras_laboradas_mes();
  150. row = sheet.createRow(i++);
  151. cell = row.createCell(1);
  152. cell.setCellValue(nom);
  153. cell = row.createCell(2);
  154. cell.setCellValue(pro);
  155. cell = row.createCell(3);
  156. cell.setCellValue(sum);
  157. cell = row.createCell(4);
  158. cell.setCellValue(horat);
  159. cell = row.createCell(5);
  160. cell.setCellValue(to);
  161.  
  162. }
  163.  
  164. try {
  165. String ex = "ensayo";
  166.  
  167. try (FileOutputStream archivo = new FileOutputStream("E:/copia/" + ex + ".xlsx")) {
  168. wb.write(archivo);
  169. archivo.close();
  170. }
  171.  
  172. } catch (IOException e) {
  173. System.out.println(e);
  174.  
  175. }
  176. } catch (SQLException ex) {
  177. System.out.println(ex);
  178. Logger.getLogger(Detalle_ServiciosDao.class.getName()).log(Level.SEVERE, null, ex);
  179. }
  180.  
  181. }
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement