Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 129.08 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package com.side.oleoducto;
  6.  
  7. import com.side.oleoducto.estatico.LEComboTipoParametro;
  8. import com.side.oleoducto.estatico.LEComboTipoReparacion;
  9. import com.side.oleoducto.general.Funciones;
  10. import static com.side.oleoducto.general.Funciones.getExtenciones;
  11. import static com.side.oleoducto.general.Funciones.tipoArchvioExtension;
  12. import com.side.oleoducto.mantenimiento.ArchivosDtoLocal;
  13. import com.side.oleoducto.mantenimiento.JuntaDtoLocal;
  14. import com.side.oleoducto.mantenimiento.JuntaReparcionDtoLocal;
  15. import com.side.oleoducto.mantenimiento.ParametrosDtoLocal;
  16. import com.side.oleoducto.persistencia.Archivo;
  17. import com.side.oleoducto.persistencia.Junta;
  18. import com.side.oleoducto.persistencia.JuntaReparcion;
  19. import com.side.oleoducto.persistencia.LibroTuberia;
  20. import com.side.oleoducto.persistencia.Parametros;
  21. import com.side.oleoducto.persistencia.Usuario;
  22. import com.sun.faces.util.CollectionsUtils;
  23. import java.io.ByteArrayOutputStream;
  24. import java.io.File;
  25. import java.io.FileInputStream;
  26. import java.io.IOException;
  27. import java.util.ArrayList;
  28. import java.util.Date;
  29. import java.util.HashMap;
  30. import java.util.Iterator;
  31. import java.util.List;
  32. import java.util.Map;
  33. import java.util.logging.Level;
  34. import java.util.logging.Logger;
  35. import javax.ejb.EJB;
  36. import javax.naming.Context;
  37. import javax.naming.InitialContext;
  38. import javax.naming.NamingException;
  39.  
  40. /**
  41. *
  42. * @author Usuario
  43. */
  44. public class CargaArchivos extends Thread {
  45.  
  46. ArchivosDtoLocal archivosDto = lookupArchivosDtoLocal();
  47. JuntaReparcionDtoLocal juntaReparcionDto = lookupJuntaReparcionDtoLocal();
  48. JuntaDtoLocal juntaDto = lookupJuntaDtoLocal();
  49. private ParametrosDtoLocal parametrosDto = lookupParametrosDtoLocal();
  50. private List<Junta> juntas;
  51. private Usuario usuario;
  52. private String carpetaLectura;
  53. private String separador;
  54. private int hilo;
  55. private boolean soloInformes = false;
  56. private boolean busquedaTotalTramo;
  57. private LibroTuberia libroTuberia;
  58. private HashMap<String, ArchivoImagenJunta> juntasF2 = new HashMap<String, ArchivoImagenJunta>();
  59. //private HashMap<String, File> juntasF = new HashMap<String, File>();
  60. private HashMap<String, File> infoRX = new HashMap<String, File>();
  61. private HashMap<String, File> infoUsa = new HashMap<String, File>();
  62. private HashMap<Short, String> parametros = null;
  63.  
  64. public CargaArchivos(List<Junta> juntas, Usuario usuario, String carpetaLectura, String separador, int hilo, LibroTuberia lib, boolean soloInformes, boolean busquedaTotalTramo) {
  65. this.juntas = juntas;
  66. this.usuario = usuario;
  67. this.carpetaLectura = carpetaLectura + separador;
  68. this.separador = separador;
  69. this.hilo = hilo;
  70. this.libroTuberia = lib;
  71. this.soloInformes = soloInformes;
  72. this.busquedaTotalTramo = busquedaTotalTramo;
  73. }
  74.  
  75. public CargaArchivos(List<Junta> juntas, Usuario usuario, String carpetaLectura, String separador, int hilo, LibroTuberia lib) {
  76. this.juntas = juntas;
  77. this.usuario = usuario;
  78. this.carpetaLectura = carpetaLectura + separador;
  79. this.separador = separador;
  80. this.hilo = hilo;
  81. this.libroTuberia = lib;
  82. }
  83.  
  84. @Override
  85. public void run() {
  86. try {
  87. boolean sigue = true;
  88. boolean multiple = false;
  89. if (juntas == null) {
  90. multiple = true;
  91. }
  92. File carpetaImagenes = new File(this.carpetaLectura + "imagenes" + separador);
  93. String tipoLibro = getParametros().get(LEComboTipoParametro.TIPO_LIBRO.getId());
  94. if (tipoLibro.equals("FORMATO2")) {
  95. carpetaImagenes = new File(this.carpetaLectura + libroTuberia.getSegmento().getCarpeta() + separador);
  96. }
  97. if (this.juntasF2.size() == 0) {
  98. buscaArchivoImagenesMap(carpetaImagenes, libroTuberia.getSegmento().getCarpeta());
  99. }
  100.  
  101. // if(true){
  102. // return;
  103. // }
  104. File carpetaInformes = null;
  105. if (this.infoRX != null && this.infoRX.size() == 0 && (!libroTuberia.getSegmento().getCarpeta().equals("CUPIAGUA-CUSIANA"))) {
  106. carpetaInformes = new File(this.carpetaLectura + "informes RX" + separador);
  107. this.buscaArchivoInformeRXMap(carpetaInformes);
  108. }
  109.  
  110. File carpetaInformesUs = new File(this.carpetaLectura + "informes ultrasonido" + separador);
  111. this.buscaArchivoInformeUSAMap(carpetaInformesUs);
  112. while (sigue) {
  113.  
  114. if (multiple) {
  115. juntas = null;
  116. juntas = this.juntaDto.busquedaXLibro(libroTuberia, true, "");
  117. if (juntas.isEmpty()) {
  118. juntas = this.juntaDto.busquedaXLibro2(libroTuberia, true);
  119. }
  120. if (juntas.isEmpty()) {
  121. sigue = false;
  122. }
  123. }
  124. if (juntas.isEmpty()) {
  125. sigue = false;
  126. }
  127. int temm = 0;
  128.  
  129. LiberaMemoria(juntas.size());
  130.  
  131. for (int i = 0; i < juntas.size(); i++) {
  132. if ((temm % 10) == 0) {
  133. // LiberaMemoria(hilo);
  134. consola2("Archivos Cargados " + temm + " de " + juntas.size() + " hilo " + hilo + " seg " + libroTuberia.getSegmento().getNombre() + " id " + libroTuberia.getSegmento().getCodigo());
  135. } else if (i == (juntas.size() - 1)) {
  136. // LiberaMemoria(hilo);
  137. consola2("FIN Archivos Cargados " + temm + " de " + juntas.size() + " hilo " + hilo + " seg " + libroTuberia.getSegmento().getNombre() + " id " + libroTuberia.getSegmento().getCodigo());
  138. }
  139.  
  140. temm++;
  141.  
  142. Junta tem = juntas.get(i);
  143. try {
  144. // String carpetaDestino = "C:\\archivosJuntas\\Segmento" + juntas.get(0).getTuboInicial().getSegmento().getCodigo() + "\\KM" + tem.getHoja();
  145. // new File(carpetaDestino).mkdirs();
  146. String nombreArchivoCorto = tem.getNumeroSoldadura().replaceAll("/", "");
  147. consola(nombreArchivoCorto);
  148. if (tem.getNumeroSoldadura().equals("K200/J1")) {
  149. consola(nombreArchivoCorto);
  150. }
  151. tipoLibro = getParametros().get(LEComboTipoParametro.TIPO_LIBRO.getId());
  152. if (tipoLibro.equals("FORMATO2")) {
  153. nombreArchivoCorto = tem.getNumeroSoldadura().replaceAll("/", "");
  154. }
  155.  
  156. if (tipoLibro.equals("FORMATO2")) {
  157. nombreArchivoCorto = nombreArchivoCorto.replaceAll("PK", "");
  158. } else if (nombreArchivoCorto.indexOf("PK") < 0) {
  159. nombreArchivoCorto = "PK" + tem.getHoja() + nombreArchivoCorto;
  160. }
  161. if (tem.getHojaReal().equals("SCARF 50002 KMO")) {
  162. nombreArchivoCorto = "SCARF50002" + nombreArchivoCorto;
  163. } else if (tem.getHojaReal().equals("SCARF 50002 KM1")) {
  164. nombreArchivoCorto = "SCARF50002" + nombreArchivoCorto;
  165. } else if (tem.getHojaReal().equals("M.TRAM 50001")) {
  166. nombreArchivoCorto = "TRAMP" + nombreArchivoCorto;
  167. } else if (tem.getHojaReal().equals("M.TRAMP 50003")) {
  168. nombreArchivoCorto = "TRAMP" + nombreArchivoCorto;
  169. } else if (tem.getHojaReal().equals("TIEIN-KM31")) {
  170. nombreArchivoCorto = "TIEIN" + nombreArchivoCorto;
  171. } else if (tem.getHojaReal().equals("CPF-CUS-K34")) {
  172. nombreArchivoCorto = "CPFCUSK34" + nombreArchivoCorto.replaceAll("CPF CUS ", "");
  173. }
  174.  
  175. //carpeta = new File(this.carpetaLectura + "imagenes" + separador);
  176. if (!soloInformes) {
  177. List<File> archivosImagenes1 = new ArrayList<File>();
  178. if (this.busquedaTotalTramo) {
  179. archivosImagenes1 = buscaArchivoImagenesTotalTramo(carpetaImagenes, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem, null, true);
  180. if (archivosImagenes1.isEmpty() && tem.getHojaReal().length() > 2
  181. && tem.getHojaReal().substring(tem.getHojaReal().length() - 2, tem.getHojaReal().length()).toUpperCase().equals("LR")) {
  182. archivosImagenes1 = buscaArchivoImagenesTotalTramo(carpetaImagenes, (nombreArchivoCorto.replaceAll("LR", "")).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem, null, true);
  183. }
  184. if (archivosImagenes1.isEmpty() && tem.getHojaReal().length() > 2
  185. && tem.getHojaReal().substring(tem.getHojaReal().length() - 2, tem.getHojaReal().length()).toUpperCase().equals("OE")) {
  186. archivosImagenes1 = buscaArchivoImagenesTotalTramo(carpetaImagenes, (nombreArchivoCorto.replaceAll("OE", "")).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem, null, true);
  187. }
  188. if (archivosImagenes1.isEmpty()
  189. && (nombreArchivoCorto.toUpperCase().lastIndexOf("E") < 0
  190. || (nombreArchivoCorto.toUpperCase().lastIndexOf("E") > 0
  191. && nombreArchivoCorto.toUpperCase().lastIndexOf("E") != nombreArchivoCorto.length()))) {
  192. archivosImagenes1 = buscaArchivoImagenesTotalTramo(carpetaImagenes, (nombreArchivoCorto + "E").replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem, null, true);
  193. }
  194. if (archivosImagenes1.isEmpty()
  195. && nombreArchivoCorto.length() >1 && !nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length() ).equals("O")
  196. && nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length()).equals("E")) {
  197. archivosImagenes1 = buscaArchivoImagenesTotalTramo(carpetaImagenes, (nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 1)).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem, null, true);
  198. }
  199. } else {
  200. archivosImagenes1 = buscaArchivoImagenes(carpetaImagenes, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem);
  201.  
  202. if (archivosImagenes1.isEmpty() && tem.getHojaReal().length() > 2
  203. && tem.getHojaReal().substring(tem.getHojaReal().length() - 2, tem.getHojaReal().length()).toUpperCase().equals("LR")) {
  204. archivosImagenes1 = buscaArchivoImagenes(carpetaImagenes, (nombreArchivoCorto.replaceAll("LR", "")).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem);
  205. }
  206. if (archivosImagenes1.isEmpty() && tem.getHojaReal().length() > 2
  207. && tem.getHojaReal().substring(tem.getHojaReal().length() - 2, tem.getHojaReal().length()).toUpperCase().equals("OE")) {
  208. archivosImagenes1 = buscaArchivoImagenes(carpetaImagenes, (nombreArchivoCorto.replaceAll("OE", "")).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem);
  209. }
  210.  
  211. if (archivosImagenes1.isEmpty()
  212. && (nombreArchivoCorto.toUpperCase().lastIndexOf("E") < 0
  213. || (nombreArchivoCorto.toUpperCase().lastIndexOf("E") > 0
  214. && nombreArchivoCorto.toUpperCase().lastIndexOf("E") != nombreArchivoCorto.length()))) {
  215. archivosImagenes1 = buscaArchivoImagenes(carpetaImagenes, (nombreArchivoCorto + "E").replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem);
  216. }
  217. if (archivosImagenes1.isEmpty()
  218. && nombreArchivoCorto.length() >1 && !nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length() ).equals("O")
  219. && nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length()).equals("E")) {
  220. archivosImagenes1 = buscaArchivoImagenes(carpetaImagenes, (nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 1)).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem);
  221. }
  222. if (archivosImagenes1.isEmpty()) {
  223. nombreArchivoCorto = tem.getNumeroSoldadura().replaceAll("/", "");
  224. if (nombreArchivoCorto.indexOf("PK") < 0) {
  225. nombreArchivoCorto = "PK" + tem.getHoja() + nombreArchivoCorto.replaceAll(" ", "0");
  226. }
  227. List<File> archivosImagenes2 = buscaArchivoImagenes(carpetaImagenes, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem);
  228. if (archivosImagenes2.isEmpty()) {
  229. consola(nombreArchivoCorto);
  230. } else {
  231. consola(nombreArchivoCorto);
  232.  
  233. }
  234.  
  235. //archivosImagenes = buscaArchivoImagenes(carpetaImagenes, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>());
  236. archivosImagenes1 = buscaArchivoImagenes(carpetaImagenes, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem);
  237. // copiarArchivo(archivos.get(0).getAbsolutePath(), carpetaDestino + separador + archivos.get(0).getName());
  238. }
  239. }
  240.  
  241. if (archivosImagenes1.size() == 1) {
  242. tem.setPlaca1(getArchivo(archivosImagenes1.get(0), tem.getPlaca1()));
  243. } else if (archivosImagenes1.size() == 2) {
  244. tem.setPlaca1(getArchivo(archivosImagenes1.get(0), tem.getPlaca1()));
  245. tem.setPlaca2(getArchivo(archivosImagenes1.get(1), tem.getPlaca2()));
  246. } else if (archivosImagenes1.size() == 3) {
  247. tem.setPlaca1(getArchivo(archivosImagenes1.get(0), tem.getPlaca1()));
  248. tem.setPlaca2(getArchivo(archivosImagenes1.get(1), tem.getPlaca2()));
  249. tem.setPlaca3(getArchivo(archivosImagenes1.get(2), tem.getPlaca3()));
  250. } else if (archivosImagenes1.size() == 4) {
  251. tem.setPlaca1(getArchivo(archivosImagenes1.get(0), tem.getPlaca1()));
  252. tem.setPlaca2(getArchivo(archivosImagenes1.get(1), tem.getPlaca2()));
  253. tem.setPlaca3(getArchivo(archivosImagenes1.get(2), tem.getPlaca3()));
  254. tem.setPlaca4(getArchivo(archivosImagenes1.get(3), tem.getPlaca4()));
  255.  
  256. }
  257.  
  258. }
  259. if (this.infoRX != null && !this.infoRX.isEmpty()) {
  260. String numeroInforme = tem.getNumeroInformeRx().replaceAll(" ", "").replaceAll("A", "").replaceAll("E", "").replaceAll("B", "").replaceAll("R", "").replaceAll("-", "").replaceAll("C", "").replaceAll("M", "").replaceAll("N", "").replaceAll("S", "").replaceAll(",", "").replaceAll(",", "/*/");
  261. try {
  262. numeroInforme = Integer.parseInt(numeroInforme) + "";
  263. List<File> archivos = buscaArchivoInformeRX(carpetaInformes, numeroInforme, new ArrayList<File>());
  264. boolean revisar = false;
  265. if (archivos.size() == 1) {
  266. tem.setInformeRx(this.getArchivo(archivos.get(0), tem.getInformeRx()));
  267. //copiarArchivo(archivos.get(0).getAbsolutePath(), carpetaDestino + separador + archivos.get(0).getName());
  268. } else if (archivos.size() == 2) {
  269. tem.setInformeRx(this.getArchivo(archivos.get(0), tem.getInformeRx()));
  270. tem.setInformeRxOriginal(this.getArchivo(archivos.get(01), tem.getInformeRxOriginal()));
  271. //copiarArchivo(archivos.get(0).getAbsolutePath(), carpetaDestino + separador + archivos.get(0).getName());
  272. } else {
  273. revisar = true;
  274. }
  275. } catch (Exception exp) {
  276.  
  277. }
  278. }
  279.  
  280. List<File> archivos = buscaArchivoInformeUSA(carpetaInformesUs, tem.getNumeroInformeUsa().replaceAll(" ", "").replaceAll("-", ""), new ArrayList<File>(), tem.getNumeroInformeUsa());
  281. if (archivos.size() == 1) {
  282. tem.setInformeUsa(this.getArchivo(archivos.get(0), tem.getInformeUsa()));
  283. } /*
  284. // if (revisar && tem.getHoja().equals("0")) {
  285. // carpeta = new File("D:\\archivosCGIM\\CD\\informes RX\\");
  286. // archivos = buscaArchivoInformeRX(carpeta, tem.getNumeroInformeRx(), new ArrayList<File>());
  287. // if (archivos.size() == 1) {
  288. // tem.setInformeRx(this.getArchivo(archivos.get(0)));
  289. //// copiarArchivo(archivos.get(0).getAbsolutePath(), carpetaDestino + separador + archivos.get(0).getName());
  290. // } else {
  291. // revisar = true;
  292. // }
  293. // carpeta = new File("D:\\archivosCGIM\\CD\\informes ultrasonido\\");
  294. // archivos = buscaArchivoInformeUSA(carpeta, tem.getNumeroInformeUsa().replaceAll(" ", "").replaceAll("-", ""), new ArrayList<File>());
  295. // if (archivos.size() == 1) {
  296. // tem.setInformeUsa(this.getArchivo(archivos.get(0)));
  297. //// tem.setInformeUsa(carpetaDestino + separador + archivos.get(0).getName());
  298. //// copiarArchivo(archivos.get(0).getAbsolutePath(), carpetaDestino + separador + archivos.get(0).getName());
  299. // } else {
  300. // revisar = revisar && true;
  301. // }
  302. // }*/
  303.  
  304. for (int ir = 0; ir < tem.getListaJuntaReparcionXJunta().size(); ir++) {
  305. JuntaReparcion reparacion = tem.getListaJuntaReparcionXJunta().get(ir);
  306. if (!soloInformes) {
  307. File carpetaImagenesKm = new File(this.carpetaLectura + "imagenes" + separador + "KM" + tem.getHoja() + separador);
  308. if (tipoLibro.equals("FORMATO2")) {
  309. carpetaImagenesKm = new File(this.carpetaLectura + libroTuberia.getSegmento().getCarpeta() + separador + "KM" + tem.getHoja() + separador);
  310. }
  311.  
  312. tipoLibro = getParametros().get(LEComboTipoParametro.TIPO_LIBRO.getId());
  313. if (tipoLibro.equals("FORMATO2")) {
  314. //////////////////////////////
  315. nombreArchivoCorto = reparacion.getNumeroSoldadura().replaceAll("/", "");
  316.  
  317. if (!nombreArchivoCorto.equals("")) {
  318. consola(nombreArchivoCorto);
  319. }
  320. tipoLibro = getParametros().get(LEComboTipoParametro.TIPO_LIBRO.getId());
  321. if (tipoLibro.equals("FORMATO2")) {
  322. nombreArchivoCorto = reparacion.getNumeroSoldadura().replaceAll("/", "");
  323. }
  324.  
  325. if (tipoLibro.equals("FORMATO2")) {
  326. nombreArchivoCorto = nombreArchivoCorto.replaceAll("PK", "");
  327. } else if (nombreArchivoCorto.indexOf("PK") < 0) {
  328. nombreArchivoCorto = "PK" + reparacion.getHoja() + nombreArchivoCorto;
  329. }
  330. if (reparacion.getHojaReal().equals("SCARF 50002 KMO")) {
  331. nombreArchivoCorto = "SCARF50002" + nombreArchivoCorto;
  332. } else if (reparacion.getHojaReal().equals("SCARF 50002 KM1")) {
  333. nombreArchivoCorto = "SCARF50002" + nombreArchivoCorto;
  334. } else if (reparacion.getHojaReal().equals("M.TRAM 50001")) {
  335. nombreArchivoCorto = "TRAMP" + nombreArchivoCorto;
  336. } else if (reparacion.getHojaReal().equals("M.TRAMP 50003")) {
  337. nombreArchivoCorto = "TRAMP" + nombreArchivoCorto;
  338. } else if (reparacion.getHojaReal().equals("TIEIN-KM31")) {
  339. nombreArchivoCorto = "TIEIN" + nombreArchivoCorto;
  340. } else if (reparacion.getHojaReal().equals("CPF-CUS-K34")) {
  341. nombreArchivoCorto = "CPFCUSK34" + nombreArchivoCorto.replaceAll("CPF CUS ", "");
  342. }
  343.  
  344. //carpeta = new File(this.carpetaLectura + "imagenes" + separador); dalbayoreparac
  345. List<File> archivosImagenesReparacion = new ArrayList<File>();
  346. if (this.busquedaTotalTramo) {
  347. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimoTotalTramo(carpetaImagenes, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion, null, true);
  348. if (archivosImagenesReparacion.isEmpty() && reparacion.getHojaReal().length() > 2
  349. && reparacion.getHojaReal().substring(reparacion.getHojaReal().length() - 2, reparacion.getHojaReal().length()).toUpperCase().equals("LR")) {
  350. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimoTotalTramo(carpetaImagenes, (nombreArchivoCorto.replaceAll("LR", "")).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion, null, true);
  351. }
  352. if (archivosImagenesReparacion.isEmpty() && reparacion.getHojaReal().length() > 2
  353. && reparacion.getHojaReal().substring(reparacion.getHojaReal().length() - 2, reparacion.getHojaReal().length()).toUpperCase().equals("OE")) {
  354. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimoTotalTramo(carpetaImagenes, (nombreArchivoCorto.replaceAll("OE", "")).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion, null, true);
  355. }
  356. if (archivosImagenesReparacion.isEmpty()
  357. && (nombreArchivoCorto.toUpperCase().lastIndexOf("E") < 0
  358. || (nombreArchivoCorto.toUpperCase().lastIndexOf("E") > 0
  359. && nombreArchivoCorto.toUpperCase().lastIndexOf("E") != nombreArchivoCorto.length()))) {
  360. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimoTotalTramo(carpetaImagenes, (nombreArchivoCorto + "E").replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion, null, true);
  361. }
  362.  
  363. if (archivosImagenesReparacion.isEmpty()
  364. && nombreArchivoCorto.length()>0 && !nombreArchivoCorto.substring(nombreArchivoCorto.length() -1, nombreArchivoCorto.length() ).equals("O")
  365. && nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length()).equals("E")) {
  366. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimoTotalTramo(carpetaImagenes, (nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 1)).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion, null, true);
  367. }
  368. } else {
  369. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimo(carpetaImagenes, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion);
  370. if (archivosImagenesReparacion.isEmpty() && reparacion.getHojaReal().length() > 2
  371. && reparacion.getHojaReal().substring(reparacion.getHojaReal().length() - 2, reparacion.getHojaReal().length()).toUpperCase().equals("LR")) {
  372. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimo(carpetaImagenes, (nombreArchivoCorto.replaceAll("LR", "")).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion);
  373. }
  374. if (archivosImagenesReparacion.isEmpty() && reparacion.getHojaReal().length() > 2
  375. && reparacion.getHojaReal().substring(reparacion.getHojaReal().length() - 2, reparacion.getHojaReal().length()).toUpperCase().equals("OE")) {
  376. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimo(carpetaImagenes, (nombreArchivoCorto.replaceAll("OE", "")).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion);
  377. }
  378. if (archivosImagenesReparacion.isEmpty()
  379. && (nombreArchivoCorto.toUpperCase().lastIndexOf("E") < 0
  380. || (nombreArchivoCorto.toUpperCase().lastIndexOf("E") > 0
  381. && nombreArchivoCorto.toUpperCase().lastIndexOf("E") != nombreArchivoCorto.length()))) {
  382. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimo(carpetaImagenes, (nombreArchivoCorto + "E").replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion);
  383. }
  384. if (archivosImagenesReparacion.isEmpty()
  385. && nombreArchivoCorto.length() >1 && !nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length() ).equals("O")
  386. && nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length()).equals("E")) {
  387. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimo(carpetaImagenes, (nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 1)).replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion);
  388. }
  389. if (archivosImagenesReparacion.isEmpty()) {
  390. nombreArchivoCorto = reparacion.getNumeroSoldadura().replaceAll("/", "");
  391. if (nombreArchivoCorto.indexOf("PK") < 0) {
  392. nombreArchivoCorto = "PK" + reparacion.getHoja() + nombreArchivoCorto.replaceAll(" ", "0");
  393. }
  394. archivosImagenesReparacion = buscaArchivoImagenesReparacionUltimo(carpetaImagenes, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), reparacion);
  395. if (archivosImagenesReparacion.isEmpty()) {
  396. //consola(nombreArchivoCorto);
  397. }
  398. }
  399. }
  400.  
  401. if (archivosImagenesReparacion.size() == 1) {
  402. reparacion.setPlaca1(getArchivo(archivosImagenesReparacion.get(0), reparacion.getPlaca1()));
  403. } else if (archivosImagenesReparacion.size() == 2) {
  404. reparacion.setPlaca1(getArchivo(archivosImagenesReparacion.get(0), reparacion.getPlaca1()));
  405. reparacion.setPlaca2(getArchivo(archivosImagenesReparacion.get(1), reparacion.getPlaca2()));
  406. } else if (archivosImagenesReparacion.size() == 3) {
  407. reparacion.setPlaca1(getArchivo(archivosImagenesReparacion.get(0), reparacion.getPlaca1()));
  408. reparacion.setPlaca2(getArchivo(archivosImagenesReparacion.get(1), reparacion.getPlaca2()));
  409. reparacion.setPlaca3(getArchivo(archivosImagenesReparacion.get(2), reparacion.getPlaca3()));
  410. } else if (archivosImagenesReparacion.size() == 4) {
  411. reparacion.setPlaca1(getArchivo(archivosImagenesReparacion.get(0), reparacion.getPlaca1()));
  412. reparacion.setPlaca2(getArchivo(archivosImagenesReparacion.get(1), reparacion.getPlaca2()));
  413. reparacion.setPlaca3(getArchivo(archivosImagenesReparacion.get(2), reparacion.getPlaca3()));
  414. reparacion.setPlaca4(getArchivo(archivosImagenesReparacion.get(3), reparacion.getPlaca4()));
  415.  
  416. }
  417. } else {
  418. if (reparacion.getTipo().equals(LEComboTipoReparacion.ORIGINAL.getId())) {
  419. nombreArchivoCorto = tem.getNumeroSoldadura().replaceAll("/", "");
  420. if (nombreArchivoCorto.indexOf("PK") < 0) {
  421. nombreArchivoCorto = "PK" + tem.getHoja() + nombreArchivoCorto;
  422. }
  423. //carpeta = new File(this.carpetaLectura + "imagenes" + separador);
  424.  
  425. if (nombreArchivoCorto.substring(nombreArchivoCorto.length() - 2, nombreArchivoCorto.length()).equals("R1")) {
  426. nombreArchivoCorto = nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 2);
  427. }
  428. if (nombreArchivoCorto.substring(nombreArchivoCorto.length() - 2, nombreArchivoCorto.length()).equals("R2")) {
  429. nombreArchivoCorto = nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 2);
  430. }
  431.  
  432. archivos = buscaArchivoImagenesReparacion(carpetaImagenes, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", ""), new ArrayList<File>(), tem);
  433.  
  434. buscaArchivoImagenes(carpetaImagenes, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", "").replaceAll("-", ""), new ArrayList<File>(), tem);
  435.  
  436. } else if (nombreArchivoCorto.substring(nombreArchivoCorto.length() - 2, nombreArchivoCorto.length()).equals("R2") && ir == 1) {
  437.  
  438. nombreArchivoCorto = nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 2) + "R1";
  439. } else {
  440. archivos = buscaArchivoImagenesReparacion(carpetaImagenesKm, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", ""), new ArrayList<File>(), tem);
  441. }
  442.  
  443. if (archivos.size() == 1) {
  444. reparacion.setPlaca1(getArchivo(archivos.get(0), reparacion.getPlaca1()));
  445. // copiarArchivo(archivos.get(0).getAbsolutePath(), carpetaDestino + separador + archivos.get(0).getName());
  446. } else if (archivos.size() > 0) {
  447. reparacion.setPlaca1(getArchivo(archivos.get(0), reparacion.getPlaca1()));
  448. reparacion.setPlaca2(getArchivo(archivos.get(1), reparacion.getPlaca2()));
  449. // tem.setImagenRx1(carpetaDestino + separador + archivos.get(0).getName());
  450. // tem.setImagenRx2(carpetaDestino + separador + archivos.get(1).getName());
  451. // copiarArchivo(archivos.get(0).getAbsolutePath(), carpetaDestino + separador + archivos.get(0).getName());
  452. // copiarArchivo(archivos.get(1).getAbsolutePath(), carpetaDestino + separador + archivos.get(1).getName());
  453. }
  454. }
  455. }
  456. // carpeta = new File(this.carpetaLectura + "informes RX" + separador);
  457. if (this.infoRX != null && !this.infoRX.isEmpty()) {
  458. String numeroInforme = reparacion.getNumeroInformeRx().replaceAll(" ", "").replaceAll("A", "").replaceAll("E", "").replaceAll("B", "").replaceAll("R", "").replaceAll("-", "").replaceAll("C", "").replaceAll("M", "").replaceAll("N", "").replaceAll("S", "").replaceAll(",", "").replaceAll(",", "/*/");
  459. try {
  460. numeroInforme = Integer.parseInt(numeroInforme) + "";
  461. archivos = buscaArchivoInformeRX(carpetaInformes, numeroInforme, new ArrayList<File>());
  462. boolean revisar = false;
  463. if (archivos.size() == 1) {
  464. reparacion.setInformeRx(this.getArchivo(archivos.get(0), reparacion.getInformeRx()));
  465. //copiarArchivo(archivos.get(0).getAbsolutePath(), carpetaDestino + separador + archivos.get(0).getName());
  466. } else if (archivos.size() == 2) {
  467. reparacion.setInformeRx(this.getArchivo(archivos.get(0), reparacion.getInformeRx()));
  468. reparacion.setInformeRxOriginal(this.getArchivo(archivos.get(01), reparacion.getInformeRxOriginal()));
  469. //copiarArchivo(archivos.get(0).getAbsolutePath(), carpetaDestino + separador + archivos.get(0).getName());
  470. } else {
  471. revisar = true;
  472. }
  473. } catch (Exception exp) {
  474. }
  475.  
  476. }
  477. if (!Funciones.isVacio(tem.getNumeroInformeUsa())) {
  478.  
  479. archivos = buscaArchivoInformeUSA(carpetaInformesUs, tem.getNumeroInformeUsa().replaceAll(" ", "").replaceAll("-", ""), new ArrayList<File>(), tem.getNumeroInformeUsa());
  480. if (archivos.size() == 1) {
  481. reparacion.setInformeUsa(this.getArchivo(archivos.get(0), reparacion.getInformeUsa()));
  482. // reparacion.setInformeUsa(carpetaDestino + separador + archivos.get(0).getName());
  483. // copiarArchivo(archivos.get(0).getAbsolutePath(), carpetaDestino + separador + archivos.get(0).getName());
  484. }
  485. }
  486. this.juntaReparcionDto.guardar(reparacion);
  487. }
  488.  
  489. // if(!Funciones.isVacio(tem.getNumeroInformeRx()) && tem.getInformeRx().isNuevo()){
  490. // nombreArchivoCorto = "PK" + tem.getHoja() + tem.getNumeroSoldadura();
  491. // carpeta = new File(this.carpetaLectura + "imagenes" + separador);
  492. // archivos = buscaArchivoImagenes(carpeta, nombreArchivoCorto.replaceAll(" ", "").replaceAll("/", ""), new ArrayList<File>());
  493. //
  494. // }
  495. tem.setSubioArchivos(Short.parseShort("1"));
  496. if (temm % 10 == 0) {
  497. this.juntaDto.guardarMemoria(tem, true);
  498. } else {
  499. this.juntaDto.guardarMemoria(tem, true);
  500. }
  501.  
  502. tem = null;
  503. juntas.set(i, tem);
  504. juntas.remove(i);
  505. i--;
  506.  
  507. } catch (Exception e) {
  508. e.printStackTrace();
  509. this.juntaDto.guardarMemoria(tem, true);
  510. e.printStackTrace();
  511. }
  512.  
  513. }
  514. }
  515.  
  516. } catch (Exception ex) {
  517. Logger.getLogger(CargaArchivos.class.getName()).log(Level.SEVERE, null, ex);
  518. }
  519. this.finalize();
  520. }
  521.  
  522. private List<File> buscaArchivoImagenes(File carpeta, String nombreArchivoCorto, List<File> resultado, Junta junta) {
  523.  
  524. String nombreArchivoCarpeta = junta.getHojaReal();
  525. String kilometroCarpeta = "";
  526. kilometroCarpeta = validaNombreYHojakilometroCarpeta(nombreArchivoCarpeta, junta);
  527. nombreArchivoCarpeta = validaNombreYHoja(nombreArchivoCarpeta, junta);
  528.  
  529. try {
  530. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  531. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  532. && !kilometroCarpeta.equals("")) {
  533. if (nombreArchivoCorto.toUpperCase().indexOf("K") != 0 && nombreArchivoCorto.length() > 2) {
  534. nombreArchivoCorto = "K" + nombreArchivoCorto.substring(1, nombreArchivoCorto.length());
  535. }
  536. nombreArchivoCorto = nombreArchivoCorto.toUpperCase().replaceAll("K" + kilometroCarpeta, "K" + kilometroCarpeta + "J").replaceAll("JJ", "J");
  537. }
  538.  
  539. } catch (Exception exp) {
  540. consola2(" error carpeta " + libroTuberia.getSegmento().getCarpeta().trim().toUpperCase());
  541. return resultado;
  542. }
  543. nombreArchivoCorto = nombreArchivoCorto.replaceAll("\\.", "");
  544.  
  545. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  546. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null &&
  547. junta.getHojaReal().length() > 2
  548. && junta.getHojaReal().substring(junta.getHojaReal().length() - 2, junta.getHojaReal().length()).toUpperCase().equals("LR")) {
  549. nombreArchivoCorto =(nombreArchivoCorto.replaceAll("LR", ""));
  550. }
  551. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  552. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null &&
  553. junta.getHojaReal().length() > 2
  554. && junta.getHojaReal().substring(junta.getHojaReal().length() - 2, junta.getHojaReal().length()).toUpperCase().equals("OE")) {
  555. nombreArchivoCorto = (nombreArchivoCorto.replaceAll("OE", ""));
  556. }
  557. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  558. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  559. && (nombreArchivoCorto.toUpperCase().lastIndexOf("E") < 0
  560. || (nombreArchivoCorto.toUpperCase().lastIndexOf("E") > 0
  561. && nombreArchivoCorto.toUpperCase().lastIndexOf("E") != nombreArchivoCorto.length()))) {
  562. String nombreArchivoCorto2 = (nombreArchivoCorto + "E");
  563. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  564. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto2.trim()) != null ){
  565. nombreArchivoCorto = nombreArchivoCorto2;
  566. }
  567.  
  568. }
  569. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  570. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  571. && nombreArchivoCorto.length() >1 && !nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length() ).equals("O")
  572. && nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length()).equals("E")) {
  573. nombreArchivoCorto = (nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 1));
  574.  
  575. }
  576. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  577. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) != null) {
  578. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()));
  579. //if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "1") != null) {
  580. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  581. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM1") != null) {
  582. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM1"));
  583. //if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "2") != null) {
  584. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  585. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM2") != null) {
  586. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto + "IM2".trim()));
  587. // if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "3") != null) {
  588. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  589. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM3") != null) {
  590. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM3"));
  591. // if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "4") != null) {
  592. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  593. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM4") != null) {
  594. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM4"));
  595. }
  596.  
  597. }
  598. }
  599. }
  600. return resultado;
  601. }
  602. return resultado;
  603. }
  604.  
  605. private List<File> buscaArchivoImagenesTotalTramo(File carpeta, String nombreArchivoCorto, List<File> resultado, Junta junta, String nombreCarpetaKm, boolean recorrerCarpetas) {
  606.  
  607. if (nombreCarpetaKm == null) {
  608. resultado = buscaArchivoImagenes(carpeta, nombreArchivoCorto, resultado, junta);
  609. if (!resultado.isEmpty()) {
  610. return resultado;
  611. }
  612. }
  613. if (recorrerCarpetas) {
  614. Iterator it = this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().entrySet().iterator();
  615. while (it.hasNext()) {
  616. Map.Entry e = (Map.Entry) it.next();
  617.  
  618. resultado = buscaArchivoImagenesTotalTramo(carpeta, nombreArchivoCorto, resultado, junta, e.getKey().toString(), false);
  619. if (!resultado.isEmpty()) {
  620. return resultado;
  621. }
  622. }
  623. return resultado;
  624. }
  625.  
  626. String nombreArchivoCarpeta = junta.getHojaReal();
  627. String kilometroCarpeta = "";
  628. if (nombreArchivoCorto.toUpperCase().equals("K265J8R")) {
  629. // consola(nombreArchivoCorto);
  630. }
  631. kilometroCarpeta = validaNombreYHojakilometroCarpeta(nombreArchivoCarpeta, junta);
  632. nombreArchivoCarpeta = validaNombreYHoja(nombreArchivoCarpeta, junta);
  633. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpetaKm.trim().toUpperCase()) != null
  634. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpetaKm.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  635. && !kilometroCarpeta.equals("")) {
  636. if (nombreArchivoCorto.toUpperCase().indexOf("K") != 0 && nombreArchivoCorto.length() > 2) {
  637. nombreArchivoCorto = "K" + nombreArchivoCorto.substring(1, nombreArchivoCorto.length());
  638. }
  639. nombreArchivoCorto = nombreArchivoCorto.toUpperCase().replaceAll("K" + kilometroCarpeta, "K" + kilometroCarpeta + "J").replaceAll("JJ", "J");
  640.  
  641. }
  642. nombreArchivoCorto = nombreArchivoCorto.replaceAll("\\.", "");
  643.  
  644. nombreArchivoCarpeta = nombreCarpetaKm;
  645. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  646. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null &&
  647. junta.getHojaReal().length() > 2
  648. && junta.getHojaReal().substring(junta.getHojaReal().length() - 2, junta.getHojaReal().length()).toUpperCase().equals("LR")) {
  649. nombreArchivoCorto =(nombreArchivoCorto.replaceAll("LR", ""));
  650. }
  651. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  652. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null &&
  653. junta.getHojaReal().length() > 2
  654. && junta.getHojaReal().substring(junta.getHojaReal().length() - 2, junta.getHojaReal().length()).toUpperCase().equals("OE")) {
  655. nombreArchivoCorto = (nombreArchivoCorto.replaceAll("OE", ""));
  656. }
  657. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  658. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  659. && (nombreArchivoCorto.toUpperCase().lastIndexOf("E") < 0
  660. || (nombreArchivoCorto.toUpperCase().lastIndexOf("E") > 0
  661. && nombreArchivoCorto.toUpperCase().lastIndexOf("E") != nombreArchivoCorto.length()))) {
  662. String nombreArchivoCorto2 = (nombreArchivoCorto + "E");
  663. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  664. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto2.trim()) != null ){
  665. nombreArchivoCorto = nombreArchivoCorto2;
  666. }
  667.  
  668. }
  669. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  670. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  671. && nombreArchivoCorto.length() >1 && !nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length() ).equals("O")
  672. && nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length()).equals("E")) {
  673. nombreArchivoCorto = (nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 1));
  674.  
  675. }
  676.  
  677. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  678. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) != null) {
  679. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()));
  680. //if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "1") != null) {
  681. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  682. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM1") != null) {
  683. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM1"));
  684. //if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "2") != null) {
  685. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  686. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM2") != null) {
  687. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto + "IM2".trim()));
  688. // if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "3") != null) {
  689. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  690. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM3") != null) {
  691. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM3"));
  692. // if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "4") != null) {
  693. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  694. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM4") != null) {
  695. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM4"));
  696. }
  697.  
  698. }
  699. }
  700. }
  701. return resultado;
  702. }
  703. return resultado;
  704. }
  705.  
  706. private List<File> buscaArchivoImagenesReparacionUltimo(File carpeta, String nombreArchivoCorto, List<File> resultado, JuntaReparcion junta) {
  707.  
  708. String nombreArchivoCarpeta = junta.getHojaReal();
  709. String kilometroCarpeta = "";
  710. kilometroCarpeta = validaNombreYHojakilometroCarpeta(nombreArchivoCarpeta, junta);
  711. nombreArchivoCarpeta = validaNombreYHoja(nombreArchivoCarpeta, junta);
  712.  
  713. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  714. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  715. && !kilometroCarpeta.equals("")) {
  716. if (nombreArchivoCorto.toUpperCase().indexOf("K") != 0 && nombreArchivoCorto.length() > 2) {
  717. nombreArchivoCorto = "K" + nombreArchivoCorto.substring(1, nombreArchivoCorto.length());
  718. }
  719. nombreArchivoCorto = nombreArchivoCorto.toUpperCase().replaceAll("K" + kilometroCarpeta, "K" + kilometroCarpeta + "J").replaceAll("JJ", "J");
  720. }
  721. nombreArchivoCorto = nombreArchivoCorto.replaceAll("\\.", "");
  722. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  723. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null &&
  724. junta.getHojaReal().length() > 2
  725. && junta.getHojaReal().substring(junta.getHojaReal().length() - 2, junta.getHojaReal().length()).toUpperCase().equals("LR")) {
  726. nombreArchivoCorto =(nombreArchivoCorto.replaceAll("LR", ""));
  727. }
  728. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  729. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null &&
  730. junta.getHojaReal().length() > 2
  731. && junta.getHojaReal().substring(junta.getHojaReal().length() - 2, junta.getHojaReal().length()).toUpperCase().equals("OE")) {
  732. nombreArchivoCorto = (nombreArchivoCorto.replaceAll("OE", ""));
  733. }
  734. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  735. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  736. && (nombreArchivoCorto.toUpperCase().lastIndexOf("E") < 0
  737. || (nombreArchivoCorto.toUpperCase().lastIndexOf("E") > 0
  738. && nombreArchivoCorto.toUpperCase().lastIndexOf("E") != nombreArchivoCorto.length()))) {
  739. String nombreArchivoCorto2 = (nombreArchivoCorto + "E");
  740. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  741. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto2.trim()) != null ){
  742. nombreArchivoCorto = nombreArchivoCorto2;
  743. }
  744.  
  745. }
  746. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  747. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  748. && nombreArchivoCorto.length() >1 && !nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length() ).equals("O")
  749. && nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length()).equals("E")) {
  750. nombreArchivoCorto = (nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 1));
  751.  
  752. }
  753.  
  754. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  755. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) != null) {
  756. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()));
  757. //if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "1") != null) {
  758. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  759. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM1") != null) {
  760. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM1"));
  761. //if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "2") != null) {
  762. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  763. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM2") != null) {
  764. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto + "IM2".trim()));
  765. // if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "3") != null) {
  766. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  767. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM3") != null) {
  768. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM3"));
  769. // if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "4") != null) {
  770. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  771. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM4") != null) {
  772. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM4"));
  773. }
  774.  
  775. }
  776. }
  777. }
  778. return resultado;
  779. }
  780. return resultado;
  781. }
  782.  
  783. private List<File> buscaArchivoImagenesReparacionUltimoTotalTramo(File carpeta, String nombreArchivoCorto, List<File> resultado, JuntaReparcion junta, String nombreCarpetaKm, boolean recorrerCarpetas) {
  784.  
  785. if (nombreCarpetaKm == null) {
  786. resultado = buscaArchivoImagenesReparacionUltimo(carpeta, nombreArchivoCorto, resultado, junta);
  787. if (!resultado.isEmpty()) {
  788. return resultado;
  789. }
  790. }
  791. if (recorrerCarpetas) {
  792. Iterator it = this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().entrySet().iterator();
  793. while (it.hasNext()) {
  794. Map.Entry e = (Map.Entry) it.next();
  795.  
  796. resultado = buscaArchivoImagenesReparacionUltimoTotalTramo(carpeta, nombreArchivoCorto, resultado, junta, e.getKey().toString(), false);
  797. if (!resultado.isEmpty()) {
  798. return resultado;
  799. }
  800. }
  801. return resultado;
  802. }
  803. String nombreArchivoCarpeta = junta.getHojaReal();
  804. String kilometroCarpeta = "";
  805. if (nombreArchivoCorto.toUpperCase().equals("K265J8R")) {
  806. // consola(nombreArchivoCorto);
  807. }
  808.  
  809. kilometroCarpeta = validaNombreYHojakilometroCarpeta(nombreArchivoCarpeta, junta);
  810. if (kilometroCarpeta.equals("")) {
  811. kilometroCarpeta = validaNombreYHojakilometroCarpeta(nombreArchivoCarpeta, junta);
  812. if (kilometroCarpeta.equals("")) {
  813. kilometroCarpeta = validaNombreYHojakilometroCarpeta(nombreArchivoCarpeta, junta);
  814. }
  815. }
  816. nombreArchivoCarpeta = validaNombreYHoja(nombreArchivoCarpeta, junta);
  817. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpetaKm.trim().toUpperCase()) != null
  818. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpetaKm.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  819. && !kilometroCarpeta.equals("")) {
  820. if (nombreArchivoCorto.toUpperCase().indexOf("K") != 0 && nombreArchivoCorto.length() > 2) {
  821. nombreArchivoCorto = "K" + nombreArchivoCorto.substring(1, nombreArchivoCorto.length());
  822. }
  823. nombreArchivoCorto = nombreArchivoCorto.toUpperCase().replaceAll("K" + kilometroCarpeta, "K" + kilometroCarpeta + "J").replaceAll("JJ", "J");
  824.  
  825. }
  826. nombreArchivoCorto = nombreArchivoCorto.replaceAll("\\.", "");
  827. nombreArchivoCarpeta = nombreCarpetaKm;
  828.  
  829. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  830. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null &&
  831. junta.getHojaReal().length() > 2
  832. && junta.getHojaReal().substring(junta.getHojaReal().length() - 2, junta.getHojaReal().length()).toUpperCase().equals("LR")) {
  833. nombreArchivoCorto =(nombreArchivoCorto.replaceAll("LR", ""));
  834. }
  835. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  836. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null &&
  837. junta.getHojaReal().length() > 2
  838. && junta.getHojaReal().substring(junta.getHojaReal().length() - 2, junta.getHojaReal().length()).toUpperCase().equals("OE")) {
  839. nombreArchivoCorto = (nombreArchivoCorto.replaceAll("OE", ""));
  840. }
  841. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  842. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  843. && (nombreArchivoCorto.toUpperCase().lastIndexOf("E") < 0
  844. || (nombreArchivoCorto.toUpperCase().lastIndexOf("E") > 0
  845. && nombreArchivoCorto.toUpperCase().lastIndexOf("E") != nombreArchivoCorto.length()))) {
  846. String nombreArchivoCorto2 = (nombreArchivoCorto + "E");
  847. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  848. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto2.trim()) != null ){
  849. nombreArchivoCorto = nombreArchivoCorto2;
  850. }
  851.  
  852. }
  853. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  854. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) == null
  855. && nombreArchivoCorto.length() > 1 && !nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length()).equals("O")
  856. && nombreArchivoCorto.substring(nombreArchivoCorto.length() - 1, nombreArchivoCorto.length()).equals("E")) {
  857. nombreArchivoCorto = (nombreArchivoCorto.substring(0, nombreArchivoCorto.length() - 1));
  858.  
  859. }
  860.  
  861. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  862. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) != null) {
  863. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()));
  864. //if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "1") != null) {
  865. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  866. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM1") != null) {
  867. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM1"));
  868. //if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "2") != null) {
  869. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  870. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM2") != null) {
  871. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto + "IM2".trim()));
  872. // if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "3") != null) {
  873. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  874. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM3") != null) {
  875. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM3"));
  876. // if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "4") != null) {
  877. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  878. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM4") != null) {
  879. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM4"));
  880. }
  881.  
  882. }
  883. }
  884. }
  885. return resultado;
  886. }
  887. return resultado;
  888. }
  889.  
  890. public HashMap<String, ArchivoImagenJunta> precargaArchivosImagenes(File carpeta, String carpetaSegmento) {
  891. buscaArchivoImagenesMap(carpeta, carpetaSegmento);
  892. return juntasF2;
  893. }
  894.  
  895. private void buscaArchivoImagenesMap(File carpeta, String carpetaSegmento) {
  896.  
  897. if (carpeta.isDirectory()) {
  898. for (File file : carpeta.listFiles()) {
  899. buscaArchivoImagenesMap(file, carpetaSegmento);
  900. }
  901. } else {
  902. String nombreCarpeta = "";
  903. String nombreArchivoCarpeta = carpeta.getParentFile().getName().trim().toUpperCase();
  904. if (nombreArchivoCarpeta.indexOf("265") >= 0) {
  905. consola(nombreArchivoCarpeta);
  906. }
  907. if (nombreArchivoCarpeta.equals("SCARF50002K0")) {
  908. nombreCarpeta = "SCARF50002K0";
  909. } else if (nombreArchivoCarpeta.equals("SCARF50002K1")) {
  910. nombreCarpeta = "SCARF50002K1";
  911. } else if (nombreArchivoCarpeta.equals("TRAMP50001")) {
  912. nombreCarpeta = "TRAMP50001";
  913. } else if (nombreArchivoCarpeta.equals("TRAMP50003")) {
  914. nombreCarpeta = "TRAMP50003";
  915. } else if (nombreArchivoCarpeta.equals("TIEIN K31")) {
  916. nombreCarpeta = "TIEIN K31";
  917. } else if (nombreArchivoCarpeta.equals("CPF CUS K34")) {
  918. nombreCarpeta = "CPF CUS K34";
  919. } else {
  920. // if(carpeta.getParentFile().getName().equals("KST94")){
  921. // consola(carpeta.getParentFile().getName());
  922. // }
  923. nombreCarpeta = carpeta.getParentFile().getName().trim().toUpperCase().replace("KM", "").replace("K", "");
  924.  
  925. try {
  926. nombreCarpeta = Integer.parseInt(nombreCarpeta) + "";
  927. nombreCarpeta = "KM" + nombreCarpeta;
  928. } catch (Exception expp) {
  929. nombreCarpeta = carpeta.getParentFile().getName().trim().toUpperCase();
  930. }
  931. }
  932. String nombreArchivo = carpeta.getName();
  933. String quitar = "";
  934. if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()) == null) {
  935. this.juntasF2.put(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase(), new ArchivoImagenJunta());
  936. }
  937. if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta) == null) {
  938.  
  939. this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().put(nombreCarpeta, new ArchivoImagenJunta());
  940. }
  941.  
  942. if (carpeta.getParentFile().getName().indexOf("K") >= 0) {
  943. quitar = carpeta.getParentFile().getName().substring(0, carpeta.getParentFile().getName().indexOf("K"));
  944. nombreArchivo = nombreArchivo.replaceAll(quitar, "");
  945. }
  946.  
  947. if (nombreArchivo.indexOf(".") > 0) {
  948. nombreArchivo = carpeta.getName().substring(0, carpeta.getName().indexOf("."));
  949. }
  950.  
  951. if (nombreArchivo.indexOf("(") > 0) {
  952. nombreArchivo = nombreArchivo.substring(0, nombreArchivo.indexOf("("));
  953. }
  954. String tipoLibro = getParametros().get(LEComboTipoParametro.TIPO_LIBRO.getId());
  955. if (nombreArchivo.indexOf("-") > 0) {
  956. String[] tem = nombreArchivo.split("-");
  957. if (tem.length == 2) {
  958. if (tem[0].lastIndexOf(" ") > 0) {
  959. nombreArchivo = tem[0].substring(0, tem[0].lastIndexOf(" "));
  960. } else {
  961. // nombreArchivo = tem[0].substring(0, tem[0].lastIndexOf(" "));
  962. }
  963. } else if (tem.length == 3) {
  964. if (tem[1].lastIndexOf(" ") > 0) {
  965. nombreArchivo = tem[0] + " " + tem[1].substring(0, tem[1].lastIndexOf(" "));
  966. } else {
  967. //nombreArchivo = tem[0].substring(0, tem[0].lastIndexOf(" "));
  968. }
  969. }
  970. }
  971. if (tipoLibro.equals("FORMATO2")) {
  972. nombreArchivo = nombreArchivo.replaceAll(" ", "");
  973. }
  974.  
  975. nombreArchivo = nombreArchivo.replaceAll("00-120", "").replaceAll("120-00", "").replaceAll("LR", "").replaceAll("OE", "");
  976. consola(nombreArchivo + " -- " + carpeta.getPath());
  977. // if(this.juntasF.get(carpeta.getParentFile().getName()) ){
  978. //
  979. // }
  980. try {
  981. this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivo);
  982. } catch (Exception expppr) {
  983. expppr.printStackTrace();
  984. expppr.printStackTrace();
  985. }
  986. if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivo) != null) {
  987. consola(nombreCarpeta);
  988. consola(nombreArchivo);
  989. consola(nombreCarpeta);
  990. }
  991. if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivo) == null) {
  992. this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta.trim().toUpperCase()).getImagenes().put(nombreArchivo, carpeta);
  993. } else if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivo + "IM1") == null) {
  994. this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta.trim().toUpperCase()).getImagenes().put(nombreArchivo + "IM1", carpeta);
  995. } else if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivo + "IM2") == null) {
  996. this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta.trim().toUpperCase()).getImagenes().put(nombreArchivo + "IM2", carpeta);
  997. } else if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivo + "IM3") == null) {
  998. this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreCarpeta.trim().toUpperCase()).getImagenes().put(nombreArchivo + "IM3", carpeta);
  999. }
  1000.  
  1001. }
  1002. }
  1003.  
  1004. private List<File> buscaArchivoImagenesReparacion(File carpeta, String nombreArchivoCorto, List<File> resultado, Junta junta) {
  1005.  
  1006. String nombreArchivoCarpeta = junta.getHojaReal().trim().toUpperCase().replace("KM", "").replace("K", "");
  1007. try {
  1008. nombreArchivoCarpeta = Integer.parseInt(nombreArchivoCarpeta) + "";
  1009. nombreArchivoCarpeta = "KM" + nombreArchivoCarpeta;
  1010. } catch (Exception expp) {
  1011.  
  1012. }
  1013. try {
  1014. this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim());
  1015. } catch (Exception expp) {
  1016. expp.printStackTrace();
  1017. expp.printStackTrace();
  1018. return resultado;
  1019. }
  1020. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  1021. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()) != null) {
  1022. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim()));
  1023. //if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "1") != null) {
  1024. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  1025. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM1") != null) {
  1026. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM1"));
  1027. //if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "2") != null) {
  1028. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  1029. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM2") != null) {
  1030. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto + "IM2".trim()));
  1031. // if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "3") != null) {
  1032. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  1033. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM3") != null) {
  1034. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM3"));
  1035. // if (this.juntasF2.get(carpeta.getParentFile().getParentFile().getName().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivo.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "4") != null) {
  1036. if (this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()) != null
  1037. && this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM4") != null) {
  1038. resultado.add(this.juntasF2.get(libroTuberia.getSegmento().getCarpeta().trim().toUpperCase()).getArchivosImagenes().get(nombreArchivoCarpeta.trim().toUpperCase()).getImagenes().get(nombreArchivoCorto.trim() + "IM4"));
  1039. }
  1040.  
  1041. }
  1042. }
  1043. }
  1044. return resultado;
  1045. }
  1046. if (carpeta.isDirectory()) {
  1047. for (File file : carpeta.listFiles()) {
  1048. resultado = buscaArchivoImagenes(file, nombreArchivoCorto, resultado, junta);
  1049. }
  1050. } else {
  1051. String nombreArchivo = carpeta.getName();
  1052. if (nombreArchivo.indexOf(".") > 0) {
  1053. nombreArchivo = carpeta.getName().substring(0, carpeta.getName().indexOf("."));
  1054. }
  1055.  
  1056. if (nombreArchivo.indexOf("(") > 0) {
  1057. nombreArchivo = nombreArchivo.substring(0, nombreArchivo.indexOf("("));
  1058. }
  1059. if (nombreArchivo.equals(nombreArchivoCorto.trim())) {
  1060. resultado.add(carpeta);
  1061. }
  1062. }
  1063. return resultado;
  1064. }
  1065.  
  1066. public HashMap<String, File> getInfoRX() {
  1067. return infoRX;
  1068. }
  1069.  
  1070. public void setInfoRX(HashMap<String, File> infoRX) {
  1071. this.infoRX = infoRX;
  1072. }
  1073.  
  1074. public HashMap<String, File> precargaArchivosInformeRX(File carpeta) {
  1075. buscaArchivoInformeRXMap(carpeta);
  1076. return infoRX;
  1077. }
  1078.  
  1079. private void buscaArchivoInformeRXMap(File carpeta) {
  1080.  
  1081. if (carpeta.isDirectory()) {
  1082. for (File file : carpeta.listFiles()) {
  1083. buscaArchivoInformeRXMap(file);
  1084. }
  1085. } else {
  1086. String nombreArchivo = carpeta.getName();
  1087. if (nombreArchivo.indexOf(".") > 0) {
  1088. nombreArchivo = carpeta.getName().replaceAll("Informe", "").replaceAll("INFORME ", "").replaceAll("Tecniensayos.pdf", "").replaceAll("Tenciensayos.pdf", "").replaceAll("B- ", "").replaceAll("A", "").replaceAll(" A", "").replaceAll(".pdf", "");
  1089. if (nombreArchivo.indexOf("A") > 0) {
  1090. try {
  1091. nombreArchivo = Integer.parseInt(nombreArchivo.replaceAll("A", "").replaceAll(" ", "")) + "";
  1092. } catch (Exception exp) {
  1093. exp.printStackTrace();
  1094. }
  1095.  
  1096. nombreArchivo = nombreArchivo + "A";
  1097. } else {
  1098. try {
  1099.  
  1100. nombreArchivo = Integer.parseInt(nombreArchivo.replaceAll("A", "").replaceAll(" ", "")) + "";
  1101. } catch (Exception exp) {
  1102. //exp.printStackTrace();
  1103. }
  1104. }
  1105.  
  1106. consola(nombreArchivo + " -- " + carpeta.getPath());
  1107. if (this.infoRX.get(nombreArchivo) == null) {
  1108. this.infoRX.put(nombreArchivo, carpeta);
  1109. } else {
  1110. this.infoRX.put(nombreArchivo + "_BZ", carpeta);
  1111. }
  1112.  
  1113. }
  1114.  
  1115. }
  1116. }
  1117.  
  1118. public HashMap<String, File> precargaArchivosInformeRXTrampas(File carpeta, HashMap<String, File> inforx) {
  1119. return buscaArchivoInformeRXMapTrampas(carpeta, inforx);
  1120.  
  1121. }
  1122.  
  1123. private HashMap<String, File> buscaArchivoInformeRXMapTrampas(File carpeta, HashMap<String, File> inforx) {
  1124.  
  1125. if (carpeta.isDirectory()) {
  1126. for (File file : carpeta.listFiles()) {
  1127. inforx = buscaArchivoInformeRXMapTrampas(file, inforx);
  1128. }
  1129. } else {
  1130. String nombreArchivo = carpeta.getName();
  1131. if (nombreArchivo.toUpperCase().trim().indexOf("ITEM") > 0) {
  1132. return inforx;
  1133. }
  1134. if (nombreArchivo.indexOf(".") > 0) {
  1135. nombreArchivo = carpeta.getName().replaceAll("Informe", "").replaceAll("INFORME ", "").replaceAll("Tecniensayos.pdf", "").replaceAll("Tenciensayos.pdf", "").replaceAll("B- ", "").replaceAll("A", "").replaceAll(" A", "").replaceAll(".pdf", "");
  1136. if (nombreArchivo.indexOf("A") > 0) {
  1137. try {
  1138. nombreArchivo = Integer.parseInt(nombreArchivo.replaceAll("A", "").replaceAll(" ", "")) + "";
  1139. } catch (Exception exp) {
  1140. exp.printStackTrace();
  1141. }
  1142.  
  1143. nombreArchivo = nombreArchivo + "A";
  1144. } else {
  1145. try {
  1146.  
  1147. nombreArchivo = Integer.parseInt(nombreArchivo.replaceAll("A", "").replaceAll(" ", "")) + "TRAMPAS";
  1148. } catch (Exception exp) {
  1149. exp.printStackTrace();
  1150. }
  1151. }
  1152.  
  1153. consola(nombreArchivo + " -- " + carpeta.getPath());
  1154. if (inforx.get(nombreArchivo) == null) {
  1155. inforx.put(nombreArchivo, carpeta);
  1156. } else {
  1157. inforx.put(nombreArchivo + "_BZ", carpeta);
  1158. }
  1159.  
  1160. }
  1161.  
  1162. }
  1163. return inforx;
  1164. }
  1165.  
  1166. private List<File> buscaArchivoInformeRX(File carpeta, String nombreInformeCorto, List<File> resultado) {
  1167. if (this.infoRX.get(nombreInformeCorto.trim()) != null) {
  1168. resultado.add(this.infoRX.get(nombreInformeCorto.trim()));
  1169. return resultado;
  1170. }
  1171. // if (carpeta.isDirectory()) {
  1172. // for (File file : carpeta.listFiles()) {
  1173. // resultado = buscaArchivoInformeRX(file, nombreInformeCorto, resultado);
  1174. // if (resultado.size() > 0) {
  1175. // return resultado;
  1176. // }
  1177. //
  1178. // }
  1179. // } else {
  1180. //// String nombreArchivo = carpeta.getName();
  1181. //// if (nombreArchivo.indexOf(".") > 0) {
  1182. //// nombreArchivo = carpeta.getName().replaceAll("Informe", "").replaceAll("Tecniensayos.pdf", "").replaceAll("Tenciensayos.pdf", "");
  1183. //// int temp = nombreArchivo.indexOf(nombreInformeCorto);
  1184. //// if (temp > 0) {
  1185. //// String nom1 = nombreArchivo.substring(0, temp).replaceAll("0", "");;
  1186. //// String nomb2 = nombreArchivo.substring(temp, nombreArchivo.length());
  1187. //// nombreArchivo = nom1 + nomb2;
  1188. //// }
  1189. //// }
  1190. //// if (nombreArchivo.equals(nombreInformeCorto)) {
  1191. //// resultado.add(carpeta);
  1192. //// return resultado;
  1193. //// }
  1194. //// if (nombreArchivo.indexOf(nombreInformeCorto) >= 0) {
  1195. //// }
  1196. // }
  1197. return resultado;
  1198. }
  1199.  
  1200. private void buscaArchivoInformeUSAMap(File carpeta) {
  1201.  
  1202. if (carpeta.isDirectory()) {
  1203. for (File file : carpeta.listFiles()) {
  1204. buscaArchivoInformeUSAMap(file);
  1205. }
  1206. } else {
  1207. String nombreArchivo = carpeta.getName();
  1208. if (nombreArchivo.indexOf(".") > 0) {
  1209. nombreArchivo = carpeta.getName().replaceAll("-", "").replaceAll(" ", "").replaceAll(".pdf", "").replaceAll(" ", "");
  1210. }
  1211. consola(nombreArchivo + " -- " + carpeta.getPath());
  1212. this.infoUsa.put(nombreArchivo, carpeta);
  1213. nombreArchivo = carpeta.getName();
  1214. if (nombreArchivo.indexOf(".") > 0) {
  1215. nombreArchivo = carpeta.getName().replaceAll("AT", "").replaceAll("-", "").replaceAll(" ", "").replaceAll(".pdf", "").replaceAll(" ", "");
  1216. consola(nombreArchivo + " -- " + carpeta.getPath());
  1217. }
  1218. String[] tempors = carpeta.getName().replaceAll(".pdf", "").replaceAll(" ", "").split("-");
  1219. if (tempors.length == 4) {
  1220. nombreArchivo = tempors[0] + Integer.parseInt(tempors[1]) + tempors[2] + Integer.parseInt(tempors[3]);
  1221. if (this.infoUsa.get(nombreArchivo) == null) {
  1222. this.infoUsa.put(nombreArchivo, carpeta);
  1223. }
  1224. }
  1225.  
  1226. }
  1227. }
  1228.  
  1229. private List<File> buscaArchivoInformeUSA(File carpeta, String nombreInformeCorto, List<File> resultado, String nombreOriginal) {
  1230. if (this.infoUsa.get(nombreInformeCorto.trim()) != null) {
  1231. resultado.add(this.infoUsa.get(nombreInformeCorto.trim()));
  1232. return resultado;
  1233. }
  1234. String[] tempors = nombreOriginal.replaceAll(".pdf", "").split("-");
  1235. if (tempors.length == 4) {
  1236. try {
  1237. nombreInformeCorto = tempors[0].trim() + Integer.parseInt(tempors[1].trim()) + tempors[2].trim() + Integer.parseInt(tempors[3].trim());
  1238. if (this.infoUsa.get(nombreInformeCorto.trim()) != null) {
  1239. resultado.add(this.infoUsa.get(nombreInformeCorto.trim()));
  1240. return resultado;
  1241. }
  1242. } catch (Exception eee) {
  1243. eee.printStackTrace();
  1244. eee.printStackTrace();
  1245. }
  1246.  
  1247. } else if (tempors.length == 3) {
  1248. try {
  1249. nombreInformeCorto = tempors[0].trim() + Integer.parseInt(tempors[1].trim());
  1250. tempors = tempors[2].replaceAll(".pdf", "").split(" ");
  1251. if (tempors.length == 2) {
  1252. nombreInformeCorto = nombreInformeCorto + tempors[0].trim() + Integer.parseInt(tempors[1].trim());
  1253. if (this.infoUsa.get(nombreInformeCorto.trim()) != null) {
  1254. resultado.add(this.infoUsa.get(nombreInformeCorto.trim()));
  1255. return resultado;
  1256. }
  1257. }
  1258. } catch (Exception eee) {
  1259. try {
  1260. nombreInformeCorto = tempors[1].trim() + Integer.parseInt(tempors[2].trim());
  1261. tempors = tempors[0].replaceAll(".pdf", "").split(" ");
  1262. if (tempors.length == 2) {
  1263. nombreInformeCorto = tempors[0].trim() + Integer.parseInt(tempors[1].trim()) + nombreInformeCorto;
  1264. if (this.infoUsa.get(nombreInformeCorto.trim()) != null) {
  1265. resultado.add(this.infoUsa.get(nombreInformeCorto.trim()));
  1266. return resultado;
  1267. }
  1268. }
  1269. } catch (Exception eeet) {
  1270. eeet.printStackTrace();
  1271. eeet.printStackTrace();
  1272.  
  1273. }
  1274.  
  1275. }
  1276.  
  1277. }
  1278. // if (carpeta.isDirectory()) {
  1279. // for (File file : carpeta.listFiles()) {
  1280. // resultado = buscaArchivoInformeUSA(file, nombreInformeCorto, resultado);
  1281. // if (resultado.size() > 0) {
  1282. // return resultado;
  1283. // }
  1284. // }
  1285. // } else {
  1286. // String nombreArchivo = carpeta.getName();
  1287. // if (nombreArchivo.indexOf(".") > 0) {
  1288. // nombreArchivo = carpeta.getName().replaceAll("-", "").replaceAll(" ", "").replaceAll(".pdf", "").replaceAll(" ", "");
  1289. // }
  1290. // if (nombreArchivo.equals(nombreInformeCorto)) {
  1291. // resultado.add(carpeta);
  1292. // return resultado;
  1293. // } else {
  1294. // nombreArchivo = carpeta.getName();
  1295. // if (nombreArchivo.indexOf(".") > 0) {
  1296. // nombreArchivo = carpeta.getName().replaceAll("AT", "").replaceAll("-", "").replaceAll(" ", "").replaceAll(".pdf", "").replaceAll(" ", "");
  1297. // }
  1298. // nombreInformeCorto = nombreInformeCorto.replaceAll("-", "").replaceAll(" ", "").replaceAll(".pdf", "").replaceAll(" ", "");
  1299. // int tempi = nombreArchivo.indexOf("UT");
  1300. // try {
  1301. // String nom1 = nombreArchivo.substring(0, tempi + 2).replaceAll("0", "");;
  1302. // String nomb2 = nombreArchivo.substring(tempi + 2, nombreArchivo.length());
  1303. //
  1304. // tempi = Integer.parseInt(nomb2);
  1305. //
  1306. // nombreArchivo = nom1 + tempi;
  1307. // tempi = nombreInformeCorto.indexOf("UT");
  1308. // nom1 = nombreInformeCorto.substring(0, tempi + 2).replaceAll("0", "");;
  1309. // nomb2 = nombreInformeCorto.substring(tempi + 2, nombreInformeCorto.length());
  1310. // try {
  1311. // tempi = Integer.parseInt(nomb2);
  1312. // } catch (Exception e) {
  1313. // }
  1314. // nombreInformeCorto = nom1 + tempi;
  1315. // if (nombreArchivo.equals(nombreInformeCorto)) {
  1316. // resultado.add(carpeta);
  1317. // return resultado;
  1318. // }
  1319. // } catch (Exception e) {
  1320. // }
  1321. //
  1322. // }
  1323. // }
  1324. return resultado;
  1325. }
  1326.  
  1327. private JuntaDtoLocal lookupJuntaDtoLocal() {
  1328. try {
  1329. Context c = new InitialContext();
  1330. return (JuntaDtoLocal) c.lookup("java:global/oleoducto/oleoducto-ejb/JuntaDto!com.side.oleoducto.mantenimiento.JuntaDtoLocal");
  1331. } catch (NamingException ne) {
  1332. Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
  1333. throw new RuntimeException(ne);
  1334. }
  1335. }
  1336.  
  1337. private ParametrosDtoLocal lookupParametrosDtoLocal() {
  1338. try {
  1339. Context c = new InitialContext();
  1340. return (ParametrosDtoLocal) c.lookup("java:global/oleoducto/oleoducto-ejb/ParametrosDto!com.side.oleoducto.mantenimiento.ParametrosDtoLocal");
  1341. } catch (NamingException ne) {
  1342. Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
  1343. throw new RuntimeException(ne);
  1344. }
  1345. }
  1346.  
  1347. private JuntaReparcionDtoLocal lookupJuntaReparcionDtoLocal() {
  1348. try {
  1349. Context c = new InitialContext();
  1350. return (JuntaReparcionDtoLocal) c.lookup("java:global/oleoducto/oleoducto-ejb/JuntaReparcionDto!com.side.oleoducto.mantenimiento.JuntaReparcionDtoLocal");
  1351. } catch (NamingException ne) {
  1352. Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
  1353. throw new RuntimeException(ne);
  1354. }
  1355. }
  1356.  
  1357. private Archivo getArchivo(File file, Archivo archivo) {
  1358. try {
  1359. if (!archivo.isNuevo()) {
  1360. return archivo;
  1361. }
  1362. // LiberaMemoria(hilo);
  1363. // LiberaMemoria(hilo);
  1364. if (!file.exists()) {
  1365. consola2("no existe el archivo " + file.getPath());
  1366. return null;
  1367. }
  1368. archivo.setNombre(file.getName());
  1369. archivo.setPath(file.getPath());
  1370. archivo.setTipo(getExtenciones().get(tipoArchvioExtension(file.getName())));
  1371.  
  1372. byte[] buf = new byte[1024];
  1373. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  1374. FileInputStream fis = new FileInputStream(file);
  1375. try {
  1376. for (int readNum; (readNum = fis.read(buf)) != -1;) {
  1377. bos.write(buf, 0, readNum);
  1378. }
  1379. } catch (IOException ioe) {
  1380. consola2("no existe el archivoIOException " + file.getPath());
  1381. return null;
  1382. }
  1383. archivo.setDatos(bos.toByteArray());
  1384. archivo.setBorrado(Short.parseShort("0"));
  1385. archivo.setUsuarioauditoria(usuario.getCodigo());
  1386. archivo.setPerfilauditoria(usuario.getPerfil().getCodigo());
  1387. archivo.setFechamodificacion(new Date());
  1388. archivo.setSegmento(this.libroTuberia.getSegmento().getCodigo());
  1389. this.archivosDto.guardar(archivo);
  1390.  
  1391. return archivo;
  1392. } catch (OutOfMemoryError ex) {
  1393. LiberaMemoria(hilo);
  1394. LiberaMemoria(hilo);
  1395. // consola2("OutOfMemoryError " + file.getPath());
  1396. LiberaMemoria(hilo);
  1397. LiberaMemoria(hilo);
  1398. ex.printStackTrace();
  1399. ex.printStackTrace();
  1400. try {
  1401. if (!file.exists()) {
  1402. consola2("no existe el archivo " + file.getPath());
  1403. return null;
  1404. }
  1405. archivo.setNombre(file.getName());
  1406. archivo.setPath(file.getPath());
  1407. archivo.setTipo(getExtenciones().get(tipoArchvioExtension(file.getName())));
  1408.  
  1409. byte[] buf = new byte[1024];
  1410. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  1411. FileInputStream fis = new FileInputStream(file);
  1412. try {
  1413. for (int readNum; (readNum = fis.read(buf)) != -1;) {
  1414. bos.write(buf, 0, readNum);
  1415. }
  1416. } catch (IOException ioe) {
  1417. return null;
  1418. }
  1419. archivo.setDatos(bos.toByteArray());
  1420. archivo.setBorrado(Short.parseShort("0"));
  1421. archivo.setUsuarioauditoria(usuario.getCodigo());
  1422. archivo.setPerfilauditoria(usuario.getPerfil().getCodigo());
  1423. archivo.setFechamodificacion(new Date());
  1424. archivo.setSegmento(this.libroTuberia.getSegmento().getCodigo());
  1425. this.archivosDto.guardar(archivo);
  1426.  
  1427. return archivo;
  1428. } catch (OutOfMemoryError ex2) {
  1429. LiberaMemoria(hilo);
  1430. LiberaMemoria(hilo);
  1431. consola2("OutOfMemoryError " + file.getPath());
  1432. ex2.printStackTrace();
  1433. ex2.printStackTrace();
  1434. } catch (Exception ex2) {
  1435. consola2("get archivo Exception2 " + file.getPath() + " " + ex.getMessage());
  1436. ex2.printStackTrace();
  1437. ex2.printStackTrace();
  1438. }
  1439. } catch (Exception ex) {
  1440. consola2("get archivo Exception " + file.getPath() + " " + ex.getMessage());
  1441. ex.printStackTrace();
  1442. ex.printStackTrace();
  1443. }
  1444. return null;
  1445.  
  1446. }
  1447.  
  1448. private ArchivosDtoLocal lookupArchivosDtoLocal() {
  1449. try {
  1450. Context c = new InitialContext();
  1451. return (ArchivosDtoLocal) c.lookup("java:global/oleoducto/oleoducto-ejb/ArchivosDto!com.side.oleoducto.mantenimiento.ArchivosDtoLocal");
  1452. } catch (NamingException ne) {
  1453. Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
  1454. throw new RuntimeException(ne);
  1455. }
  1456. }
  1457.  
  1458. private void LiberaMemoria(int i) {
  1459.  
  1460. // Get a Runtime object
  1461. Runtime r = Runtime.getRuntime();
  1462.  
  1463. // Collect garbage at the start of the program
  1464. long availMem = r.freeMemory();
  1465. r.gc();
  1466. System.gc();
  1467. System.gc();
  1468. r.gc();
  1469.  
  1470. //Let's see what we have now
  1471. long availMem2 = r.freeMemory();
  1472. //consola("After collecting garbage we have : " + availMem + " --" + availMem2 + " bytes hilo " + hilo + " i = " + i);
  1473. }
  1474. private static final Logger LOG = Logger.getLogger(CargaArchivos.class
  1475. .getName());
  1476.  
  1477. @Override
  1478. protected void finalize() {
  1479. try {
  1480. this.juntas = null;
  1481. System.gc();
  1482. System.gc();
  1483. consola("Salio hilo" + hilo);
  1484. try {
  1485. super.finalize();
  1486. } catch (Throwable ex) {
  1487. Logger.getLogger(CargaArchivos.class.getName()).log(Level.SEVERE, null, ex);
  1488. }
  1489. } finally {
  1490. try {
  1491. super.finalize();
  1492. } catch (Throwable ex) {
  1493. Logger.getLogger(CargaArchivos.class.getName()).log(Level.SEVERE, null, ex);
  1494. }
  1495. }
  1496.  
  1497. }
  1498.  
  1499. public HashMap<Short, String> getParametros() {
  1500. if (parametros == null) {
  1501. parametros = new CollectionsUtils.ConstMap<Short, String>();
  1502. List<Parametros> paramet = this.parametrosDto.buscarTodos();
  1503. for (Parametros par : paramet) {
  1504. parametros.put(par.getTipo(), par.getValor());
  1505. }
  1506. String tem = parametros.get(LEComboTipoParametro.CARPETATEMPORAL.getId());
  1507. if (tem.indexOf("\\") < 0) {
  1508. this.separador = "/";
  1509. }
  1510. }
  1511. return parametros;
  1512. }
  1513.  
  1514. private void consola(String msg) {
  1515. // System.out.println(msg);
  1516. }
  1517.  
  1518. private void consola2(String msg) {
  1519. System.out.println(msg);
  1520. }
  1521.  
  1522. private void consola(int msg) {
  1523. consola(msg + "");
  1524. }
  1525.  
  1526. private void consola(Boolean msg) {
  1527. consola(msg + "");
  1528. }
  1529.  
  1530. public HashMap<String, ArchivoImagenJunta> getJuntasF2() {
  1531. return juntasF2;
  1532. }
  1533.  
  1534. public void setJuntasF2(HashMap<String, ArchivoImagenJunta> juntasF2) {
  1535. this.juntasF2 = juntasF2;
  1536. }
  1537.  
  1538. private String validaNombreYHoja(String nombreArchivoCarpeta, Junta junta) {
  1539. return validaNombreYHoja(nombreArchivoCarpeta, junta.getHojaReal());
  1540. }
  1541.  
  1542. private String validaNombreYHoja(String nombreArchivoCarpeta, JuntaReparcion junta) {
  1543. return validaNombreYHoja(nombreArchivoCarpeta, junta.getHojaReal());
  1544. }
  1545.  
  1546. private String validaNombreYHoja(String nombreArchivoCarpeta, String hojaReal) {
  1547. if (hojaReal.equals("SCARF 50002 KMO")) {
  1548. nombreArchivoCarpeta = "SCARF50002K0";
  1549. } else if (hojaReal.equals("SCARF 50002 KM1")) {
  1550. nombreArchivoCarpeta = "SCARF50002K1";
  1551. } else if (hojaReal.equals("M.TRAM 50001")) {
  1552. nombreArchivoCarpeta = "TRAMP50001";
  1553. } else if (hojaReal.equals("M.TRAMP 50003")) {
  1554. nombreArchivoCarpeta = "TRAMP50003";
  1555. } else if (hojaReal.equals("TIEIN-KM31")) {
  1556. nombreArchivoCarpeta = "TIEIN K31";
  1557. } else if (hojaReal.equals("CPF-CUS-K34")) {
  1558. nombreArchivoCarpeta = "CPF CUS K34";
  1559. } else if (hojaReal.equals("KST-85")) {
  1560. nombreArchivoCarpeta = "KST85";
  1561. } else if (hojaReal.equals("RUSA Km94")) {
  1562. nombreArchivoCarpeta = "KRUSA94";
  1563. } else if (hojaReal.equals("RUSA K95")) {
  1564. nombreArchivoCarpeta = "KRUSA95";
  1565. } else if (hojaReal.equals("RUSA K96")) {
  1566. nombreArchivoCarpeta = "KRUSA96";
  1567. } else if (hojaReal.equals("KST-93")) {
  1568. nombreArchivoCarpeta = "KST93";
  1569. } else if (hojaReal.equals("KST-94")) {
  1570. nombreArchivoCarpeta = "KST94";
  1571. } else if (hojaReal.equals("CALIF-PROSED-SOLD")) {
  1572. nombreArchivoCarpeta = "CALIFICACION-PROCEDIMIENTO";
  1573. } else if (hojaReal.equals("K201LR")) {
  1574. nombreArchivoCarpeta = "K201LR";
  1575. } else if (hojaReal.equals("K201OE")) {
  1576. nombreArchivoCarpeta = "K201OE";
  1577. } else if (hojaReal.equals("k202LR")) {
  1578. nombreArchivoCarpeta = "K202LR";
  1579. } else if (hojaReal.equals("K202OE")) {
  1580. nombreArchivoCarpeta = "K202OE";
  1581. } else if (hojaReal.equals("K203LR")) {
  1582. nombreArchivoCarpeta = "K203LR";
  1583. } else if (hojaReal.equals("K203OE")) {
  1584. nombreArchivoCarpeta = "K203OE";
  1585. } else if (hojaReal.equals("K204LR")) {
  1586. nombreArchivoCarpeta = "K204LR";
  1587. } else if (hojaReal.equals("K204OE")) {
  1588. nombreArchivoCarpeta = "K204OE";
  1589. } else if (hojaReal.equals("K226LR")) {
  1590. nombreArchivoCarpeta = "K226LR";
  1591. } else if (hojaReal.equals("K226OE")) {
  1592. nombreArchivoCarpeta = "K226OE";
  1593. } else if (hojaReal.equals("TRAMPAS")) {
  1594. nombreArchivoCarpeta = "SOLD-TRAMPAS";
  1595. } else if (hojaReal.equals("Km465 J64-J83")) {
  1596. nombreArchivoCarpeta = "K465 J64 J83";
  1597. } else if (hojaReal.equals("Km467 J65-J83")) {
  1598. nombreArchivoCarpeta = "K467 J65 J83";
  1599. } else if (hojaReal.equals("Km468 J64-81")) {
  1600. nombreArchivoCarpeta = "K468 J64 J81";
  1601. } else if (hojaReal.equals("Km473 J64-J83")) {
  1602. nombreArchivoCarpeta = "K473 J64-J83";
  1603. } else if (hojaReal.equals("Km475 J65-J83")) {
  1604. nombreArchivoCarpeta = "K475 J65-J83";
  1605. } else if (hojaReal.equals("Km476 J65-J83")) {
  1606. nombreArchivoCarpeta = "K476 J65-J83";
  1607. } else if (hojaReal.equals("Km478 W65-W85")) {
  1608. nombreArchivoCarpeta = "K478 W65-W85";
  1609. } else if (hojaReal.equals("Km481 W65-W85")) {
  1610. nombreArchivoCarpeta = "K481 W65-W85";
  1611. } else if (hojaReal.equals("Km484 W65-W85")) {
  1612. nombreArchivoCarpeta = "K484 W65-W85";
  1613. } else if (hojaReal.equals("Km485 W65-W83")) {
  1614. nombreArchivoCarpeta = "K485 W65-W83";
  1615. } else if (hojaReal.equals("Km488 W65-W85")) {
  1616. nombreArchivoCarpeta = "K488 W65-W85";
  1617. } else if (hojaReal.equals("Km489 W65-W85")) {
  1618. nombreArchivoCarpeta = "K489 W65-W";
  1619. } else if (hojaReal.equals("Km490 W65-W85")) {
  1620. nombreArchivoCarpeta = "K490 W65-W";
  1621. } else if (hojaReal.equals("Km491 W65-W77T")) {
  1622. nombreArchivoCarpeta = "K491 W65-W";
  1623. } else if (hojaReal.equals("Km492 W65-W81")) {
  1624. nombreArchivoCarpeta = "K492 W65-W";
  1625. } else if (hojaReal.equals("Km492B2 W65-W73 ")) {
  1626. nombreArchivoCarpeta = "K492B2 W65-W";
  1627. } else if (hojaReal.equals("Km493 W65-W83")) {
  1628. nombreArchivoCarpeta = "K493";
  1629. } else if (hojaReal.equals("Km493B2")) {
  1630. nombreArchivoCarpeta = "K493 B2";
  1631. } else if (hojaReal.equals("Km493B2 W65-W82")) {
  1632. nombreArchivoCarpeta = "K493 W65-W B2";
  1633. } else if (hojaReal.equals("Km494 W65-W86")) {
  1634. nombreArchivoCarpeta = "K494 W65-W82";
  1635. } else if (hojaReal.equals("Km494B2")) {
  1636. nombreArchivoCarpeta = "K494B2";
  1637. } else if (hojaReal.equals("Km494B2 W65-W82")) {
  1638. nombreArchivoCarpeta = "K494B2 W65-W82";
  1639. } else if (hojaReal.equals("Km495 W65 W76")) {
  1640. nombreArchivoCarpeta = "K495 W65-W76";
  1641. } else if (hojaReal.equals("Km495B2")) {
  1642. nombreArchivoCarpeta = "K495B2";
  1643. } else if (hojaReal.equals("Km495B2 W65 W82")) {
  1644. nombreArchivoCarpeta = "K495B2 W65-W82";
  1645. } else if (hojaReal.equals("Km496 W65T")) {
  1646. nombreArchivoCarpeta = "K496 W65T";
  1647. } else if (hojaReal.equals("Km496B2")) {
  1648. nombreArchivoCarpeta = "K496B2";
  1649. } else if (hojaReal.equals("Km496B2 W65-W82")) {
  1650. nombreArchivoCarpeta = "K496B2 W65-W82";
  1651. } else if (hojaReal.equals("Km497 W65-W80")) {
  1652. nombreArchivoCarpeta = "K497 W65-W82";
  1653. } else if (hojaReal.equals("Km498 W65-W75")) {
  1654. nombreArchivoCarpeta = "K498 W65-W75";
  1655. } else if (hojaReal.equals("Km499 W65-W81")) {
  1656. nombreArchivoCarpeta = "K499 W65-W81";
  1657. } else if (hojaReal.equals("Km500 W65-W82")) {
  1658. nombreArchivoCarpeta = "K500 W65-W83";
  1659. } else if (hojaReal.equals("Km502 W65-W83")) {
  1660. nombreArchivoCarpeta = "K502 W65-W83";
  1661. } else if (hojaReal.equals("Km503 W65-W81")) {
  1662. nombreArchivoCarpeta = "K503 W65-W81";
  1663. } else if (hojaReal.equals("Km504 W65-W71")) {
  1664. nombreArchivoCarpeta = "K504 W65-W71";
  1665. } else if (hojaReal.equals("Km505 W65-W81")) {
  1666. nombreArchivoCarpeta = "K505 W65-W81";
  1667. } else if (hojaReal.equals("Km506 W65-W74")) {
  1668. nombreArchivoCarpeta = "K506 W65-W74";
  1669. } else if (hojaReal.equals("Km507 W65-W78")) {
  1670. nombreArchivoCarpeta = "K507 W65-W78";
  1671. } else if (hojaReal.equals("Km508 W65-W79")) {
  1672. nombreArchivoCarpeta = "K508 W65-W79";
  1673. } else if (hojaReal.equals("Km509 W65-W68")) {
  1674. nombreArchivoCarpeta = "K509 W65-W68";
  1675. } else if (hojaReal.equals("Km510 W65-W78")) {
  1676. nombreArchivoCarpeta = "K510 W65-W78";
  1677. } else if (hojaReal.equals("Km511 W65-W70")) {
  1678. nombreArchivoCarpeta = "K511 W65 W70";
  1679. } else if (hojaReal.equals("Km512 W65-W75")) {
  1680. nombreArchivoCarpeta = "K512 W65-W75";
  1681. } else if (hojaReal.equals("Km513 NRC")) {
  1682. nombreArchivoCarpeta = "K513 NRC";
  1683. } else if (hojaReal.equals("Km513 W1-W32")) {
  1684. nombreArchivoCarpeta = "K513W1-W32";
  1685. } else if (hojaReal.equals("Km513 W33-39")) {
  1686. nombreArchivoCarpeta = "K513W33-W39";
  1687. } else if (hojaReal.equals("Km556")) {
  1688. nombreArchivoCarpeta = "K556 W1-W51";
  1689. } else if (hojaReal.equals("Km556 27AT-27DT")) {
  1690. nombreArchivoCarpeta = "K556 W1-W51";
  1691. } else if (hojaReal.equals("Km591 W22AT-62A")) {
  1692. nombreArchivoCarpeta = "K591W22AT-W62A";
  1693. } else if (hojaReal.equals(" K737")) {
  1694. nombreArchivoCarpeta = "K737";
  1695. } else if (hojaReal.equals("K610W1-W50")) {
  1696. nombreArchivoCarpeta = "K610";
  1697. } else if (hojaReal.equals("K610W8T-50FT")) {
  1698. nombreArchivoCarpeta = "K610";
  1699. } else if (hojaReal.equals("K613MLW1-W23")) {
  1700. nombreArchivoCarpeta = "K613 W1 W23";
  1701. } else if (hojaReal.equals("K613SJRCSW1-W27")) {
  1702. nombreArchivoCarpeta = "K613 SJRC W1 W27";
  1703. } else {
  1704.  
  1705. try {
  1706.  
  1707. nombreArchivoCarpeta = nombreArchivoCarpeta.replaceAll("KM", "").replaceAll("Km", "").replaceAll("km", "").replaceAll("kM", "")
  1708. .replaceAll("kM", "").replaceAll("k", "").replaceAll("K", "").trim();
  1709. nombreArchivoCarpeta = Integer.parseInt(nombreArchivoCarpeta) + "";
  1710.  
  1711. nombreArchivoCarpeta = "KM" + nombreArchivoCarpeta;
  1712. } catch (Exception expp) {
  1713.  
  1714. }
  1715. }
  1716. return nombreArchivoCarpeta;
  1717. }
  1718.  
  1719. private String validaNombreYHojakilometroCarpeta(String nombreArchivoCarpeta, Junta junta) {
  1720. return validaNombreYHojakilometroCarpeta(nombreArchivoCarpeta, junta.getHojaReal());
  1721. }
  1722.  
  1723. private String validaNombreYHojakilometroCarpeta(String nombreArchivoCarpeta, JuntaReparcion junta) {
  1724. return validaNombreYHojakilometroCarpeta(nombreArchivoCarpeta, junta.getHojaReal());
  1725. }
  1726.  
  1727. private String validaNombreYHojakilometroCarpeta(String nombreArchivoCarpeta, String hojaReal) {
  1728. if (hojaReal.equals("SCARF 50002 KMO")) {
  1729. nombreArchivoCarpeta = "SCARF50002K0";
  1730. } else if (hojaReal.equals("SCARF 50002 KM1")) {
  1731. nombreArchivoCarpeta = "SCARF50002K1";
  1732. } else if (hojaReal.equals("M.TRAM 50001")) {
  1733. nombreArchivoCarpeta = "TRAMP50001";
  1734. } else if (hojaReal.equals("M.TRAMP 50003")) {
  1735. nombreArchivoCarpeta = "TRAMP50003";
  1736. } else if (hojaReal.equals("TIEIN-KM31")) {
  1737. nombreArchivoCarpeta = "TIEIN K31";
  1738. } else if (hojaReal.equals("CPF-CUS-K34")) {
  1739. nombreArchivoCarpeta = "CPF CUS K34";
  1740. } else if (hojaReal.equals("KST-85")) {
  1741. nombreArchivoCarpeta = "KST85";
  1742. } else if (hojaReal.equals("RUSA Km94")) {
  1743. nombreArchivoCarpeta = "KRUSA94";
  1744. } else if (hojaReal.equals("RUSA K95")) {
  1745. nombreArchivoCarpeta = "KRUSA95";
  1746. } else if (hojaReal.equals("RUSA K96")) {
  1747. nombreArchivoCarpeta = "KRUSA96";
  1748. } else if (hojaReal.equals("KST-93")) {
  1749. nombreArchivoCarpeta = "KST93";
  1750. } else if (hojaReal.equals("KST-94")) {
  1751. nombreArchivoCarpeta = "KST94";
  1752. } else if (hojaReal.equals("CALIF-PROSED-SOLD")) {
  1753. nombreArchivoCarpeta = "CALIFICACION-PROCEDIMIENTO";
  1754. } else if (hojaReal.equals("K201LR")) {
  1755. nombreArchivoCarpeta = "K201LR";
  1756. } else if (hojaReal.equals("K201OE")) {
  1757. nombreArchivoCarpeta = "K201OE";
  1758. } else if (hojaReal.equals("k202LR")) {
  1759. nombreArchivoCarpeta = "K202LR";
  1760. } else if (hojaReal.equals("K202OE")) {
  1761. nombreArchivoCarpeta = "K202OE";
  1762. } else if (hojaReal.equals("K203LR")) {
  1763. nombreArchivoCarpeta = "K203LR";
  1764. } else if (hojaReal.equals("K203OE")) {
  1765. nombreArchivoCarpeta = "K203OE";
  1766. } else if (hojaReal.equals("K204LR")) {
  1767. nombreArchivoCarpeta = "K204LR";
  1768. } else if (hojaReal.equals("K204OE")) {
  1769. nombreArchivoCarpeta = "K204OE";
  1770. } else if (hojaReal.equals("K226LR")) {
  1771. nombreArchivoCarpeta = "K226LR";
  1772. } else if (hojaReal.equals("K226OE")) {
  1773. nombreArchivoCarpeta = "K226OE";
  1774. } else if (hojaReal.equals("TRAMPAS")) {
  1775. nombreArchivoCarpeta = "SOLD-TRAMPAS";
  1776. } else if (hojaReal.equals("Km465 J64-J83")) {
  1777. nombreArchivoCarpeta = "K465 J64 J83";
  1778. } else if (hojaReal.equals("Km467 J65-J83")) {
  1779. nombreArchivoCarpeta = "K467 J65 J83";
  1780. } else if (hojaReal.equals("Km468 J64-81")) {
  1781. nombreArchivoCarpeta = "K468 J64 J81";
  1782. } else if (hojaReal.equals("Km473 J64-J83")) {
  1783. nombreArchivoCarpeta = "K473 J64-J83";
  1784. } else if (hojaReal.equals("Km475 J65-J83")) {
  1785. nombreArchivoCarpeta = "K475 J65-J83";
  1786. } else if (hojaReal.equals("Km476 J65-J83")) {
  1787. nombreArchivoCarpeta = "K476 J65-J83";
  1788. } else if (hojaReal.equals("Km478 W65-W85")) {
  1789. nombreArchivoCarpeta = "K478 W65-W85";
  1790. } else if (hojaReal.equals("Km481 W65-W85")) {
  1791. nombreArchivoCarpeta = "K481 W65-W85";
  1792. } else if (hojaReal.equals("Km484 W65-W85")) {
  1793. nombreArchivoCarpeta = "K484 W65-W85";
  1794. } else if (hojaReal.equals("Km485 W65-W83")) {
  1795. nombreArchivoCarpeta = "K485 W65-W83";
  1796. } else if (hojaReal.equals("Km488 W65-W85")) {
  1797. nombreArchivoCarpeta = "K488 W65-W85";
  1798. } else if (hojaReal.equals("Km489 W65-W85")) {
  1799. nombreArchivoCarpeta = "K489 W65-W";
  1800. } else if (hojaReal.equals("Km490 W65-W85")) {
  1801. nombreArchivoCarpeta = "K490 W65-W";
  1802. } else if (hojaReal.equals("Km491 W65-W77T")) {
  1803. nombreArchivoCarpeta = "K491 W65-W";
  1804. } else if (hojaReal.equals("Km492 W65-W81")) {
  1805. nombreArchivoCarpeta = "K492 W65-W";
  1806. } else if (hojaReal.equals("Km492B2 W65-W73 ")) {
  1807. nombreArchivoCarpeta = "K492B2 W65-W";
  1808. } else if (hojaReal.equals("Km493 W65-W83")) {
  1809. nombreArchivoCarpeta = "K493";
  1810. } else if (hojaReal.equals("Km493B2")) {
  1811. nombreArchivoCarpeta = "K493 B2";
  1812. } else if (hojaReal.equals("Km493B2 W65-W82")) {
  1813. nombreArchivoCarpeta = "K493 W65-W B2";
  1814. } else if (hojaReal.equals("Km494 W65-W86")) {
  1815. nombreArchivoCarpeta = "K494 W65-W82";
  1816. } else if (hojaReal.equals("Km494B2")) {
  1817. nombreArchivoCarpeta = "K494B2";
  1818. } else if (hojaReal.equals("Km494B2 W65-W82")) {
  1819. nombreArchivoCarpeta = "K494B2 W65-W82";
  1820. } else if (hojaReal.equals("Km495 W65 W76")) {
  1821. nombreArchivoCarpeta = "K495 W65-W76";
  1822. } else if (hojaReal.equals("Km495B2")) {
  1823. nombreArchivoCarpeta = "K495B2";
  1824. } else if (hojaReal.equals("Km495B2 W65 W82")) {
  1825. nombreArchivoCarpeta = "K495B2 W65-W82";
  1826. } else if (hojaReal.equals("Km496 W65T")) {
  1827. nombreArchivoCarpeta = "K496 W65T";
  1828. } else if (hojaReal.equals("Km496B2")) {
  1829. nombreArchivoCarpeta = "K496B2";
  1830. } else if (hojaReal.equals("Km496B2 W65-W82")) {
  1831. nombreArchivoCarpeta = "K496B2 W65-W82";
  1832. } else if (hojaReal.equals("Km497 W65-W80")) {
  1833. nombreArchivoCarpeta = "K497 W65-W82";
  1834. } else if (hojaReal.equals("Km498 W65-W75")) {
  1835. nombreArchivoCarpeta = "K498 W65-W75";
  1836. } else if (hojaReal.equals("Km499 W65-W81")) {
  1837. nombreArchivoCarpeta = "K499 W65-W81";
  1838. } else if (hojaReal.equals("Km500 W65-W82")) {
  1839. nombreArchivoCarpeta = "K500 W65-W83";
  1840. } else if (hojaReal.equals("Km502 W65-W83")) {
  1841. nombreArchivoCarpeta = "K502 W65-W83";
  1842. } else if (hojaReal.equals("Km503 W65-W81")) {
  1843. nombreArchivoCarpeta = "K503 W65-W81";
  1844. } else if (hojaReal.equals("Km504 W65-W71")) {
  1845. nombreArchivoCarpeta = "K504 W65-W71";
  1846. } else if (hojaReal.equals("Km505 W65-W81")) {
  1847. nombreArchivoCarpeta = "K505 W65-W81";
  1848. } else if (hojaReal.equals("Km506 W65-W74")) {
  1849. nombreArchivoCarpeta = "K506 W65-W74";
  1850. } else if (hojaReal.equals("Km507 W65-W78")) {
  1851. nombreArchivoCarpeta = "K507 W65-W78";
  1852. } else if (hojaReal.equals("Km508 W65-W79")) {
  1853. nombreArchivoCarpeta = "K508 W65-W79";
  1854. } else if (hojaReal.equals("Km509 W65-W68")) {
  1855. nombreArchivoCarpeta = "K509 W65-W68";
  1856. } else if (hojaReal.equals("Km510 W65-W78")) {
  1857. nombreArchivoCarpeta = "K510 W65-W78";
  1858. } else if (hojaReal.equals("Km511 W65-W70")) {
  1859. nombreArchivoCarpeta = "K511 W65 W70";
  1860. } else if (hojaReal.equals("Km512 W65-W75")) {
  1861. nombreArchivoCarpeta = "K512 W65-W75";
  1862. } else if (hojaReal.equals("Km513 NRC")) {
  1863. nombreArchivoCarpeta = "K513 NRC";
  1864. } else if (hojaReal.equals("Km513 W1-W32")) {
  1865. nombreArchivoCarpeta = "K513W1-W32";
  1866. } else if (hojaReal.equals("Km513 W33-39")) {
  1867. nombreArchivoCarpeta = "K513W33-W39";
  1868. } else if (hojaReal.equals("Km556")) {
  1869. nombreArchivoCarpeta = "K556 W1-W51";
  1870. } else if (hojaReal.equals("Km556 27AT-27DT")) {
  1871. nombreArchivoCarpeta = "K556 W1-W51";
  1872. } else if (hojaReal.equals("Km591 W22AT-62A")) {
  1873. nombreArchivoCarpeta = "K591W22AT-W62A";
  1874. } else if (hojaReal.equals(" K737")) {
  1875. nombreArchivoCarpeta = "K737";
  1876. } else if (hojaReal.equals("K610W1-W50")) {
  1877. nombreArchivoCarpeta = "K610";
  1878. } else if (hojaReal.equals("K610W8T-50FT")) {
  1879. nombreArchivoCarpeta = "K610";
  1880. } else if (hojaReal.equals("K613MLW1-W23")) {
  1881. nombreArchivoCarpeta = "K613 W1 W23";
  1882. } else if (hojaReal.equals("K613SJRCSW1-W27")) {
  1883. nombreArchivoCarpeta = "K613 SJRC W1 W27";
  1884. } else {
  1885.  
  1886. try {
  1887. nombreArchivoCarpeta = nombreArchivoCarpeta.replaceAll("KM", "").replaceAll("Km", "").replaceAll("km", "").replaceAll("kM", "")
  1888. .replaceAll("kM", "").replaceAll("k", "").replaceAll("K", "").trim();
  1889. nombreArchivoCarpeta = Integer.parseInt(nombreArchivoCarpeta) + "";
  1890.  
  1891. return nombreArchivoCarpeta;
  1892. } catch (Exception expp) {
  1893. consola2(nombreArchivoCarpeta);
  1894. }
  1895. }
  1896. return "";
  1897. }
  1898.  
  1899. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement