Finish Hotfix-89
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20241108172515 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("suggestMtbArtEqui",
|
||||
"CREATE FUNCTION dbo.suggestMtbArtEqui\n" +
|
||||
"( \n" +
|
||||
" @jsonParm varchar(max)\n" +
|
||||
")\n" +
|
||||
"RETURNS TABLE \n" +
|
||||
"AS\n" +
|
||||
"RETURN \n" +
|
||||
"(\n" +
|
||||
" -- Add the SELECT statement with parameter references here\n" +
|
||||
" SELECT CONVERT(varchar(25), null ) as id_art_equi, CONVERT(varchar(255), null ) as descrizione \n" +
|
||||
")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
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_20241108172544 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomer(IntegryCustomer.RossoGargano)) return;
|
||||
|
||||
createOrUpdateFunction("suggestMtbArtEqui",
|
||||
"CREATE FUNCTION dbo.suggestMtbArtEqui\n" +
|
||||
"( \n" +
|
||||
" @jsonParm varchar(max)\n" +
|
||||
")\n" +
|
||||
"RETURNS TABLE \n" +
|
||||
"AS\n" +
|
||||
"RETURN \n" +
|
||||
"(\n" +
|
||||
" with tab_json as (\n" +
|
||||
"select *\n" +
|
||||
"from openJson(@jsonParm) \n" +
|
||||
"WITH (\n" +
|
||||
" cod_mgrp VARCHAR(5) '$.cod_mgrp',\n" +
|
||||
" cod_msgr VARCHAR(5) '$.cod_msgr',\n" +
|
||||
" cod_mtip VARCHAR(5) '$.cod_mtip',\n" +
|
||||
" cod_mstp VARCHAR(5) '$.cod_mstp',\n" +
|
||||
" cod_tcol_UI VARCHAR(100) '$.cod_tcol_UI',\n" +
|
||||
" marchio VARCHAR(255) '$.marchio',\n" +
|
||||
" qta_cnf FLOAT '$.qta_cnf',\n" +
|
||||
" peso_kg FLOAT '$.peso_kg'\n" +
|
||||
") )\n" +
|
||||
",art as (\n" +
|
||||
"SELECT distinct mtb_aart_equi.id_art_equi, IsNull(mtb_aart_equi.descrizione,\n" +
|
||||
" CONCAT_WS(' ', mtb_tipi.descrizione, mtb_aart.cod_tcol_UI, CAST(mtb_aart.qta_cnf AS FLOAT), 'x',\n" +
|
||||
" CAST(mtb_aart.peso_kg AS FLOAT), mtb_stip.descrizione, mtb_aart.marchio) ) as descizione\n" +
|
||||
"FROM mtb_aart \n" +
|
||||
"left outer join mtb_aart_equi on mtb_aart.id_art_equi = mtb_aart_equi.id_art_equi\n" +
|
||||
"left outer join mtb_tipi on mtb_aart.cod_mtip = mtb_tipi.cod_mtip\n" +
|
||||
"left outer join mtb_stip on mtb_aart.cod_mtip = mtb_stip.cod_mtip and mtb_aart.cod_mstp = mtb_stip.cod_mstp \n" +
|
||||
"where exists (select *\n" +
|
||||
"from tab_json where mtb_aart.cod_mgrp = tab_json.cod_mgrp and\n" +
|
||||
"mtb_aart.cod_msgr = tab_json.cod_msgr and \n" +
|
||||
"mtb_aart.qta_cnf = tab_json.qta_cnf and\n" +
|
||||
"mtb_aart.peso_kg = tab_json.peso_kg and\n" +
|
||||
"(IsNull(mtb_aart.marchio,'') = isNull(tab_json.marchio,'')) and\n" +
|
||||
"(IsNull(mtb_aart.cod_mtip,'') = isNull(tab_json.cod_mtip,'')) and\n" +
|
||||
"(IsNull(mtb_aart.cod_mstp, '') = isNull(tab_json.cod_mstp,'')) \n" +
|
||||
"))\n" +
|
||||
"\n" +
|
||||
"select *\n" +
|
||||
"from art \n" +
|
||||
"union all\n" +
|
||||
"select null as id_art_eqi, upper( CONCAT_WS(' ', mtb_tipi.descrizione, cod_tcol_UI, CAST(qta_cnf AS FLOAT), 'x',\n" +
|
||||
" CAST(peso_kg AS FLOAT), mtb_stip.descrizione, marchio))\n" +
|
||||
"from tab_json left outer join mtb_tipi on tab_json.cod_mtip = mtb_tipi.cod_mtip\n" +
|
||||
"left outer join mtb_stip on tab_json.cod_mtip = mtb_stip.cod_mtip and tab_json.cod_mstp = mtb_stip.cod_mstp \n" +
|
||||
"where exists(select * from tab_json)\n" +
|
||||
")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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_20241108181101 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
createSetup("MTB_AART", "ID_ART_EQUI", "INSERT_AUTO", "N",
|
||||
"inserisce automaticamente l'id equivalente", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
|
||||
if (!isCustomer(IntegryCustomer.RossoGargano)) return;
|
||||
updateSetupValue("MTB_AART", "ID_ART_EQUI", "INSERT_AUTO", "S");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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_20241111094439 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("W_PORDI_RC", "DISTRIBUZIONE_MATERIALI", "EMAL_NOTIFICATION", null,
|
||||
"Inserire la mail a cui inviare gli errori", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,22 +108,8 @@ public class ProductionController {
|
||||
|
||||
@RequestMapping(value = "/distribuzioneMateriali", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse distribuzioneMateriali(@RequestParam String codAnag,
|
||||
@RequestParam String codDtip,
|
||||
@RequestParam Date dataDoc,
|
||||
@RequestParam String serDoc,
|
||||
@RequestParam Integer numDoc) throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT * \n" +
|
||||
"FROM dtb_doct WHERE dtb_doct.cod_anag = %s\n" +
|
||||
" AND dtb_doct.cod_dtip = %s\n" +
|
||||
" AND dtb_doct.data_doc = %s\n" +
|
||||
" AND dtb_doct.ser_doc = %s\n" +
|
||||
" AND dtb_doct.num_doc = %s",
|
||||
codAnag, codDtip, dataDoc, serDoc, numDoc
|
||||
);
|
||||
DtbDoct dtbDoct = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbDoct.class);
|
||||
ServiceRestResponse distribuzioneMateriali() throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(productionService.distribuzioneMateriali(dtbDoct));
|
||||
return ServiceRestResponse.createPositiveResponse(productionService.distribuzioneMateriali());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package it.integry.ems.production.service;
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.document.dto.ChiusuraLavorazioneDTO;
|
||||
import it.integry.ems.document.service.DocumentProdService;
|
||||
import it.integry.ems.exception.MissingDataException;
|
||||
@@ -11,6 +12,7 @@ import it.integry.ems.production.dto.*;
|
||||
import it.integry.ems.rules.businessLogic.LoadColliService;
|
||||
import it.integry.ems.rules.businessLogic.dto.LoadColliDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.MailService;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
@@ -31,6 +33,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
@@ -51,6 +54,9 @@ public class ProductionService {
|
||||
@Autowired
|
||||
private LoadColliService loadColliService;
|
||||
|
||||
@Autowired
|
||||
private MailService mailService;
|
||||
|
||||
public void chiudiGiornata(ChiudiGiornataDTO datiChiusura) throws Exception {
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
HashMap<String, String> setupCruscotto = setupGest.getSetupSection(conn, "CRUSCOTTO_PRODUZIONE", "SETUP");
|
||||
@@ -1139,7 +1145,53 @@ public class ProductionService {
|
||||
return entities;
|
||||
}
|
||||
|
||||
public List<EntityBase> distribuzioneMateriali(DtbDoct dtbDoct) throws Exception {
|
||||
public List<EntityBase> distribuzioneMateriali() throws Exception {
|
||||
String sql =
|
||||
"SELECT *\n" +
|
||||
"FROM dtb_doct\n" +
|
||||
"WHERE cod_dtip IN (SELECT value\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'W_PORDI_RC'\n" +
|
||||
" AND section = 'SETUP_DOCUMENTI'\n" +
|
||||
" AND key_section = 'COD_DTIP_SCAR')\n" +
|
||||
" AND data_doc BETWEEN DATEADD(MONTH, -1, CAST(GETDATE() AS DATE)) AND CAST(GETDATE() AS DATE)";
|
||||
|
||||
List<DtbDoct> dtbDocts = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbDoct.class);
|
||||
|
||||
List<EntityBase> entities = new ArrayList<>();
|
||||
List<AnomalieDTO> anomalieDTOS = new ArrayList<>();
|
||||
for (DtbDoct dtbDoct: dtbDocts) {
|
||||
distribuzioneMateriali(dtbDoct);
|
||||
|
||||
entities.add(distribuzioneMateriali(dtbDoct));
|
||||
if (dtbDoct.getException() != null ) {
|
||||
anomalieDTOS.add(
|
||||
AnomalieDTO.error(
|
||||
String.format(
|
||||
"Errore nell'aggiornamento del documento %s del %s n. %s/%s: %s",
|
||||
dtbDoct.getCodDtip(),
|
||||
new SimpleDateFormat(CommonConstants.DATE_FORMAT_YMD).format(dtbDoct.getDataDoc()),
|
||||
dtbDoct.getSerDoc(),
|
||||
dtbDoct.getNumDoc(),
|
||||
dtbDoct.getException().getMessage()
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
if (anomalieDTOS.size() > 0) {
|
||||
String emailForLog = setupGest.getSetup("W_PORDI_RC", "DISTRIBUZIONE_MATERIALI", "EMAL_NOTIFICATION");
|
||||
if (!UtilityString.isNullOrEmpty(emailForLog))
|
||||
mailService.sendErrorMail(multiDBTransactionManager, emailForLog, "Errore durante la procedure di distribuzione materiali",
|
||||
"Errore durante la procedure di distribuzione materiali",
|
||||
entities.stream().filter(x->x.getException() != null).collect(Collectors.toList()),
|
||||
null, anomalieDTOS, null);
|
||||
}
|
||||
|
||||
return entities;
|
||||
|
||||
}
|
||||
|
||||
public DtbDoct distribuzioneMateriali(DtbDoct dtbDoct) throws Exception {
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
String sql = Query.format(
|
||||
"SELECT * FROM dtb_docr WHERE cod_dtip = %s AND num_doc = %s AND data_doc = %s AND cod_anag = %s AND ser_doc = %s",
|
||||
@@ -1307,8 +1359,8 @@ public class ProductionService {
|
||||
}
|
||||
|
||||
dtbDoct.setOperation(OperationType.UPDATE);
|
||||
|
||||
return entityProcessor.processEntity(dtbDoct, multiDBTransactionManager);
|
||||
entityProcessor.processEntity(dtbDoct, multiDBTransactionManager);
|
||||
return dtbDoct;
|
||||
}
|
||||
|
||||
public static BigDecimal sumQtaOrd(List<RigheLottLavDTO> righeLottLavDTOList) {
|
||||
|
||||
Reference in New Issue
Block a user