|
|
@@ -8,6 +8,7 @@ import java.io.Reader;
|
|
|
import java.io.UncheckedIOException;
|
|
|
import java.math.BigInteger;
|
|
|
import java.nio.file.Files;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Base64;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
@@ -36,6 +37,7 @@ import es.uv.saic.shared.domain.Plantilla;
|
|
|
import es.uv.saic.shared.domain.PlantillaComentario;
|
|
|
import es.uv.saic.shared.domain.PlantillaConversation;
|
|
|
import es.uv.saic.shared.domain.PlantillaRepository;
|
|
|
+import es.uv.saic.shared.domain.UsuarisRolRepository;
|
|
|
import es.uv.saic.shared.dto.InstanciaTascaDTO;
|
|
|
import es.uv.saic.shared.feign.TascaClient;
|
|
|
|
|
|
@@ -44,6 +46,8 @@ public class PlantillaService {
|
|
|
|
|
|
@Autowired
|
|
|
private PlantillaRepository r;
|
|
|
+ @Autowired
|
|
|
+ private UsuarisRolRepository usuarisRolRepository;
|
|
|
|
|
|
@Value("${saic.data.filePath}")
|
|
|
private String filePath;
|
|
|
@@ -109,25 +113,25 @@ public class PlantillaService {
|
|
|
|
|
|
public String savePDF(String content, BigInteger idtascai) throws IOException, InterruptedException {
|
|
|
InstanciaTascaDTO instanciaTasca = tc.findInstanciaTascaById(idtascai);
|
|
|
-
|
|
|
- Plantilla plantilla = this.findEvidencia(Integer.parseInt(instanciaTasca.getTasca().getCodiEvidencia()),
|
|
|
- instanciaTasca.getInstancia().getTitulacio(), instanciaTasca.getInstancia().getTambit());
|
|
|
-
|
|
|
String width = "297mm";
|
|
|
String height = "210mm";
|
|
|
+ if (instanciaTasca.getTasca().getIdTipus() == 11 || instanciaTasca.getTasca().getIdTipus() == 15){
|
|
|
+ Plantilla plantilla = this.findEvidencia(Integer.parseInt(instanciaTasca.getTasca().getCodiEvidencia()),
|
|
|
+ instanciaTasca.getInstancia().getTitulacio(), instanciaTasca.getInstancia().getTambit());
|
|
|
|
|
|
- if (plantilla.getOpcions() != null && !plantilla.getOpcions().trim().isEmpty()) {
|
|
|
- try {
|
|
|
- ObjectMapper mapper = new ObjectMapper();
|
|
|
- JsonNode rootNode = mapper.readTree(plantilla.getOpcions());
|
|
|
- JsonNode orientacionNode = rootNode.get("orientacion");
|
|
|
+ if (plantilla.getOpcions() != null && !plantilla.getOpcions().trim().isEmpty()) {
|
|
|
+ try {
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ JsonNode rootNode = mapper.readTree(plantilla.getOpcions());
|
|
|
+ JsonNode orientacionNode = rootNode.get("orientacion");
|
|
|
|
|
|
- if (orientacionNode != null && "vertical".equalsIgnoreCase(orientacionNode.asText())) {
|
|
|
- width = "210mm";
|
|
|
- height = "297mm";
|
|
|
+ if (orientacionNode != null && "vertical".equalsIgnoreCase(orientacionNode.asText())) {
|
|
|
+ width = "210mm";
|
|
|
+ height = "297mm";
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("Error al parsear el JSON de opciones: " + e.getMessage());
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- System.err.println("Error al parsear el JSON de opciones: " + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -168,8 +172,14 @@ public class PlantillaService {
|
|
|
}
|
|
|
|
|
|
InstanciaTascaDTO ita = tc.findInstanciaTascaById(idtascai);
|
|
|
- if(ita.getTasca().getNomRol().equals("u_uq")) {
|
|
|
- d.body().append(this.parseComments(d.html()));
|
|
|
+
|
|
|
+ List<Integer> idUsuariRol = new ArrayList<>();
|
|
|
+ idUsuariRol.add(ita.getTasca().getIdRol());
|
|
|
+
|
|
|
+ for (String permission : this.usuarisRolRepository.getPermisosRoles(idUsuariRol)) {
|
|
|
+ if(permission.equals("x")) {
|
|
|
+ d.body().append(this.parseComments(d.html()));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
String basecommand = "google-chrome --headless --disable-gpu --no-pdf-header-footer --run-all-compositor-stages-before-draw --no-sandbox";
|
|
|
@@ -229,8 +239,14 @@ public class PlantillaService {
|
|
|
|
|
|
if(idtascai.isPresent()) {
|
|
|
InstanciaTascaDTO ita = tc.findInstanciaTascaById(idtascai.get());
|
|
|
- if(ita.getTasca().getNomRol().equals("u_uq")) {
|
|
|
- d.body().append(this.parseComments(d.html()));
|
|
|
+
|
|
|
+ List<Integer> idUsuariRol = new ArrayList<>();
|
|
|
+ idUsuariRol.add(ita.getTasca().getIdRol());
|
|
|
+
|
|
|
+ for (String permission : this.usuarisRolRepository.getPermisosRoles(idUsuariRol)) {
|
|
|
+ if(permission.equals("x")) {
|
|
|
+ d.body().append(this.parseComments(d.html()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|