diff --git a/ems-core/src/main/java/it/integry/ems/migration/model/Migration_20251212151308.java b/ems-core/src/main/java/it/integry/ems/migration/model/Migration_20251212151308.java new file mode 100644 index 0000000000..c2863224e6 --- /dev/null +++ b/ems-core/src/main/java/it/integry/ems/migration/model/Migration_20251212151308.java @@ -0,0 +1,121 @@ +package it.integry.ems.migration.model; + +import it.integry.ems.migration._base.BaseMigration; +import it.integry.ems.migration._base.IntegryCustomer; +import it.integry.ems.migration._base.MigrationModelInterface; + +public class Migration_20251212151308 extends BaseMigration implements MigrationModelInterface { + + @Override + public void up() throws Exception { + if (isHistoryDB()) + return; + + if ( !isCustomer(IntegryCustomer.Carelli) ) return; + + createOrUpdateFunction("steup_getRilevazioni", "CREATE FUNCTION [dbo].[steup_getRilevazioni]\n" + + "(\n" + + " @dataIspezione DATETIME,\n" + + " @codMdep VARCHAR(5),\n" + + " @userRilevatore VARCHAR(20)\n" + + ")\n" + + "RETURNS TABLE AS return \n" + + "SELECT activity_id,\n" + + " stb_activity.user_name,\n" + + " user_creator,\n" + + " ISNULL(effective_time, ora_ins_act) AS effective_time,\n" + + " effective_endtime,\n" + + " activity_result_id,\n" + + " mtb_depo.cod_mdep,\n" + + " mtb_depo.descrizione AS descr_deposito,\n" + + " ISNULL(effective_date, data_ins_act) AS data_isp\n" + + "FROM winact.dbo.stb_activity INNER JOIN winact.dbo.wtb_depo ON stb_activity.user_name = wtb_depo.user_name\n" + + " INNER JOIN winact.dbo.mtb_depo ON wtb_depo.cod_mdep = mtb_depo.cod_mdep\n" + + "WHERE flag_tipologia = 'P' AND\n" + + " activity_type_id = 'ISPEZIONE' AND \n" + + " (@dataIspezione is null or stb_activity.effective_date = @dataIspezione ) AND \n" + + " (@codMdep is null or mtb_depo.cod_mdep = @codMdep ) AND \n" + + " (@userRilevatore is null or stb_activity.user_creator = @userRilevatore );"); + createOrUpdateFunction("steup_getEntriesRilevazione", "CREATE FUNCTION [dbo].[steup_getEntriesRilevazione](@idIspezione varchar(20))\n" + + " RETURNS TABLE AS return\n" + + "WITH steup_ispezioni AS (SELECT * FROM steup_getRilevazioni(null, null, null)),\n" + + "\n" + + " steup_activities AS (SELECT stb_activity.activity_id,\n" + + " stb_activity.activity_type_id,\n" + + " stb_activity.data_ins_act,\n" + + " ISNULL(stb_activity.effective_time, stb_activity.ora_ins_act) AS effective_time,\n" + + " stb_activity.cod_mart,\n" + + " mtb_aart.descrizione AS descr_art,\n" + + " stb_activity.activity_play_counter,\n" + + " stb_activity.note,\n" + + " stb_activity.cod_jfas,\n" + + " stb_activity.flag_tipologia,\n" + + " stb_activity.persona_rif,\n" + + " stb_activity.priorita,\n" + + " wtb_depo.cod_mdep,\n" + + " jtb_fasi.descrizione AS descr_fase,\n" + + " stb_activity.parent_activity_id as id_ispezione,\n" + + " stb_activity.indice_gradimento,\n" + + " stb_activity.user_creator,\n" + + " jtb_fasi.max_allocazione,\n" + + " SUM(indice_gradimento)\n" + + " OVER ( PARTITION BY parent_activity_id,wtb_depo.cod_mdep,jtb_fasi.cod_jfas ) AS gradimento_reparto,\n" + + " steup_ispezioni.data_isp\n" + + " FROM winact.dbo.stb_activity\n" + + " INNER JOIN steup_ispezioni ON parent_activity_id = steup_ispezioni.activity_id\n" + + " LEFT OUTER JOIN winact.dbo.jtb_fasi ON stb_activity.cod_jfas = jtb_fasi.cod_jfas\n" + + " LEFT OUTER JOIN winact.dbo.mtb_aart ON stb_activity.cod_mart = mtb_aart.cod_mart\n" + + " LEFT OUTER JOIN winact.dbo.wtb_depo ON stb_activity.user_name = wtb_depo.user_name\n" + + " WHERE ISNULL(cod_jcom, '') <> 'MODEL'\n" + + " and stb_activity.cod_mart is null\n" + + " AND stb_activity.flag_tipologia = 'A')\n" + + " ,\n" + + "\n" + + "\n" + + "\n" + + "\n" + + " gradimento_reparto AS (SELECT DISTINCT id_ispezione,\n" + + " cod_jfas,\n" + + " cod_mdep,\n" + + " data_isp,\n" + + " gradimento_reparto,\n" + + " LAG(gradimento_reparto, 1, 0)\n" + + " OVER (PARTITION BY cod_mdep,cod_jfas ORDER BY data_isp ) AS grad_1,\n" + + " LAG(gradimento_reparto, 2, 0)\n" + + " OVER (PARTITION BY cod_mdep,cod_jfas ORDER BY data_isp ) AS grad_2\n" + + "\n" + + " FROM (SELECT DISTINCT id_ispezione, cod_mdep, cod_jfas, gradimento_reparto, data_isp\n" + + " FROM steup_activities) acti)\n" + + "\n" + + "\n" + + "SELECT steup_activities.*,\n" + + " CASE\n" + + " WHEN gradimento_reparto.grad_1 > max_allocazione AND gradimento_reparto.grad_2 > max_allocazione THEN 1\n" + + " ELSE 0 END AS recidiva,\n" + + " ((SELECT COUNT(*)\n" + + " FROM stb_activity art\n" + + " WHERE steup_activities.activity_id = art.parent_activity_id) + (SELECT COUNT(*)\n" + + " FROM mtb_colt\n" + + " INNER JOIN mtb_colr\n" + + " ON mtb_colt.gestione =\n" + + " mtb_colr.gestione AND\n" + + " mtb_colt.data_collo =\n" + + " mtb_colr.data_collo AND\n" + + " mtb_colt.ser_collo =\n" + + " mtb_colr.ser_collo AND\n" + + " mtb_colt.num_collo =\n" + + " mtb_colr.num_collo\n" + + " WHERE mtb_colt.activity_id = steup_activities.activity_id)) AS count_art\n" + + "FROM steup_activities\n" + + " left outer JOIN gradimento_reparto ON steup_activities.id_ispezione = gradimento_reparto.id_ispezione\n" + + " AND steup_activities.cod_mdep = gradimento_reparto.cod_mdep\n" + + " AND steup_activities.cod_jfas = gradimento_reparto.cod_jfas\n" + + "WHERE (@idIspezione is null or steup_activities.id_ispezione = @idIspezione)"); + } + + @Override + public void down() throws Exception { + + } + +} diff --git a/ems-core/src/main/java/it/integry/ems_model/config/EmsRestConstants.java b/ems-core/src/main/java/it/integry/ems_model/config/EmsRestConstants.java index aadc8286af..9411e38b6c 100644 --- a/ems-core/src/main/java/it/integry/ems_model/config/EmsRestConstants.java +++ b/ems-core/src/main/java/it/integry/ems_model/config/EmsRestConstants.java @@ -116,6 +116,7 @@ public class EmsRestConstants { public static final String PATH_USERS = PATH + "getUser"; public static final String PATH_EXPORT_ORDINI_ACQ = PATH + "exportOrdiniAcquisto"; public static final String PATH_PROCESS_REPORT = PATH + "processReport"; + public static final String PATH_DOWNLOAD_REPORT_LIST = PATH + "downloadReportList"; public static final String PATH_DOWNLOAD_REPORT = PATH + "downloadReport"; public static final String PATH_PROCESS_REPORT_TYPE = PATH + "processReportType"; public static final String PATH_PRINT_REPORT_TYPE = PATH + "printReportType"; diff --git a/ems-engine/src/main/java/it/integry/core/controller/EmsEngineController.java b/ems-engine/src/main/java/it/integry/core/controller/EmsEngineController.java index 42c095b490..7c899a4aa8 100644 --- a/ems-engine/src/main/java/it/integry/core/controller/EmsEngineController.java +++ b/ems-engine/src/main/java/it/integry/core/controller/EmsEngineController.java @@ -14,6 +14,7 @@ import it.integry.ems.response.ServiceRestResponse; import it.integry.ems.service.PrinterService; import it.integry.ems.service.ReportProcessor; import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager; +import it.integry.ems.utility.UtilityPdf; import it.integry.ems_model.config.EmsRestConstants; import it.integry.ems_model.entity.GrlAnagJrept; import it.integry.ems_model.entity.JtbDisegniFiles; @@ -88,6 +89,7 @@ public class EmsEngineController { return response; } + @RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_REPORT, method = RequestMethod.POST) public @ResponseBody ServiceRestResponse downloadReport(HttpServletRequest request, @@ -100,6 +102,27 @@ public class EmsEngineController { return ServiceRestResponse.createNegativeResponse("Nessun report generato!"); } + @RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_REPORT_LIST, method = RequestMethod.POST) + public @ResponseBody + ServiceRestResponse downloadReportList(HttpServletRequest request, + @RequestParam(CommonConstants.PROFILE_DB) String configuration, + @RequestBody JasperDTO[] jasperDTOList)throws Exception { + + FileItem fi = new FileItem(); + List pdfList = new ArrayList<>(); + for (JasperDTO jasperDTO : jasperDTOList) { + pdfList.add(emsEngineService.processReport(jasperDTO)); + } + byte[] bytes = UtilityPdf.merge(pdfList); + + if (bytes != null && bytes.length > 0) { + return ServiceRestResponse.createPositiveResponse(downloadFileHandlerService.generateDownloadItem(new Date().getTime() + ".pdf", bytes)); + } else { + return ServiceRestResponse.createNegativeResponse("Nessun report generato!"); + } + + } + @RequestMapping(value = EmsRestConstants.PATH_PROCESS_REPORT_TYPE, method = RequestMethod.POST) public @ResponseBody ServiceRestResponse processReportTypeList(HttpServletRequest request, @@ -122,14 +145,9 @@ public class EmsEngineController { public @ResponseBody ServiceRestResponse printReportTypeList(HttpServletRequest request, @RequestParam(CommonConstants.PROFILE_DB) String configuration, - @RequestBody ReportTypeDTO reportTypeDTO) { - try { - printerService.printReportType(reportTypeDTO); - return ServiceRestResponse.createPositiveResponse(); - } catch (Exception e) { - logger.error(request.getRequestURI(), e); - return ServiceRestResponse.createNegativeResponse(configuration, e); - } + @RequestBody ReportTypeDTO reportTypeDTO) throws Exception { + printerService.printReportType(reportTypeDTO); + return ServiceRestResponse.createPositiveResponse(); } @RequestMapping(value = EmsRestConstants.PATH_GET_SETUP_REPORT_TYPE, method = RequestMethod.POST) diff --git a/ems-engine/src/main/java/it/integry/ems/activity/service/SteUPService.java b/ems-engine/src/main/java/it/integry/ems/activity/service/SteUPService.java index d2bfb5288c..ced8d02196 100644 --- a/ems-engine/src/main/java/it/integry/ems/activity/service/SteUPService.java +++ b/ems-engine/src/main/java/it/integry/ems/activity/service/SteUPService.java @@ -1425,7 +1425,7 @@ public class SteUPService { " activity_result_id,\n" + " cod_mdep,\n" + " descr_deposito\n" + - "FROM dbo.steup_getRilevazioni()\n" + + "FROM dbo.steup_getRilevazioni(null, null, null)\n" + "WHERE CAST(effective_time AS DATE) BETWEEN %s AND %s", dataInizio, dataFine diff --git a/ems-engine/src/main/java/it/integry/ems/retail/wms/generic/controller/WMSGenericController.java b/ems-engine/src/main/java/it/integry/ems/retail/wms/generic/controller/WMSGenericController.java index d1b9574004..31c2d547c2 100644 --- a/ems-engine/src/main/java/it/integry/ems/retail/wms/generic/controller/WMSGenericController.java +++ b/ems-engine/src/main/java/it/integry/ems/retail/wms/generic/controller/WMSGenericController.java @@ -557,8 +557,11 @@ public class WMSGenericController { ServiceRestResponse spostaULInPosizione(@RequestParam(CommonConstants.PROFILE_DB) String configuration, @RequestBody SpostaUlRequestDTO requestDTO) throws Exception { try { - wmsGenericService.spostaUL(requestDTO); - return ServiceRestResponse.createPositiveResponse(); + MtbColt mtbColt = wmsGenericService.spostaUL(requestDTO); + if (mtbColt != null) { + mtbColt.setOnlyPkMaster(false); + } + return ServiceRestResponse.createPositiveResponse(mtbColt); } catch (Exception e) { multiDBTransactionManager.rollbackAll(); throw e; diff --git a/ems-engine/src/main/java/it/integry/ems/retail/wms/generic/service/WMSGenericService.java b/ems-engine/src/main/java/it/integry/ems/retail/wms/generic/service/WMSGenericService.java index f1d8dde7a5..8445597b48 100644 --- a/ems-engine/src/main/java/it/integry/ems/retail/wms/generic/service/WMSGenericService.java +++ b/ems-engine/src/main/java/it/integry/ems/retail/wms/generic/service/WMSGenericService.java @@ -2027,7 +2027,7 @@ public class WMSGenericService { UtilityEntity.throwEntitiesException(entitiesToSave); } - public void spostaUL(SpostaUlRequestDTO requestDTO) throws Exception { + public MtbColt spostaUL(SpostaUlRequestDTO requestDTO) throws Exception { if (UtilityString.isNullOrEmpty(requestDTO.getCodMdep())) throw new Exception("Nessun deposito di arrivo selezionato"); @@ -2194,6 +2194,8 @@ public class WMSGenericService { entityProcessor.processEntityList(entitiesToSave, true); UtilityEntity.throwEntitiesException(entitiesToSave); + + return mtbCotlList.stream().findFirst().orElse(null); } public void spostaULInPosizione(MtbColt mtbColtToMove, MtbDepoPosizioni mtbDepoPosizioni) throws Exception {