|
@@ -7,6 +7,7 @@ import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.math.BigInteger;
|
|
import java.math.BigInteger;
|
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Files;
|
|
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.nio.file.StandardCopyOption;
|
|
import java.nio.file.StandardCopyOption;
|
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
@@ -14,12 +15,14 @@ import java.time.LocalDateTime;
|
|
|
import java.time.Year;
|
|
import java.time.Year;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.Base64;
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
+import java.util.stream.StreamSupport;
|
|
|
import java.util.zip.ZipEntry;
|
|
import java.util.zip.ZipEntry;
|
|
|
import java.util.zip.ZipOutputStream;
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
|
@@ -31,10 +34,16 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestPart;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
+import com.fasterxml.jackson.databind.JsonMappingException;
|
|
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
+
|
|
|
import es.uv.saic.shared.domain.DummyDataTransfer;
|
|
import es.uv.saic.shared.domain.DummyDataTransfer;
|
|
|
import es.uv.saic.shared.domain.Instancia;
|
|
import es.uv.saic.shared.domain.Instancia;
|
|
|
import es.uv.saic.shared.domain.InstanciaTasca;
|
|
import es.uv.saic.shared.domain.InstanciaTasca;
|
|
@@ -42,6 +51,9 @@ import es.uv.saic.shared.domain.InstanciaTascaTransfer;
|
|
|
import es.uv.saic.shared.domain.InstanciaTascaVer;
|
|
import es.uv.saic.shared.domain.InstanciaTascaVer;
|
|
|
import es.uv.saic.shared.domain.InstanciaTransfer;
|
|
import es.uv.saic.shared.domain.InstanciaTransfer;
|
|
|
import es.uv.saic.shared.domain.Organ;
|
|
import es.uv.saic.shared.domain.Organ;
|
|
|
|
|
+import es.uv.saic.shared.domain.PamDocuments;
|
|
|
|
|
+import es.uv.saic.shared.domain.PamDocumentsPK;
|
|
|
|
|
+import es.uv.saic.shared.domain.PamMetadades;
|
|
|
import es.uv.saic.shared.domain.Plantilla;
|
|
import es.uv.saic.shared.domain.Plantilla;
|
|
|
import es.uv.saic.shared.domain.Proces;
|
|
import es.uv.saic.shared.domain.Proces;
|
|
|
import es.uv.saic.shared.domain.Rol;
|
|
import es.uv.saic.shared.domain.Rol;
|
|
@@ -60,6 +72,8 @@ import es.uv.saic.service.InstanciaService;
|
|
|
import es.uv.saic.service.InstanciaTascaService;
|
|
import es.uv.saic.service.InstanciaTascaService;
|
|
|
import es.uv.saic.service.InstanciaTascaVerService;
|
|
import es.uv.saic.service.InstanciaTascaVerService;
|
|
|
import es.uv.saic.service.OrganService;
|
|
import es.uv.saic.service.OrganService;
|
|
|
|
|
+import es.uv.saic.service.PamDocumentsService;
|
|
|
|
|
+import es.uv.saic.service.PamMetadadesService;
|
|
|
import es.uv.saic.service.ProcesService;
|
|
import es.uv.saic.service.ProcesService;
|
|
|
import es.uv.saic.service.RolService;
|
|
import es.uv.saic.service.RolService;
|
|
|
import es.uv.saic.service.TascaService;
|
|
import es.uv.saic.service.TascaService;
|
|
@@ -92,12 +106,18 @@ public class ProceduresController {
|
|
|
private TascaService tas;
|
|
private TascaService tas;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PlantillaClient plc;
|
|
private PlantillaClient plc;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PamMetadadesService pms;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PamDocumentsService pds;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private DataClient dc;
|
|
private DataClient dc;
|
|
|
|
|
|
|
|
@Value("${saic.data.filePath}")
|
|
@Value("${saic.data.filePath}")
|
|
|
private String filePath;
|
|
private String filePath;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ObjectMapper objectMapper;
|
|
|
|
|
|
|
|
ProceduresController(ProcesService procesService) {
|
|
ProceduresController(ProcesService procesService) {
|
|
|
this.procesService = procesService;
|
|
this.procesService = procesService;
|
|
@@ -284,7 +304,7 @@ public class ProceduresController {
|
|
|
*/
|
|
*/
|
|
|
@PostMapping("/procedure/{id}")
|
|
@PostMapping("/procedure/{id}")
|
|
|
public HashMap<String, Object> updateInstanciaTasca(@PathVariable BigInteger id, @RequestBody Map<String,String> params,
|
|
public HashMap<String, Object> updateInstanciaTasca(@PathVariable BigInteger id, @RequestBody Map<String,String> params,
|
|
|
- @RequestParam(required = false) List<MultipartFile> evidencias, @RequestParam String usuari) throws IllegalStateException, IOException, InterruptedException {
|
|
|
|
|
|
|
+ @RequestPart(required = false) List<MultipartFile> evidencias, @RequestParam String usuari) throws IllegalStateException, IOException, InterruptedException {
|
|
|
HashMap<String, Object> model = new HashMap<>();
|
|
HashMap<String, Object> model = new HashMap<>();
|
|
|
Usuari u = us.findByUsername(usuari);
|
|
Usuari u = us.findByUsername(usuari);
|
|
|
|
|
|
|
@@ -307,6 +327,56 @@ public class ProceduresController {
|
|
|
it.setEvidencia(this.plc.savePDF(pdf));
|
|
it.setEvidencia(this.plc.savePDF(pdf));
|
|
|
it.setEstat("E");
|
|
it.setEstat("E");
|
|
|
}
|
|
}
|
|
|
|
|
+ else if(it.getTasca().getTipus().getTipus() == 3) {
|
|
|
|
|
+ String pamJson = params.get("pam_data");
|
|
|
|
|
+ it.setText(pamJson);
|
|
|
|
|
+ it.setEstat("E");
|
|
|
|
|
+
|
|
|
|
|
+ String tableHtml = this.generatePAMHtmlTable(pamJson);
|
|
|
|
|
+ PdfDTO pdf = new PdfDTO(tableHtml, it.getIdInstanciaTasca());
|
|
|
|
|
+ it.setEvidencia(this.plc.savePDF(pdf));
|
|
|
|
|
+
|
|
|
|
|
+ PamMetadades pam = pms.findByInstanciaTasca(it).orElse(new PamMetadades());
|
|
|
|
|
+ pam.setCursActivacio(it.getInstancia().getProces().getCursActivacio());
|
|
|
|
|
+ pam.setCursAvaluat(it.getInstancia().getProces().getCursAvaluat());
|
|
|
|
|
+ pam.setNomProces(it.getInstancia().getProces().getNomProces());
|
|
|
|
|
+ pam.setData(it.getDataFet());
|
|
|
|
|
+ pam.setUsuari(usuari);
|
|
|
|
|
+ pam.setTambit(it.getInstancia().getOrgan().getTambit());
|
|
|
|
|
+ pam.setAmbit(it.getInstancia().getProces().getAmbit());
|
|
|
|
|
+ pam.setLugar(it.getInstancia().getOrgan().getId().getLugar());
|
|
|
|
|
+ pam.setTlugar(it.getInstancia().getOrgan().getId().getTlugar());
|
|
|
|
|
+ pam.setInstanciaTasca(it);
|
|
|
|
|
+ pms.save(pam);
|
|
|
|
|
+
|
|
|
|
|
+ JsonNode docsJson = objectMapper.readTree(params.get("pam_docs"));
|
|
|
|
|
+
|
|
|
|
|
+ if (docsJson != null && !docsJson.isEmpty()) {
|
|
|
|
|
+ for (JsonNode node : docsJson) {
|
|
|
|
|
+ String rowId = node.get("rowId").asText();
|
|
|
|
|
+ String nombre = node.get("nombre").asText();
|
|
|
|
|
+ String b64 = node.get("base64").asText();
|
|
|
|
|
+
|
|
|
|
|
+ byte[] bytes = Base64.getDecoder().decode(b64);
|
|
|
|
|
+ String ruta = "C:\\Users\\Pablo\\Desktop\\Trabajo\\SAIC\\docs"+ it.getIdInstanciaTasca() + "_" + nombre;
|
|
|
|
|
+ Files.write(Paths.get(ruta),bytes);
|
|
|
|
|
+
|
|
|
|
|
+ PamDocuments pamDocuments = new PamDocuments();
|
|
|
|
|
+ PamDocumentsPK pk = new PamDocumentsPK();
|
|
|
|
|
+ pk.setIdAccio(rowId);
|
|
|
|
|
+ pk.setIdPam(pam.getIdPam());
|
|
|
|
|
+ pk.setTimestamp(new Timestamp(System.currentTimeMillis()));
|
|
|
|
|
+
|
|
|
|
|
+ pamDocuments.setId(pk);
|
|
|
|
|
+ pamDocuments.setNom(nombre);
|
|
|
|
|
+ pamDocuments.setRuta(ruta);
|
|
|
|
|
+ pamDocuments.setData(it.getDataFet());
|
|
|
|
|
+ pamDocuments.setUsuari(usuari);
|
|
|
|
|
+
|
|
|
|
|
+ pds.save(pamDocuments);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
this.saveChanges(u, it);
|
|
this.saveChanges(u, it);
|
|
|
this.loadProcedure(model, u, id);
|
|
this.loadProcedure(model, u, id);
|
|
@@ -324,8 +394,72 @@ public class ProceduresController {
|
|
|
public void saveChanges(Usuari u, InstanciaTasca it) {
|
|
public void saveChanges(Usuari u, InstanciaTasca it) {
|
|
|
this.its.saveChanges(u, it);
|
|
this.its.saveChanges(u, it);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public String generatePAMHtmlTable(String json) throws JsonMappingException, JsonProcessingException {
|
|
|
|
|
+ JsonNode rows = objectMapper.readTree(json);
|
|
|
|
|
+ StringBuilder html = new StringBuilder();
|
|
|
|
|
+
|
|
|
|
|
+ html.append("<!DOCTYPE html><html><head><meta charset='UTF-8'><style>")
|
|
|
|
|
+ .append("body { font-family: 'Verdana', Geneva, sans-serif; margin: 0; padding: 10px; }")
|
|
|
|
|
+ .append("table { width: 297mm; border-collapse: collapse; table-layout: fixed; border: 1px solid #000; background-color: #edeee5; }")
|
|
|
|
|
+ .append("th, td { border: 1px solid #000; padding: 8px; font-size: 8pt; vertical-align: top; word-wrap: break-word; }")
|
|
|
|
|
+ .append(".header-group { background-color: #355d7e; color: #ffffff; text-align: center; font-weight: bold; font-size: 10pt; }")
|
|
|
|
|
+ .append(".subheader { background-color: #e9f0f6; color: #000000; text-align: center; font-weight: bold; }")
|
|
|
|
|
+ .append(".data-row { background-color: #ffffff; }")
|
|
|
|
|
+ .append("h2 { text-align: center; font-size: 14pt; color: #355d7e; }")
|
|
|
|
|
+ .append("</style></head><body>")
|
|
|
|
|
+ .append("<h2>PLAN DE ACCIÓN DE MEJORA (PAM)</h2>")
|
|
|
|
|
+ .append("<table>")
|
|
|
|
|
+ .append("<thead>")
|
|
|
|
|
+ .append("<tr>")
|
|
|
|
|
+ .append("<th colspan='3' class='header-group'>ORIGEN DE LA ACCIÓN</th>")
|
|
|
|
|
+ .append("<th colspan='4' class='header-group'>ACCIÓN PLANIFICADA</th>")
|
|
|
|
|
+ .append("<th colspan='4' class='header-group'>SEGUIMIENTO</th>")
|
|
|
|
|
+ .append("</tr>")
|
|
|
|
|
+ .append("<tr class='subheader'>")
|
|
|
|
|
+ .append("<td style='width: 40px;'>ID</td>")
|
|
|
|
|
+ .append("<td style='width: 140px;'>Objetivo de mejora</td>")
|
|
|
|
|
+ .append("<td style='width: 100px;'>Origen</td>")
|
|
|
|
|
+ .append("<td style='width: 160px;'>Actividades a desarrollar</td>")
|
|
|
|
|
+ .append("<td style='width: 110px;'>Responsable</td>")
|
|
|
|
|
+ .append("<td style='width: 70px;'>Prioridad</td>")
|
|
|
|
|
+ .append("<td style='width: 80px;'>Curso Inicio/Fin</td>")
|
|
|
|
|
+ .append("<td style='width: 120px;'>Indicadores de seguimiento</td>")
|
|
|
|
|
+ .append("<td style='width: 90px;'>Grado ejecución</td>")
|
|
|
|
|
+ .append("<td style='width: 80px;'>Objetivo (SÍ/NO)</td>")
|
|
|
|
|
+ .append("<td style='width: 130px;'>JUSTIFICACIÓN</td>")
|
|
|
|
|
+ .append("</tr></thead><tbody>");
|
|
|
|
|
+
|
|
|
|
|
+ for (JsonNode row : rows) {
|
|
|
|
|
+ html.append("<tr class='data-row'>");
|
|
|
|
|
+ html.append("<td><b>").append(row.path("id").asText("")).append("</b></td>");
|
|
|
|
|
+ html.append("<td>").append(row.path("objetivo").asText("")).append("</td>");
|
|
|
|
|
+ html.append("<td>").append(formatList(row.path("origen"))).append("</td>");
|
|
|
|
|
+ html.append("<td>").append(row.path("actividades").asText("")).append("</td>");
|
|
|
|
|
+ html.append("<td>").append(formatList(row.path("responsable"))).append("</td>");
|
|
|
|
|
+ html.append("<td align='center'>").append(row.path("prioridad").asText("")).append("</td>");
|
|
|
|
|
+ html.append("<td align='center'>")
|
|
|
|
|
+ .append(row.path("cursoInicio").asText("")).append(" / ")
|
|
|
|
|
+ .append(row.path("cursoFin").asText(""))
|
|
|
|
|
+ .append("</td>");
|
|
|
|
|
+ html.append("<td>").append(row.path("indicadores").asText("")).append("</td>");
|
|
|
|
|
+ html.append("<td>").append(row.path("gradoEjecucion").asText("")).append("</td>");
|
|
|
|
|
+ String consecucion = row.path("consecucion").asText(" - ");
|
|
|
|
|
+ html.append("<td align='center'>").append(consecucion).append("</td>");
|
|
|
|
|
+ html.append("<td>").append(row.path("justificacion").asText("")).append("</td>");
|
|
|
|
|
+ html.append("</tr>");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ html.append("</tbody></table></body></html>");
|
|
|
|
|
+ return html.toString();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ private String formatList(JsonNode node) {
|
|
|
|
|
+ if (node.isMissingNode() || node.isNull()) return "";
|
|
|
|
|
+ return String.join(", ", StreamSupport.stream(node.spliterator(), false)
|
|
|
|
|
+ .map(JsonNode::asText)
|
|
|
|
|
+ .toArray(String[]::new));
|
|
|
|
|
+ }
|
|
|
/*
|
|
/*
|
|
|
* Saves a draft of a task instance (for specific task types)
|
|
* Saves a draft of a task instance (for specific task types)
|
|
|
*
|
|
*
|
|
@@ -688,4 +822,17 @@ public class ProceduresController {
|
|
|
return model;
|
|
return model;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @GetMapping("/procedure/pam/import")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String getPamByNomProcesAndCurs(@RequestParam String proces, @RequestParam Integer curso){
|
|
|
|
|
+
|
|
|
|
|
+ PamMetadades pam = pms.findByNomProcesAndCursActivacio(proces, curso);
|
|
|
|
|
+
|
|
|
|
|
+ if (pam == null) return "[]";
|
|
|
|
|
+
|
|
|
|
|
+ String jsonText = pam.getInstanciaTasca().getText();
|
|
|
|
|
+
|
|
|
|
|
+ return (jsonText != null && !jsonText.isEmpty()) ? jsonText : "[]";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|