Merge remote-tracking branch 'origin/develop' into develop
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:
@@ -2,13 +2,7 @@ package it.integry.ems.devices;
|
||||
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.devices.dto.RegisterDeviceRequestDTO;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -17,42 +11,14 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequestMapping("device")
|
||||
public class DevicesController {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
@Autowired
|
||||
private DevicesService devicesService;
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "register", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse register(@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody RegisterDeviceRequestDTO registerDeviceRequestDTO) throws Exception {
|
||||
public @ResponseBody ServiceRestResponse register(@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody Object registerDeviceRequestDTO) throws Exception {
|
||||
|
||||
DevicesService.App application = null;
|
||||
switch (registerDeviceRequestDTO.getApp().toLowerCase()) {
|
||||
case "wms":
|
||||
application = DevicesService.App.WMS;
|
||||
break;
|
||||
case "wingest":
|
||||
application = DevicesService.App.Wingest;
|
||||
break;
|
||||
case "textiles":
|
||||
application = DevicesService.App.Textiles;
|
||||
break;
|
||||
case "agribook":
|
||||
application = DevicesService.App.Agribook;
|
||||
break;
|
||||
}
|
||||
|
||||
if(application == null)
|
||||
throw new Exception("Impossibile riconoscere l'applicativo");
|
||||
|
||||
devicesService.register(application, requestDataDTO.getDeviceId());
|
||||
//TODO: To be removed
|
||||
//Mantenuto solo per lasciare compatibilità con le vecchie versioni del WMS
|
||||
//Non serve più per >= v1.45.00
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,46 +1,38 @@
|
||||
package it.integry.ems.devices;
|
||||
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.security.service.DeviceService;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Component
|
||||
@Scope("request")
|
||||
public class DevicesRequestInterceptor extends HandlerInterceptorAdapter {
|
||||
public class DevicesRequestInterceptor implements HandlerInterceptor {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private SettingsModel settingsModel;
|
||||
|
||||
@Autowired
|
||||
private DevicesService devicesService;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response, Object handler) {
|
||||
|
||||
try {
|
||||
DeviceService deviceService = ContextLoader.getCurrentWebApplicationContext().getBean(DeviceService.class);
|
||||
RequestDataDTO requestDataDTO = ContextLoader.getCurrentWebApplicationContext().getBean(RequestDataDTO.class);
|
||||
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
|
||||
|
||||
if (requestDataDTO.isValidProfileDB() && requestDataDTO.isValidDeviceId()) {
|
||||
devicesService.updateUsage(multiDBTransactionManager.getPrimaryConnection(), requestDataDTO.getDeviceId());
|
||||
deviceService.updateUsage(requestDataDTO.getApplication(), requestDataDTO.getDeviceId());
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error(ex.getMessage(), ex);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
package it.integry.ems.devices;
|
||||
|
||||
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.UserSession;
|
||||
import it.integry.ems_model.entity.StbDevices;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class DevicesService {
|
||||
|
||||
public enum App {
|
||||
WMS,
|
||||
Wingest,
|
||||
Textiles,
|
||||
Agribook
|
||||
}
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
public void register(App application, String deviceId) throws Exception {
|
||||
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
|
||||
EntityProcessor entityProcessor = ApplicationContextProvider.getApplicationContext().getBean(EntityProcessor.class);
|
||||
UserSession userSession = ContextLoader.getCurrentWebApplicationContext().getBean(UserSession.class);
|
||||
|
||||
if (!userSession.isAttivo()) {
|
||||
throw new UsernameNotFoundException("Utente " + userSession.getUsername() + " non riconoscuto!");
|
||||
}
|
||||
|
||||
String appName = application.name();
|
||||
|
||||
String selectSql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM stb_devices " +
|
||||
" WHERE identification_id = {}", deviceId);
|
||||
|
||||
boolean exists =
|
||||
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), selectSql);
|
||||
|
||||
if (!exists) {
|
||||
StbDevices stbDevices = new StbDevices()
|
||||
.setName(appName)
|
||||
.setIdentificationId(deviceId)
|
||||
.setCreatedAt(new Date())
|
||||
.setLastUse(new Date());
|
||||
|
||||
stbDevices.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityProcessor.processEntity(stbDevices, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateUsage(Connection connection, String deviceId) throws Exception {
|
||||
String updateSql = Query.format("UPDATE stb_devices " +
|
||||
" SET last_use = {}" +
|
||||
" WHERE identification_id = {}", UtilityLocalDate.getNowTime(), deviceId);
|
||||
|
||||
UtilityDB.executeSimpleUpdate(connection, updateSql);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package it.integry.ems.devices.dto;
|
||||
|
||||
public class RegisterDeviceRequestDTO {
|
||||
|
||||
private String app;
|
||||
|
||||
public String getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
public RegisterDeviceRequestDTO setApp(String app) {
|
||||
this.app = app;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class RequestDataDTO {
|
||||
private String requestClientIP;
|
||||
|
||||
private String profileDB;
|
||||
private String deviceId;
|
||||
private Long deviceId;
|
||||
private String username;
|
||||
private String password;
|
||||
private boolean includeNulls = false;
|
||||
@@ -55,10 +55,6 @@ public class RequestDataDTO {
|
||||
profileDB = request.getHeader(CommonConstants.PROFILE_DB);
|
||||
}
|
||||
|
||||
if (request != null && request.getHeader(EmsRestConstants.DEVICE_ID) != null) {
|
||||
deviceId = request.getHeader(EmsRestConstants.DEVICE_ID);
|
||||
}
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
|
||||
readAuthenticationClaims(authentication);
|
||||
@@ -107,7 +103,7 @@ public class RequestDataDTO {
|
||||
}
|
||||
|
||||
public boolean isValidDeviceId() {
|
||||
return !UtilityString.isNullOrEmpty(deviceId);
|
||||
return deviceId != null;
|
||||
}
|
||||
|
||||
public boolean isValidUsername() {
|
||||
@@ -136,7 +132,7 @@ public class RequestDataDTO {
|
||||
return profileDB;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
public Long getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
@@ -173,10 +169,10 @@ public class RequestDataDTO {
|
||||
|
||||
private void readAuthenticationClaims(Authentication authentication) {
|
||||
username = authentication.getName();
|
||||
//final UsernamePasswordAuthenticationToken principal = (UsernamePasswordAuthenticationToken) authentication.getPrincipal();
|
||||
final AuthTokenDetails authTokenDetails = (AuthTokenDetails) authentication.getDetails();
|
||||
|
||||
userDTO = authTokenDetails.getUserDTO();
|
||||
deviceId = authTokenDetails.getDeviceId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250313150320 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("UPDATE atb_forn SET flag_forfettario = 'N' WHERE flag_forfettario IS NULL",
|
||||
"ALTER TABLE atb_forn ALTER COLUMN flag_forfettario VARCHAR(1) NOT NULL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250314135233 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("EXPORT_VARIAZIONE PV", "XML_DIALOGO", "EMAIL_FOR_OK", null,
|
||||
"SE CONFIGURATA INIVA L'EMAIL CON LA CONFERMA DELL'AVVENTUA ESPORTAZIONE", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250314163223 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateProcedure("MRP_UpdateQtaImpProx", "CREATE Procedure [dbo].[MRP_UpdateQtaImpProx](@elencoArticoli varchar(max) = null)\n" +
|
||||
"AS \n" +
|
||||
"--DECLARE @elencoarticoli VARCHAR(MAX) --= 'CEB1TREORI6|CEB1LMS5|CEBB1MRCH2|CVINACBO1LEV2'\n" +
|
||||
"--DROP TABLE #tmp\n" +
|
||||
"\n" +
|
||||
"SET NOCOUNT ON;\n" +
|
||||
"DECLARE @tableart TABLE\n" +
|
||||
" (\n" +
|
||||
" cod_mart VARCHAR(15)\n" +
|
||||
" );\n" +
|
||||
"\n" +
|
||||
"IF @elencoarticoli IS NOT NULL AND @elencoarticoli <> ''\n" +
|
||||
" BEGIN\n" +
|
||||
" INSERT INTO @tableart\n" +
|
||||
" SELECT *\n" +
|
||||
" FROM dbo.parsestringintoarray(@elencoarticoli, '|')\n" +
|
||||
" END\n" +
|
||||
"ELSE\n" +
|
||||
" BEGIN\n" +
|
||||
" INSERT INTO @tableart\n" +
|
||||
" SELECT mtb_aart.cod_mart\n" +
|
||||
" FROM mtb_aart\n" +
|
||||
" INNER JOIN jtb_cicl ON mtb_aart.cod_mart = jtb_cicl.cod_mart\n" +
|
||||
" WHERE mtb_aart.flag_stato = 'A'\n" +
|
||||
" END;\n" +
|
||||
"\n" +
|
||||
"WITH imp_ordini AS (SELECT mtb_part.cod_mart,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN SUM(mtb_part.qta_imp_cli) > SUM(mtb_part.qta_esistente + mtb_part.qta_ord_for) THEN\n" +
|
||||
" SUM(mtb_part.qta_imp_cli - (mtb_part.qta_esistente + mtb_part.qta_ord_for))\n" +
|
||||
" ELSE 0 END AS qtadaprodurre,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN SUM(mtb_part.qta_imp_cli) > SUM(mtb_part.qta_esistente + mtb_part.qta_ord_for) THEN\n" +
|
||||
" SUM(mtb_part.qta_imp_cli - (mtb_part.qta_esistente + mtb_part.qta_ord_for)) /\n" +
|
||||
" mtb_aart.qta_cnf\n" +
|
||||
" ELSE 0 END AS numdaprodurre,\n" +
|
||||
" SUM((mtb_part.qta_esistente + mtb_part.qta_ord_for) - mtb_part.qta_imp_cli) AS qta_disp\n" +
|
||||
" \n" +
|
||||
" FROM mtb_part\n" +
|
||||
" INNER JOIN jtb_cicl ON mtb_part.cod_mart = jtb_cicl.cod_prod\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_part.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN @tableart a ON mtb_aart.cod_mart = a.cod_mart\n" +
|
||||
" WHERE mtb_aart.flag_stato = 'A'\n" +
|
||||
" GROUP BY mtb_part.cod_mart, mtb_aart.unt_mis, mtb_aart.qta_cnf\n" +
|
||||
" HAVING SUM(mtb_part.qta_esistente + mtb_part.qta_ord_for) <> SUM(mtb_part.qta_imp_cli) \n" +
|
||||
" \n" +
|
||||
" \n" +
|
||||
" )\n" +
|
||||
" , imp_contratti AS ( SELECT c.cod_mart,\n" +
|
||||
" ISNULL(SUM((qta_vend_contratto - qta_ord - qta_doc) /\n" +
|
||||
" CASE WHEN c.rap_conv = 0 THEN 1 ELSE c.rap_conv END), 0) AS qtacontratto\n" +
|
||||
" FROM vvw_contratti_vendita c\n" +
|
||||
" INNER JOIN @tableart a ON c.cod_mart = a.cod_mart\n" +
|
||||
" WHERE c.data_fine >= CAST(GETDATE() AS DATE)\n" +
|
||||
" GROUP BY c.cod_mart\n" +
|
||||
" HAVING ISNULL(SUM(qta_residua), 0) > 0)\n" +
|
||||
" , imp_budget AS (SELECT b.cod_mart,\n" +
|
||||
" SUM(qta_saldo) AS qta_bdg\n" +
|
||||
" FROM ovw_budget_ordv b\n" +
|
||||
" INNER JOIN @tableart a ON b.cod_mart = a.cod_mart\n" +
|
||||
" WHERE CAST(GETDATE() AS DATE) BETWEEN b.data_iniz AND b.data_fine\n" +
|
||||
" AND qta_saldo <> 0\n" +
|
||||
" GROUP BY b.cod_mart)\n" +
|
||||
" , tmp_impegni\n" +
|
||||
" AS (SELECT ISNULL(ISNULL(imp_ordini.cod_mart, imp_contratti.cod_mart), imp_budget.cod_mart) AS cod_mart,\n" +
|
||||
" SUM(ISNULL(imp_ordini.qtadaprodurre, 0)) AS qtadaprodurre,\n" +
|
||||
" SUM(ISNULL(imp_ordini.numdaprodurre, 0)) AS numdaprodurre,\n" +
|
||||
" SUM(ISNULL(imp_contratti.qtacontratto,0)) AS qtacontratto ,\n" +
|
||||
" SUM(ISNULL(imp_budget.qta_bdg, 0)) AS qtabudget\n" +
|
||||
" \n" +
|
||||
" FROM imp_ordini\n" +
|
||||
" FULL OUTER JOIN imp_contratti ON imp_ordini.cod_mart = imp_contratti.cod_mart\n" +
|
||||
" FULL OUTER JOIN imp_budget ON imp_ordini.cod_mart = imp_budget.cod_mart\n" +
|
||||
" \n" +
|
||||
" GROUP BY ISNULL(ISNULL(imp_ordini.cod_mart, imp_contratti.cod_mart), imp_budget.cod_mart)\n" +
|
||||
" HAVING SUM(ISNULL(imp_ordini.qtadaprodurre, 0)) <> 0\n" +
|
||||
" OR SUM(ISNULL(imp_contratti.qtacontratto,0)) <> 0\n" +
|
||||
" OR SUM(ISNULL(imp_budget.qta_bdg, 0)) <> 0)\n" +
|
||||
"\n" +
|
||||
"SELECT materiali.cod_mart,\n" +
|
||||
" materiali.cod_prod,\n" +
|
||||
" jtb_fasi.cod_mdep_lav AS cod_mdep,\n" +
|
||||
" SUM(qtadaprodurre * ((materiali.qta_prod * materiali.rap_conv) /\n" +
|
||||
" (jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod))) AS impegnatoprox,\n" +
|
||||
" SUM(qtacontratto * ((materiali.qta_prod * materiali.rap_conv) /\n" +
|
||||
" (jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod))) AS impproxcontratto,\n" +
|
||||
" SUM(qtabudget * ((materiali.qta_prod * materiali.rap_conv) /\n" +
|
||||
" (jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod))) AS impproxbudget,\n" +
|
||||
" /*\n" +
|
||||
" max(case when ord.gestione = 'L' THEN max_data_cons else null end ) as data_imp_prox,\n" +
|
||||
" max(case when ord.gestione = 'A' THEN max_data_cons else null end ) as data_imp_prox_contr\n" +
|
||||
" */\n" +
|
||||
" IsNull(max(ORD.data_imp_prox), convert(date,GetDate())) as data_imp_prox,\n" +
|
||||
" IsNull(max(ORD.data_imp_prox_contr), convert(date,GetDate())) as data_imp_prox_contr\n" +
|
||||
"INTO #tmp\n" +
|
||||
"FROM tmp_impegni\n" +
|
||||
" INNER JOIN\n" +
|
||||
" (\n" +
|
||||
" SELECT cod_mart, descrizione_estesa, unt_mis_prod AS unt_doc, rap_conv_prod AS rap_conv, qta_prod, cod_prod\n" +
|
||||
" FROM [dbo].getmaterialidistinta(NULL, 1)\n" +
|
||||
" WHERE cod_parent IS NOT NULL) materiali ON materiali.cod_prod = tmp_impegni.cod_mart\n" +
|
||||
" INNER JOIN jtb_cicl ON materiali.cod_prod = jtb_cicl.cod_prod\n" +
|
||||
" INNER JOIN jtb_fasi ON jtb_cicl.cod_jfas = jtb_fasi.cod_jfas \n" +
|
||||
" LEFT OUTER JOIN (\n" +
|
||||
" /* Modifcata da Massimo 10/07/24 la vecchia query creva quantità doppie in presenza di ordini L e A\n" +
|
||||
" select cod_mart, dtb_ordt.gestione, MAX(dtb_ordr.data_cons) as max_data_cons\n" +
|
||||
" from dtb_ordt inner join dtb_ordr on dtb_ordt.gestione = dtb_ordr.gestione\n" +
|
||||
" and dtb_ordt.data_ord = dtb_ordr.data_ord\n" +
|
||||
" and dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" where dtb_ordt.gestione <> 'V' AND\n" +
|
||||
" dtb_ordt.flag_annulla = 'N' and\n" +
|
||||
" dtb_ordt.flag_budget = 0 and\n" +
|
||||
" dtb_ordt.flag_sospeso = 'N' and\n" +
|
||||
" dtb_ordt.flag_evaso_forzato = 'N' and \n" +
|
||||
" dtb_ordr.flag_evaso = 'I' \n" +
|
||||
" group by cod_mart, dtb_ordt.gestione\n" +
|
||||
" */\n" +
|
||||
" Select isNull(ODL.cod_mart,ODA.cod_mart) as cod_mart, ODL.data_imp_prox, ODA.data_imp_prox_contr\n" +
|
||||
" from \n" +
|
||||
" (select cod_mart, dtb_ordt.gestione, MAX(dtb_ordr.data_cons) as data_imp_prox\n" +
|
||||
" from dtb_ordt inner join dtb_ordr on dtb_ordt.gestione = dtb_ordr.gestione\n" +
|
||||
" and dtb_ordt.data_ord = dtb_ordr.data_ord\n" +
|
||||
" and dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" where dtb_ordt.gestione = 'L' AND\n" +
|
||||
" dtb_ordt.flag_annulla = 'N' and\n" +
|
||||
" dtb_ordt.flag_budget = 0 and\n" +
|
||||
" dtb_ordt.flag_sospeso = 'N' and\n" +
|
||||
" dtb_ordt.flag_evaso_forzato = 'N' and \n" +
|
||||
" dtb_ordt.flag_evaso_prod = 'I' and\n" +
|
||||
" dtb_ordr.flag_evaso = 'I' \n" +
|
||||
" group by cod_mart, dtb_ordt.gestione\n" +
|
||||
" )ODL full outer join\n" +
|
||||
" (\n" +
|
||||
" select cod_mart, dtb_ordt.gestione, MAX(dtb_ordr.data_cons) as data_imp_prox_contr\n" +
|
||||
" from dtb_ordt inner join dtb_ordr on dtb_ordt.gestione = dtb_ordr.gestione\n" +
|
||||
" and dtb_ordt.data_ord = dtb_ordr.data_ord\n" +
|
||||
" and dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" where dtb_ordt.gestione = 'A' AND\n" +
|
||||
" dtb_ordt.flag_annulla = 'N' and\n" +
|
||||
" dtb_ordt.flag_budget = 0 and\n" +
|
||||
" dtb_ordt.flag_sospeso = 'N' and\n" +
|
||||
" dtb_ordt.flag_evaso_forzato = 'N' and \n" +
|
||||
" dtb_ordr.flag_evaso = 'I' \n" +
|
||||
" \n" +
|
||||
" group by cod_mart, dtb_ordt.gestione)\n" +
|
||||
" ODA on ODA.cod_mart = ODL.cod_mart\n" +
|
||||
" ) ORD ON materiali.cod_mart = ORD.cod_mart\n" +
|
||||
"GROUP BY materiali.cod_prod,\n" +
|
||||
" materiali.cod_mart,\n" +
|
||||
" jtb_fasi.cod_mdep_lav\n" +
|
||||
" \n" +
|
||||
"SELECT cod_mart,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" SUM(impegnatoprox) AS impegnatoprox,\n" +
|
||||
" SUM(impproxcontratto) AS impproxcontratto,\n" +
|
||||
" SUM(impproxbudget) AS impproxbudget,\n" +
|
||||
" case when data_imp_prox < convert(date, GetDate()) then convert(date, getDate()) else data_imp_prox end data_imp_prox,\n" +
|
||||
" case when data_imp_prox_contr < case when data_imp_prox < convert(date, GetDate()) then convert(date, getDate()) else data_imp_prox end \n" +
|
||||
" then case when data_imp_prox < convert(date, GetDate()) then convert(date, getDate()) else data_imp_prox end \n" +
|
||||
" else data_imp_prox_contr end as data_imp_prox_contr\n" +
|
||||
" --case when data_imp_prox_contr is null then isNull(data_imp_prox,convert(date,GetDate())) else data_imp_prox_contr end as data_imp_prox_contr\n" +
|
||||
" --IIF( data_imp_prox is null or data_imp_prox < Cast(getdate() as date), Cast(getdate() as date), data_imp_prox) as data_imp_prox,\n" +
|
||||
" --IIF( data_imp_prox_contr is null or isNull(data_imp_prox_contr,data_imp_prox) < Cast(getdate() as date), Cast(getdate() as date), data_imp_prox_contr) as data_imp_prox_contr \n" +
|
||||
"INTO #tmpsum\n" +
|
||||
"FROM #tmp\n" +
|
||||
"WHERE cod_mdep IS NOT NULL\n" +
|
||||
"GROUP BY cod_mart, cod_mdep,\n" +
|
||||
" data_imp_prox,\n" +
|
||||
" data_imp_prox_contr\n" +
|
||||
"\n" +
|
||||
"INSERT INTO mtb_part (cod_mart, cod_mdep, scorta_min, qta_esistente, qta_imp_cli, qta_imp_lav, qta_ord_for)\n" +
|
||||
"SELECT cod_mart, cod_mdep, 0, 0, 0, 0, 0\n" +
|
||||
"FROM #tmpsum t\n" +
|
||||
"WHERE NOT EXISTS(SELECT * FROM mtb_part WHERE mtb_part.cod_mart = t.cod_mart AND mtb_part.cod_mdep = t.cod_mdep)\n" +
|
||||
"\n" +
|
||||
"IF @elencoarticoli IS NULL OR @elencoarticoli = ''\n" +
|
||||
" UPDATE mtb_part SET qta_imp_prox = 0, qta_imp_prox_contr = 0, qta_imp_prox_bdg = 0, data_imp_prox = null, data_imp_prox_contr = null\n" +
|
||||
"ELSE\n" +
|
||||
" UPDATE mtb_part\n" +
|
||||
" SET qta_imp_prox = 0,\n" +
|
||||
" qta_imp_prox_contr = 0,\n" +
|
||||
" qta_imp_prox_bdg = 0,\n" +
|
||||
" data_imp_prox = null, \n" +
|
||||
" data_imp_prox_contr = null \n" +
|
||||
" WHERE cod_mart IN (SELECT cod_mart FROM #tmpsum)\n" +
|
||||
"\n" +
|
||||
"UPDATE mtb_part\n" +
|
||||
"SET qta_imp_prox = q.impegnatoprox,\n" +
|
||||
" qta_imp_prox_contr = q.impproxcontratto,\n" +
|
||||
" qta_imp_prox_bdg = q.impproxbudget,\n" +
|
||||
" data_imp_prox = DateAdd(day, 1, q.data_imp_prox), \n" +
|
||||
" data_imp_prox_contr = DateAdd(day, 1, q.data_imp_prox_contr )\n" +
|
||||
"FROM mtb_part\n" +
|
||||
" INNER JOIN #tmpsum q ON mtb_part.cod_mdep = q.cod_mdep AND mtb_part.cod_mart = q.cod_mart\n" +
|
||||
"\n" +
|
||||
"IF EXISTS(SELECT *\n" +
|
||||
" FROM #tmp\n" +
|
||||
" WHERE cod_mdep IS NULL)\n" +
|
||||
" BEGIN\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" DECLARE @message VARCHAR(MAX), @email VARCHAR(MAX)\n" +
|
||||
"\n" +
|
||||
" SELECT @email = e_mail FROM stb_email WHERE flag_default = 'S';\n" +
|
||||
"\n" +
|
||||
" SET @message = 'Verificare i seguenti articoli: la fase non ha il deposito agganciato.' + CHAR(10) + CHAR(13)\n" +
|
||||
" SELECT @message = @message +\n" +
|
||||
" STUFF((SELECT ',' + cod_prod\n" +
|
||||
" FROM #tmp\n" +
|
||||
" WHERE cod_mdep IS NULL\n" +
|
||||
" FOR XML PATH('')), 1, 1, '')\n" +
|
||||
"\n" +
|
||||
" EXECUTE [dbo].[sp_sendEmail] @email, 'helpdesk@integry.it', 'Errore Impegni Prossimi', @message\n" +
|
||||
"\n" +
|
||||
" END");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250314174219 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("PVM", "ACCETTAZIONE", "VIEW_CHK_LIST", "N",
|
||||
"Visualizza la lista dei colli", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import it.integry.ems.service.dto.AttachmentDTO;
|
||||
import it.integry.ems.service.dto.EntityFieldDTO;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
@@ -75,6 +76,7 @@ import java.nio.file.Files;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@@ -126,6 +128,9 @@ public class EmsServices {
|
||||
@Autowired
|
||||
private MimeTypesHandler mimetypesFileTypeMap;
|
||||
|
||||
@Autowired
|
||||
private SettingsController settingsController;
|
||||
|
||||
public EntityImportResponse<List<EntityBase>> importEntity(String type, String format, ImportRequestDTO body, boolean headless) throws Exception {
|
||||
logger.debug("Starting import [Type: " + type + ", Format: " + format + "]");
|
||||
String gestName = "IMPORT_" + type;
|
||||
@@ -186,8 +191,8 @@ public class EmsServices {
|
||||
if (UtilityString.isNullOrEmpty(fileNameFilter)) {
|
||||
filesList = fileInput.listFiles();
|
||||
} else {
|
||||
filesList = fileInput.listFiles((dir, name) -> name.startsWith(fileNameFilter) ||
|
||||
name.equalsIgnoreCase(fileNameFilter));
|
||||
Pattern pattern = Pattern.compile(fileNameFilter, Pattern.CASE_INSENSITIVE);
|
||||
filesList = fileInput.listFiles((dir, name) -> pattern.matcher(name).matches());
|
||||
}
|
||||
} else if (!flagDirectory) {
|
||||
filesList = new File[1];
|
||||
@@ -825,7 +830,9 @@ public class EmsServices {
|
||||
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||
throw new Exception("Cannot export server info in DEBUG mode");
|
||||
|
||||
List<AvailableConnectionsModel> availableConnectionList = settingsModel.getAvailableConnections(true);
|
||||
|
||||
List<AvailableConnectionsModel> availableConnectionList =
|
||||
settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true, settingsController.getHistoryProfileDb());
|
||||
|
||||
for (AvailableConnectionsModel model : availableConnectionList) {
|
||||
try {
|
||||
@@ -852,10 +859,6 @@ public class EmsServices {
|
||||
try {
|
||||
Properties jvmProperties = System.getProperties();
|
||||
|
||||
// String tomcatBase = jvmProperties.getProperty("catalina.base");
|
||||
// String warPath = String.format("%s/webapps/ems-api.war", tomcatBase);
|
||||
// File warFile = new File(warPath);
|
||||
|
||||
String domainname = System.getenv("USERDOMAIN");
|
||||
arguments.put("domainName", domainname);
|
||||
|
||||
@@ -997,9 +1000,10 @@ public class EmsServices {
|
||||
|
||||
|
||||
List<AdvancedDataSource> db =
|
||||
Stream.of(data.getActiveConnections())
|
||||
data.getActiveConnections().stream()
|
||||
.filter(x -> UtilityString.equalsIgnoreCase(x.getDataSource().getProfile(), x.getDataSource().getDbName()) &&
|
||||
x.isInternalDb()).toList();
|
||||
x.isInternalDb())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (AdvancedDataSource dataSource : db) {
|
||||
HashMap<String, Object> resultDbInfo = UtilityDB.executeSimpleQueryOnlyFirstRow(dataSource.getConnection(), sql);
|
||||
|
||||
@@ -892,6 +892,9 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
}
|
||||
|
||||
private void executeManage() throws Exception {
|
||||
if (getOperation() == OperationType.NO_OP)
|
||||
managePriorityPre();
|
||||
|
||||
managePriorityPre();
|
||||
if (getOperation() == OperationType.NO_OP) {
|
||||
// FABIO 20.1.2017: se la entity era in sincronizzazione cond altri
|
||||
|
||||
@@ -54,7 +54,6 @@ public class EmsRestConstants {
|
||||
public static final String PASSWORD = "password";
|
||||
public static final String X_APP_TOKEN = "x-app-token";
|
||||
|
||||
public static final String DEVICE_ID = "device_id";
|
||||
public static final String INCLUDE_NULLS = "include_nulls";
|
||||
public static final String FILE_PROPS_NAME = "configs";
|
||||
//calcoli
|
||||
|
||||
@@ -360,6 +360,9 @@ public class DtbDoct extends DtbBaseDocT implements EquatableEntityInterface<Dtb
|
||||
@JsonProperty(value = "numCmovAutofattura")
|
||||
private Integer numCmovAutofattura;
|
||||
|
||||
@JsonProperty
|
||||
private boolean checkNumDoc = true;
|
||||
|
||||
private DtbTipi dtbTipi;
|
||||
|
||||
private VtbClie vtbClie;
|
||||
@@ -1382,6 +1385,15 @@ public class DtbDoct extends DtbBaseDocT implements EquatableEntityInterface<Dtb
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCheckNumDoc() {
|
||||
return checkNumDoc;
|
||||
}
|
||||
|
||||
public DtbDoct setCheckNumDoc(boolean checkNumDoc) {
|
||||
this.checkNumDoc = checkNumDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DtbTipi getDtbTipi() {
|
||||
return dtbTipi;
|
||||
}
|
||||
@@ -1729,25 +1741,28 @@ public class DtbDoct extends DtbBaseDocT implements EquatableEntityInterface<Dtb
|
||||
numDocOld = numDoc;
|
||||
HashMap<String, Object> oldPk = getOldPk();
|
||||
if (oldPk != null && !oldPk.isEmpty()) {
|
||||
|
||||
if (oldPk.containsKey("codAnag"))
|
||||
codAnagOld = (String) oldPk.get("codAnag");
|
||||
else if (oldPk.containsKey("codDtip"))
|
||||
codDtipOld = (String) oldPk.get("codDtip");
|
||||
else if (oldPk.containsKey("dataDoc")) {
|
||||
Object value = oldPk.get("dataDoc");
|
||||
if (value instanceof String )
|
||||
dataDocOld = UtilityString.parseDate((String) oldPk.get("dataDoc"));
|
||||
else
|
||||
dataDocOld = (Date) value;
|
||||
for (HashMap.Entry<String, Object> dati : oldPk.entrySet()) {
|
||||
String fieldName = dati.getKey();
|
||||
if (fieldName.equalsIgnoreCase("codAnag")) {
|
||||
codAnagOld = (String) dati.getValue();
|
||||
} else if (fieldName.equalsIgnoreCase("codDtip")) {
|
||||
codDtipOld = (String) dati.getValue();
|
||||
}else if (fieldName.equalsIgnoreCase("dataDoc")) {
|
||||
Object value = dati.getValue();
|
||||
if (value instanceof String )
|
||||
dataDocOld = UtilityString.parseDate((String) oldPk.get("dataDoc"));
|
||||
else
|
||||
dataDocOld = (Date) value;
|
||||
} else if (fieldName.equalsIgnoreCase("serDoc")) {
|
||||
serDocOld = (String) dati.getValue();
|
||||
}
|
||||
else if (fieldName.equalsIgnoreCase("numDoc")) {
|
||||
if (oldPk.get("numDoc") instanceof String) {
|
||||
numDocOld = Integer.valueOf((String) oldPk.get("numDoc"));
|
||||
} else
|
||||
numDocOld = (Integer) oldPk.get("numDoc");
|
||||
}
|
||||
}
|
||||
else if (oldPk.containsKey("serDoc"))
|
||||
serDocOld = (String) oldPk.get("serDoc");
|
||||
else if (oldPk.containsKey("numDoc"))
|
||||
if ( oldPk.get("numDoc") instanceof String ) {
|
||||
numDocOld = Integer.valueOf((String) oldPk.get("numDoc"));
|
||||
} else
|
||||
numDocOld = (Integer) oldPk.get("numDoc");
|
||||
}
|
||||
if ("DIRETTA".equals(tipoEmissione)) {
|
||||
// HashMap<String, Object> datiDoc = new HashMap<>();
|
||||
|
||||
@@ -381,7 +381,7 @@ public class DtbOrdt extends DtbDocOrdT implements EquatableEntityInterface<DtbO
|
||||
@SqlField(value = "incoterms", maxLength = 20)
|
||||
private String incoterms;
|
||||
|
||||
@SqlField(value = "note_incoterms", maxLength = 20)
|
||||
@SqlField(value = "note_incoterms", maxLength = 40)
|
||||
private String noteIncoterms;
|
||||
|
||||
private BigDecimal cambio;
|
||||
|
||||
@@ -222,6 +222,9 @@ public class DtbTipi extends EntityBase {
|
||||
@EntityChild
|
||||
private List<DrlTipiNoteDoc> drlTipiNoteDoc= new ArrayList<>();
|
||||
|
||||
@EntityChild
|
||||
private WtbJreptSetup wtbJreptSetup;
|
||||
|
||||
public DtbTipi() {
|
||||
super(logger);
|
||||
}
|
||||
@@ -822,6 +825,15 @@ public class DtbTipi extends EntityBase {
|
||||
|
||||
public void setCodCcauCoan(String codCcauCoan) { this.codCcauCoan = codCcauCoan; }
|
||||
|
||||
public WtbJreptSetup getWtbJreptSetup() {
|
||||
return wtbJreptSetup;
|
||||
}
|
||||
|
||||
public DtbTipi setWtbJreptSetup(WtbJreptSetup wtbJreptSetup) {
|
||||
this.wtbJreptSetup = wtbJreptSetup;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteChilds() throws Exception {
|
||||
DtbTipiAnag dtbTipiAnag = new DtbTipiAnag();
|
||||
@@ -830,6 +842,8 @@ public class DtbTipi extends EntityBase {
|
||||
dtbTipiCarat.deleteAllEntities(connection, this);
|
||||
DrlTipiNoteDoc drlTipiNoteDoc = new DrlTipiNoteDoc();
|
||||
drlTipiNoteDoc.deleteAllEntities(connection, this);
|
||||
WtbJreptSetup wtbJreptSetup = new WtbJreptSetup();
|
||||
wtbJreptSetup.deleteAllEntities(connection, this);
|
||||
}
|
||||
|
||||
public enum AccontoDa {
|
||||
|
||||
@@ -130,4 +130,18 @@ public class UtilityLocalDate {
|
||||
if (dateToCheck == null) return fallbackValue;
|
||||
return dateToCheck;
|
||||
}
|
||||
|
||||
public static LocalDateTime addHourToLocalDate(LocalDate localDate, String hour) {
|
||||
LocalDateTime localDateTime = localDate.atStartOfDay();
|
||||
String[] split = hour.split(":");
|
||||
int hourToAdd = 0;
|
||||
int minuteToAdd = 0;
|
||||
int secondToAdd = 0;
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
if (i == 0) hourToAdd = Integer.parseInt(split[i]);
|
||||
else if (i == 1) minuteToAdd = Integer.parseInt(split[i]);
|
||||
else if (i == 2) secondToAdd = Integer.parseInt(split[i]);
|
||||
}
|
||||
return localDateTime.plusHours(hourToAdd).plusMinutes(minuteToAdd).plusSeconds(secondToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package it.integry.security.config;
|
||||
import it.integry.security.JWTAccessDeniedHandler;
|
||||
import it.integry.security.JWTAuthenticationEntryPoint;
|
||||
import it.integry.security.cache.JwtTokenCacheComponent;
|
||||
import it.integry.security.jwt.JWTFilter;
|
||||
import it.integry.security.jwt.AccessTokenProvider;
|
||||
import it.integry.security.jwt.JWTFilter;
|
||||
import it.integry.security.provider.TokenAuthenticationProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -24,10 +24,13 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
|
||||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
@Autowired
|
||||
private AccessTokenProvider accessTokenProvider;
|
||||
|
||||
@Autowired
|
||||
private JwtTokenCacheComponent tokenCache;
|
||||
|
||||
@Autowired
|
||||
private JWTAuthenticationEntryPoint authenticationErrorHandler;
|
||||
|
||||
@Autowired
|
||||
private JWTAccessDeniedHandler jwtAccessDeniedHandler;
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ public class JWTFilter extends GenericFilterBean {
|
||||
public JWTFilter(AccessTokenProvider accessTokenProvider, JwtTokenCacheComponent tokenCache) {
|
||||
this.accessTokenProvider = accessTokenProvider;
|
||||
this.tokenCache = tokenCache;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package it.integry.security.service;
|
||||
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DeviceInternalService {
|
||||
|
||||
private final Logger logger = LogManager.getLogger(DeviceInternalService.class);
|
||||
|
||||
@Autowired
|
||||
private SettingsModel settingsModel;
|
||||
|
||||
@Autowired
|
||||
private SettingsController settingsController;
|
||||
|
||||
|
||||
@Scheduled(cron = "0 0 0 * * *", zone = "Europe/Rome")
|
||||
private void cleanOrphanDevices() {
|
||||
if(UtilityDebug.isDebugExecution() || !settingsModel.isPrimaryInstance())
|
||||
return;
|
||||
|
||||
String cleanQuery = "DELETE stb_devices FROM stb_devices\n" +
|
||||
"LEFT OUTER JOIN stb_auth_tokens ON stb_auth_tokens.device_id = stb_devices.id\n" +
|
||||
"WHERE stb_auth_tokens.device_id IS NULL";
|
||||
|
||||
try {
|
||||
List<AvailableConnectionsModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true, settingsController.getHistoryProfileDb());
|
||||
|
||||
for(AvailableConnectionsModel availableConnection : availableConnections) {
|
||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(availableConnection)) {
|
||||
UtilityDB.executeStatement(mdb.getPrimaryConnection(), cleanQuery);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,14 +1,21 @@
|
||||
package it.integry.security.service;
|
||||
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.model.IntegryApplicationEnum;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.entity.StbDevices;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@@ -17,6 +24,7 @@ public class DeviceService {
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
@@ -45,4 +53,22 @@ public class DeviceService {
|
||||
return stbDevices;
|
||||
}
|
||||
|
||||
|
||||
public String getIdentificationString(long deviceId) throws SQLException, IOException, PrimaryDatabaseNotPresentException {
|
||||
String sql = "SELECT identification_id " +
|
||||
"FROM " + StbDevices.ENTITY + " " +
|
||||
"WHERE id = " + deviceId;
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
}
|
||||
|
||||
public void updateUsage(IntegryApplicationEnum application, long deviceId) throws Exception {
|
||||
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
|
||||
String updateSql = Query.format("UPDATE stb_devices " +
|
||||
" SET last_use = {}, name = {}" +
|
||||
" WHERE id = {}", UtilityLocalDate.getNowTime(), application.name(), deviceId);
|
||||
|
||||
UtilityDB.executeSimpleUpdate(multiDBTransactionManager.getPrimaryConnection(), updateSql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ salience 20
|
||||
no-loop
|
||||
when
|
||||
eval(checkRulesEnabled)
|
||||
$entity : DtbDoct(codAnag != null && codDtip != null && serDoc != null && numDoc !=null && dataDoc != null)
|
||||
$entity : DtbDoct(codAnag != null && codDtip != null && serDoc != null && numDoc !=null && dataDoc != null && checkNumDoc)
|
||||
eval(DocumentCheckRules.checkExistDoc(conn, $entity))
|
||||
then
|
||||
end
|
||||
|
||||
@@ -1003,73 +1003,76 @@ public class ActivityService {
|
||||
}
|
||||
|
||||
List<ActivityDTO> activityDTOS = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.class);
|
||||
List<String> elencoId = Stream.of(activityDTOS).map(ActivityDTO::getIdAttivita).toList();
|
||||
sql =
|
||||
"SELECT stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name,\n" +
|
||||
" MAX(IIF(effective_date <= CAST(GETDATE() AS DATE), effective_date, NULL)) AS last_activity_date,\n" +
|
||||
" MIN(IIF(estimated_date >= CAST(GETDATE() AS DATE), estimated_date, NULL)) AS next_activity_date,\n" +
|
||||
" MAX(IIF(((estimated_date BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()) OR\n" +
|
||||
" estimated_date IS NULL) AND effective_date IS NULL), stb_activity.activity_description,\n" +
|
||||
" NULL)) AS activity_description,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_this_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, -1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_previous_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, 1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, 1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_next_week,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(GETDATE()) AND EOMONTH(GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(DATEADD(MONTH, -1, GETDATE())) AND EOMONTH(DATEADD(MONTH, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" DATEPART(QUARTER, effective_date) = DATEPART(QUARTER, GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_quarter,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND DATEPART(QUARTER, effective_date) =\n" +
|
||||
" DATEPART(QUARTER, DATEADD(MONTH, -3, GETDATE())), 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_quarter,\n" +
|
||||
" SUM(jtb_rlavr.ore) AS ore_fatte\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" AND stb_activity.parent_activity_id IN (" + UtilityDB.listValueToString(elencoId) + ")\n" +
|
||||
"GROUP BY stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name";
|
||||
|
||||
List<ActivityDTO.WorkedHours> activityResponseDtoWorkedHours = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.WorkedHours.class);
|
||||
if (activityDTOS != null) {
|
||||
List<String> elencoId = Stream.of(activityDTOS).map(ActivityDTO::getIdAttivita).toList();
|
||||
sql =
|
||||
"SELECT stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name,\n" +
|
||||
" MAX(IIF(effective_date <= CAST(GETDATE() AS DATE), effective_date, NULL)) AS last_activity_date,\n" +
|
||||
" MIN(IIF(estimated_date >= CAST(GETDATE() AS DATE), estimated_date, NULL)) AS next_activity_date,\n" +
|
||||
" MAX(IIF(((estimated_date BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()) OR\n" +
|
||||
" estimated_date IS NULL) AND effective_date IS NULL), stb_activity.activity_description,\n" +
|
||||
" NULL)) AS activity_description,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_this_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, -1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_previous_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, 1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, 1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_next_week,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(GETDATE()) AND EOMONTH(GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(DATEADD(MONTH, -1, GETDATE())) AND EOMONTH(DATEADD(MONTH, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" DATEPART(QUARTER, effective_date) = DATEPART(QUARTER, GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_quarter,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND DATEPART(QUARTER, effective_date) =\n" +
|
||||
" DATEPART(QUARTER, DATEADD(MONTH, -3, GETDATE())), 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_quarter,\n" +
|
||||
" SUM(jtb_rlavr.ore) AS ore_fatte\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" AND stb_activity.parent_activity_id IN (" + UtilityDB.listValueToString(elencoId) + ")\n" +
|
||||
"GROUP BY stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name";
|
||||
|
||||
if (activityResponseDtoWorkedHours != null) {
|
||||
final HashMap<String, List<ActivityDTO.WorkedHours>> subActivityList = activityResponseDtoWorkedHours.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
ActivityDTO.WorkedHours::getParentActivityId,
|
||||
LinkedHashMap::new,
|
||||
Collectors.toList()
|
||||
));
|
||||
List<ActivityDTO.WorkedHours> activityResponseDtoWorkedHours = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.WorkedHours.class);
|
||||
|
||||
for (ActivityDTO activityResponse : activityDTOS) {
|
||||
if (subActivityList.containsKey(activityResponse.getIdAttivita())) {
|
||||
List<ActivityDTO.WorkedHours> workedHours = subActivityList.get(activityResponse.getIdAttivita());
|
||||
if (activityResponseDtoWorkedHours != null) {
|
||||
final HashMap<String, List<ActivityDTO.WorkedHours>> subActivityList = activityResponseDtoWorkedHours.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
ActivityDTO.WorkedHours::getParentActivityId,
|
||||
LinkedHashMap::new,
|
||||
Collectors.toList()
|
||||
));
|
||||
|
||||
for (ActivityDTO.WorkedHours workedHour : workedHours) {
|
||||
if (workedHour.getActivityDescription() != null &&
|
||||
workedHour.getActivityDescription().equals(activityResponse.getDescrizione())) {
|
||||
workedHour.setActivityDescription(null);
|
||||
for (ActivityDTO activityResponse : activityDTOS) {
|
||||
if (subActivityList.containsKey(activityResponse.getIdAttivita())) {
|
||||
List<ActivityDTO.WorkedHours> workedHours = subActivityList.get(activityResponse.getIdAttivita());
|
||||
|
||||
for (ActivityDTO.WorkedHours workedHour : workedHours) {
|
||||
if (workedHour.getActivityDescription() != null &&
|
||||
workedHour.getActivityDescription().equals(activityResponse.getDescrizione())) {
|
||||
workedHour.setActivityDescription(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
activityResponse.setWorkedHours(workedHours);
|
||||
activityResponse.setWorkedHours(workedHours);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class AutofatturaDTO {
|
||||
private String identificativoSdi;
|
||||
|
||||
private boolean rigeneraAutofattura;
|
||||
private boolean checkNumDoc;
|
||||
|
||||
public Integer getNumCmov() {
|
||||
return numCmov;
|
||||
@@ -57,4 +58,13 @@ public class AutofatturaDTO {
|
||||
this.rigeneraAutofattura = rigeneraAutofattura;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCheckNumDoc() {
|
||||
return checkNumDoc;
|
||||
}
|
||||
|
||||
public AutofatturaDTO setCheckNumDoc(boolean checkNumDoc) {
|
||||
this.checkNumDoc = checkNumDoc;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,8 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
@@ -83,8 +81,10 @@ public class AutofatturaService {
|
||||
numCmov);
|
||||
|
||||
CrlMovtRifCmov crlMovtRifCmov = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, CrlMovtRifCmov.class);
|
||||
crlMovtRifCmov.setOperation(OperationType.DELETE);
|
||||
entitylist.add(crlMovtRifCmov);
|
||||
if (crlMovtRifCmov != null) {
|
||||
crlMovtRifCmov.setOperation(OperationType.DELETE);
|
||||
entitylist.add(crlMovtRifCmov);
|
||||
}
|
||||
entitylist.add(dtbDoct);
|
||||
return entitylist;
|
||||
|
||||
@@ -96,91 +96,122 @@ public class AutofatturaService {
|
||||
Integer numDocFirst,
|
||||
Integer numProtFirst) throws Exception {
|
||||
|
||||
|
||||
String sql =
|
||||
Query.format("SELECT cod_dtip, Cast(num_ireg as int) as num_ireg, dare_avere, serie FROM dtb_tipi WHERE cod_ireg = %s and flag_gestione_speciale = 1 and flag_attivo = 'S' ", codIregAutoFat);
|
||||
|
||||
List<HashMap<String, Object>> tipiDocumento = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if ( tipiDocumento == null || tipiDocumento.isEmpty() )
|
||||
if (tipiDocumento == null || tipiDocumento.isEmpty())
|
||||
throw new Exception(String.format("Nessun tipo documento trovato per il registro %s", codIreg));
|
||||
|
||||
Integer anno = UtilityDate.getYear(dataInizio);
|
||||
try {
|
||||
Integer anno = UtilityDate.getYear(dataInizio);
|
||||
|
||||
CtbIreg ctbIreg = new CtbIreg()
|
||||
.setCodIreg(codIregAutoFat);
|
||||
//non spostare perchè dopo la cancellazione non funziona più il join
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT ctb_movt.num_cmov,\n" +
|
||||
" dtb_docr.descrizione_estesa as descrizione,\n" +
|
||||
" dtb_docr.note AS identificativo_sdi, \n" +
|
||||
" CAST(ctb_caus.segno_ireg as int) as segno_ireg \n" +
|
||||
"FROM ctb_movt\n" +
|
||||
" INNER JOIN crl_movt_rif_cmov ON ctb_movt.num_cmov = crl_movt_rif_cmov.num_cmov\n" +
|
||||
" INNER JOIN ctb_caus ON ctb_movt.cod_ccau = ctb_caus.cod_ccau\n" +
|
||||
" INNER JOIN dtb_doct ON crl_movt_rif_cmov.num_cmov_rif = dtb_doct.num_cmov\n" +
|
||||
" INNER JOIN dtb_docr ON dtb_doct.cod_anag = dtb_docr.cod_anag AND dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc AND dtb_doct.ser_doc = dtb_docr.ser_doc AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
"WHERE ctb_movt.data_cmov BETWEEN %s AND DateFromParts( %s, 12, 31)\n" +
|
||||
" AND ctb_movt.cod_ireg = %s\n" +
|
||||
"ORDER BY ctb_movt.data_cmov, ctb_movt.num_prot",
|
||||
dataInizio, anno, codIreg);
|
||||
|
||||
for (HashMap<String, Object> documento : tipiDocumento) {
|
||||
Integer numIreg = (Integer) documento.get("num_ireg");
|
||||
String serie = (String) documento.get("serie");
|
||||
if (ctbIreg.getCtbInum().stream().noneMatch(x->x.getNumIreg().equals(numIreg))) {
|
||||
CtbInum ctbInum = new CtbInum()
|
||||
.setAnno(anno)
|
||||
.setNumIreg(numIreg)
|
||||
.setNumProt(numProtFirst);
|
||||
ctbInum.setOperation(OperationType.UPDATE);
|
||||
ctbIreg.getCtbInum().add(ctbInum);
|
||||
List<HashMap<String, Object>> listaMov = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
//Cancellazione documenti
|
||||
sql = Query.format(
|
||||
"SELECT dtb_doct.num_cmov\n" +
|
||||
"FROM dtb_doct\n" +
|
||||
" INNER JOIN dtb_tipi ON dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
"WHERE dtb_doct.data_doc BETWEEN %s AND DATEFROMPARTS(%s, 12, 31)\n" +
|
||||
" AND dtb_tipi.cod_ireg = %s", dataInizio, anno, codIregAutoFat);
|
||||
|
||||
/*List<DtbDoct> dtbDocts = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbDoct.class);
|
||||
dtbDocts.stream().forEach(x->x.setOperation(OperationType.DELETE));
|
||||
entityProcessor.processEntityList(dtbDocts, true); */
|
||||
|
||||
List<Integer> movDeleted = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
for (Integer numCmov : movDeleted) {
|
||||
List<EntityBase> entitylist = cancellaAutofattura(numCmov);
|
||||
entityProcessor.processEntityList(entitylist, true);
|
||||
}
|
||||
|
||||
if (ctbIreg.getDtbInum().stream().noneMatch(x->x.getNumIreg().equals(numIreg) && ((String) x.getSerDoc()).equalsIgnoreCase(serie))) {
|
||||
DtbInum dtbInum = new DtbInum()
|
||||
.setAnno(anno)
|
||||
.setNumIreg(numIreg)
|
||||
.setSerDoc(serie)
|
||||
.setNumDoc(numDocFirst);
|
||||
dtbInum.setOperation(OperationType.UPDATE);
|
||||
ctbIreg.getDtbInum().add(dtbInum);
|
||||
|
||||
CtbIreg ctbIreg = new CtbIreg()
|
||||
.setCodIreg(codIregAutoFat);
|
||||
|
||||
for (HashMap<String, Object> documento : tipiDocumento) {
|
||||
Integer numIreg = (Integer) documento.get("num_ireg");
|
||||
String serie = (String) documento.get("serie");
|
||||
if (ctbIreg.getCtbInum().stream().noneMatch(x -> x.getNumIreg().equals(numIreg))) {
|
||||
CtbInum ctbInum = new CtbInum()
|
||||
.setAnno(anno)
|
||||
.setNumIreg(numIreg)
|
||||
.setNumProt(numProtFirst - 1);
|
||||
ctbInum.setOperation(OperationType.UPDATE);
|
||||
ctbIreg.getCtbInum().add(ctbInum);
|
||||
}
|
||||
|
||||
if (ctbIreg.getDtbInum().stream().noneMatch(x -> x.getNumIreg().equals(numIreg) && ((String) x.getSerDoc()).equalsIgnoreCase(serie))) {
|
||||
DtbInum dtbInum = new DtbInum()
|
||||
.setAnno(anno)
|
||||
.setNumIreg(numIreg)
|
||||
.setSerDoc(serie)
|
||||
.setNumDoc(numDocFirst - 1);
|
||||
dtbInum.setOperation(OperationType.UPDATE);
|
||||
ctbIreg.getDtbInum().add(dtbInum);
|
||||
}
|
||||
}
|
||||
|
||||
entityProcessor.processEntity(ctbIreg, true, multiDBTransactionManager);
|
||||
|
||||
|
||||
List<EntityBase> entityBaseList = new ArrayList<>();
|
||||
|
||||
boolean checkNumDoc = (UtilityDate.datePart(Calendar.DAY_OF_MONTH,dataInizio) == 1 && UtilityDate.datePart(Calendar.MONTH,dataInizio) == 0 );
|
||||
for (HashMap<String, Object> mov : listaMov) {
|
||||
String dareAvere;
|
||||
if (UtilityHashMap.<Integer>getValueIfExists(mov, "segno_ireg") < 0) {
|
||||
dareAvere = "A";
|
||||
} else {
|
||||
dareAvere = "D";
|
||||
}
|
||||
String codDtip = (String) tipiDocumento.stream()
|
||||
.filter(x -> ((String) x.get("dare_avere"))
|
||||
.equalsIgnoreCase(dareAvere)).map(x -> x.get("cod_dtip"))
|
||||
.findFirst().orElse(null);
|
||||
if (UtilityString.isNullOrEmpty(codDtip)) {
|
||||
throw new Exception(String.format("Tipo documento non configurato per la registrazione delle ",
|
||||
dareAvere.equalsIgnoreCase("D") ? "fatture" : "note credito"));
|
||||
}
|
||||
|
||||
AutofatturaDTO autofatturaDTO =
|
||||
new AutofatturaDTO().setCodDtip(codDtip)
|
||||
.setNumCmov((Integer) mov.get("num_cmov"))
|
||||
.setDescrizione((String) mov.get("descrizione"))
|
||||
.setIdentificativoSdi((String) mov.get("identificativo_sdi"))
|
||||
.setRigeneraAutofattura(true)
|
||||
.setCheckNumDoc(checkNumDoc);
|
||||
entityBaseList.add(generaAutofattura(autofatturaDTO));
|
||||
|
||||
checkNumDoc = true;
|
||||
}
|
||||
return entityBaseList;
|
||||
}catch (Exception e){
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
|
||||
entityProcessor.processEntity(ctbIreg, multiDBTransactionManager);
|
||||
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT ctb_movt.num_cmov,\n" +
|
||||
" dtb_docr.descrizione_estesa as descrizione,\n" +
|
||||
" dtb_docr.note AS identificativo_sdi, \n" +
|
||||
" CAST(ctb_caus.segno_ireg as int) as segno_ireg \n" +
|
||||
"FROM ctb_movt\n" +
|
||||
" INNER JOIN crl_movt_rif_cmov ON ctb_movt.num_cmov = crl_movt_rif_cmov.num_cmov\n" +
|
||||
" INNER JOIN ctb_caus ON ctb_movt.cod_ccau = ctb_caus.cod_ccau\n" +
|
||||
" INNER JOIN dtb_doct ON crl_movt_rif_cmov.num_cmov_rif = dtb_doct.num_cmov\n" +
|
||||
" INNER JOIN dtb_docr ON dtb_doct.cod_anag = dtb_docr.cod_anag AND dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc AND dtb_doct.ser_doc = dtb_docr.ser_doc AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
"WHERE ctb_movt.data_cmov BETWEEN %s AND DateFromParts( %s, 12, 31)\n" +
|
||||
" AND ctb_movt.cod_ireg = %s\n" +
|
||||
"ORDER BY ctb_movt.data_cmov, ctb_movt.num_prot",
|
||||
dataInizio, anno, codIreg);
|
||||
|
||||
List<HashMap<String, Object>> listaMov = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
List<EntityBase> entityBaseList = new ArrayList<>();
|
||||
for (HashMap<String, Object> mov : listaMov) {
|
||||
String dareAvere;
|
||||
if (UtilityHashMap.<Integer>getValueIfExists(mov, "segno_ireg") < 0) {
|
||||
dareAvere = "A";
|
||||
} else {
|
||||
dareAvere = "D";
|
||||
}
|
||||
String codDtip = (String) tipiDocumento.stream()
|
||||
.filter(x->((String) x.get("dare_avere"))
|
||||
.equalsIgnoreCase(dareAvere)).map(x->x.get("cod_dtip"))
|
||||
.findFirst().orElse(null);
|
||||
if ( UtilityString.isNullOrEmpty(codDtip) ) {
|
||||
throw new Exception(String.format("Tipo documento non configurato per la registrazione delle ",
|
||||
dareAvere.equalsIgnoreCase("D")?"fatture":"note credito"));
|
||||
}
|
||||
|
||||
AutofatturaDTO autofatturaDTO =
|
||||
new AutofatturaDTO().setCodDtip(codDtip)
|
||||
.setNumCmov((Integer) mov.get("num_cmov"))
|
||||
.setDescrizione((String) mov.get("descrizione"))
|
||||
.setIdentificativoSdi((String) mov.get("identificativo_sdi"))
|
||||
.setRigeneraAutofattura(true);
|
||||
entityBaseList.add(generaAutofattura(autofatturaDTO));
|
||||
}
|
||||
return entityBaseList;
|
||||
}
|
||||
|
||||
public EntityBase generaAutofattura(AutofatturaDTO autofatturaDTO) throws Exception {
|
||||
@@ -269,15 +300,17 @@ public class AutofatturaService {
|
||||
}
|
||||
|
||||
DtbDoct dtbDoct;
|
||||
if (autofatturaDTO.isRigeneraAutofattura()) {
|
||||
entityList.addAll(cancellaAutofattura((Integer) datiMov.get("num_cmov_rif")));
|
||||
if (autofatturaDTO.isRigeneraAutofattura()) {
|
||||
List<EntityBase> entityBaseList = cancellaAutofattura((Integer) datiMov.get("num_cmov_rif"));
|
||||
if ( entityBaseList != null ) entityList.addAll(entityBaseList);
|
||||
operationType = OperationType.INSERT;
|
||||
dtbDoct =
|
||||
new DtbDoct()
|
||||
.setCodAnag((String) datiMov.get("cod_anag"))
|
||||
.setCodDtip(codDtip)
|
||||
.setDataDoc((Date) datiMov.get("data_cmov"))
|
||||
.setDataReg((Date) datiMov.get("data_cmov"));
|
||||
.setDataReg((Date) datiMov.get("data_cmov"))
|
||||
.setCheckNumDoc(autofatturaDTO.isCheckNumDoc());
|
||||
} else {
|
||||
dtbDoct =
|
||||
new DtbDoct()
|
||||
@@ -412,7 +445,7 @@ public class AutofatturaService {
|
||||
if (UtilityDebug.isIntegryServer()) {
|
||||
availableConnections = availableConnections.stream().filter(x ->
|
||||
x.getDbName().equalsIgnoreCase("STUDIOML"))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
for (AvailableConnectionsModel model : availableConnections) {
|
||||
|
||||
@@ -45,13 +45,15 @@ public class RiscontiService {
|
||||
Integer annoFine = AccountingBusinessLogic.getAnnoFisc(conn, dataFineComp);
|
||||
Integer annoDoc = AccountingBusinessLogic.getAnnoFisc(conn, dataDoc);
|
||||
|
||||
if (annoIniz.compareTo(annoFine) < 0 && annoDoc.compareTo(annoIniz) <= 0) {
|
||||
if (annoIniz.compareTo(annoFine) < 0 || annoDoc.compareTo(annoIniz) <= 0) {
|
||||
LocalDate dataInizCompMov = UtilityLocalDate.localDateFromDate(UtilityDate.dateAdd(Calendar.DATE, -1, dataInizComp));
|
||||
|
||||
LocalDate dataFineCompMov = UtilityLocalDate.localDateFromDate(dataFineComp);
|
||||
|
||||
long giorniTot = UtilityLocalDate.daysAfterDate(dataInizCompMov, dataFineCompMov);
|
||||
long giorniAnno = UtilityLocalDate.daysAfterDate(dataInizCompMov, UtilityLocalDate.localDateFromDate(periodoFiscInizComp.getDataFine()));
|
||||
long giorniAnno = 0;
|
||||
if (annoIniz.equals(annoDoc))
|
||||
giorniAnno = UtilityLocalDate.daysAfterDate(dataInizCompMov, UtilityLocalDate.localDateFromDate(periodoFiscInizComp.getDataFine()));
|
||||
importoCompetenza = importo.divide(new BigDecimal(giorniTot), 10, RoundingMode.HALF_UP).multiply(new BigDecimal(giorniAnno)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
@@ -60,7 +62,7 @@ public class RiscontiService {
|
||||
.setImportoCompetenza(importoCompetenza)
|
||||
.setImportoRisconto(impRisconto);
|
||||
|
||||
return riscontoDTO;
|
||||
return riscontoDTO;
|
||||
}
|
||||
public EntityBase creaMovGiroRisconti(Date dataReg, String causale) throws Exception {
|
||||
BigDecimal importoTotMov = BigDecimal.ZERO;
|
||||
|
||||
@@ -15,6 +15,7 @@ public class VariazioniPvInputDTO {
|
||||
private String tipoReport;
|
||||
private String inviaDisattivazioni;
|
||||
private String userName;
|
||||
private String oraInvioPrec;
|
||||
private List<VariazioniDettaglioDTO> variazioni;
|
||||
|
||||
public Date getDataValidita() {
|
||||
@@ -124,7 +125,14 @@ public class VariazioniPvInputDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOraInvioPrec() {
|
||||
return oraInvioPrec;
|
||||
}
|
||||
|
||||
public VariazioniPvInputDTO setOraInvioPrec(String oraInvioPrec) {
|
||||
this.oraInvioPrec = oraInvioPrec;
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
VARIAZIONI("V"),
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
@@ -667,6 +668,11 @@ public class VariazioniPvService {
|
||||
|
||||
String queryAssortimento = null;
|
||||
|
||||
LocalDateTime dataInvioPrec = null;
|
||||
if (!UtilityString.isNullOrEmpty(variazioniPvDTO.getOraInvioPrec() )){
|
||||
dataInvioPrec = UtilityLocalDate.addHourToLocalDate(LocalDate.now(), variazioniPvDTO.getOraInvioPrec());
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(variazioniPvDTO.getTipoReportEnum())) {
|
||||
throw new Exception("Tipo report non configurato");
|
||||
} else {
|
||||
@@ -699,6 +705,7 @@ public class VariazioniPvService {
|
||||
"WHERE vtb_list_data.data_iniz = '[DATA_VALIDITA]'\n" +
|
||||
" AND vtb_list_data.cod_vlis = '[COD_VLIS]'\n" +
|
||||
" AND vtb_list_data.cod_promo IS NULL\n" +
|
||||
(variazioniPvDTO.getOraInvioPrec() ==null?"":"AND mtb_lisv_data.data_agg_prz > " + UtilityDB.valueToString(dataInvioPrec)) +
|
||||
"UNION\n" +
|
||||
"SELECT vtb_list_data.cod_vlis,\n" +
|
||||
" mtb_lisv_data.cod_mart,\n" +
|
||||
@@ -716,6 +723,7 @@ public class VariazioniPvService {
|
||||
" mtb_lisv_data.cod_mart = vr.cod_mart\n" +
|
||||
"WHERE '[DATA_VALIDITA]' BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine\n" +
|
||||
" AND vtb_list_data.cod_vlis = '[COD_VLIS]'\n" +
|
||||
(variazioniPvDTO.getOraInvioPrec() ==null?"":"AND mtb_lisv_data.data_agg_prz > " + UtilityDB.valueToString(dataInvioPrec)) +
|
||||
"UNION\n" +
|
||||
"SELECT lisv.cod_vlis\n" +
|
||||
" , lisv.cod_mart\n" +
|
||||
@@ -1325,9 +1333,9 @@ public class VariazioniPvService {
|
||||
formatFile,
|
||||
Entity.json(variazioniPvInputDTO));
|
||||
|
||||
String emailForLog = setupGest.getExportSetup(multiDBTransactionManager.getPrimaryConnection(), exportType, formatFile, "EMAIL_FOR_LOG");
|
||||
String emailForLog = setupGest.getExportSetup(multiDBTransactionManager.getPrimaryConnection(), exportType, formatFile, "EMAIL_FOR_OK");
|
||||
int numVariazioni = variazioniPvInputDTO.getVariazioni().size();
|
||||
if (!UtilityString.isNullOrEmpty(emailForLog) && numVariazioni > 0) {
|
||||
if (!UtilityString.isNullOrEmpty(emailForLog) && numVariazioni > 0 ) {
|
||||
String oggetto =
|
||||
"Esportazione " +
|
||||
variazioniPvInputDTO.getTipoReportEnum().toString() +
|
||||
|
||||
@@ -92,9 +92,14 @@ public class GiacenzaService {
|
||||
sql += " AND mtb_depo.cod_mdep = " + UtilityDB.valueToString(codMdepParm);
|
||||
List<HashMap<String, Object>> datiDepo = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
List<String> depositiDisattivi = datiDepo.stream()
|
||||
.filter(x -> !((Boolean) x.get("flag_attivo"))).
|
||||
map(x -> (String) x.get("cod_mdep")).collect(Collectors.toList());
|
||||
List<String> depositiDisattivi = Collections.emptyList();
|
||||
if (datiDepo == null && !UtilityString.isNullOrEmpty(codMdepParm)) {
|
||||
depositiDisattivi.add(codMdepParm);
|
||||
} else {
|
||||
depositiDisattivi = datiDepo.stream()
|
||||
.filter(x -> !((Boolean) x.get("flag_attivo"))).
|
||||
map(x -> (String) x.get("cod_mdep")).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if (!depositiDisattivi.isEmpty() && emailDest != null) {
|
||||
String message = String.format("Attenzione sui seguenti depositi non è attiva la procedura di popolamento delle giancenze: %S",
|
||||
@@ -422,7 +427,6 @@ public class GiacenzaService {
|
||||
" INNER JOIN (" + queryArt + ") art on mtb_colr.cod_mart = art.cod_mart\n" +
|
||||
"WHERE mtb_colt.cod_dtip_provv = %s\n" +
|
||||
" AND mtb_colt.data_collo >= %s\n" +
|
||||
" AND mtb_colt.data_distribuzione is null \n" +
|
||||
" AND mtb_colt.cod_mdep = %s\n" +
|
||||
" AND exists (select * from carelli_giacenza_prog c where c.cod_mdep = mtb_colt.cod_mdep and c.cod_mart = art.cod_mart_mov and (c.data_reg < mtb_colt.data_ins or IsNull(tipo_car, 'G') = 'G' ))\n " +
|
||||
"GROUP BY art.cod_mart_mov, mtb_colt.data_ins",
|
||||
@@ -452,8 +456,6 @@ public class GiacenzaService {
|
||||
articoliSalvati.add(codMart);
|
||||
}
|
||||
carelliGiacenzaProgs.add(c);
|
||||
|
||||
|
||||
}
|
||||
saveEntity(carelliGiacenzaProgs);
|
||||
|
||||
@@ -474,7 +476,7 @@ public class GiacenzaService {
|
||||
.setDataDoc(UtilityLocalDate.localDateToDate(collo.getDataCollo()))
|
||||
.setDataDistribuzione(new Date());
|
||||
collo.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(collo, false, false, "", multiDBTransactionManager, RequestDataDTO.systemMockupData(),false, false);
|
||||
entityProcessor.processEntity(collo, false, false, "", multiDBTransactionManager, RequestDataDTO.systemMockupData(), false, false);
|
||||
UtilityEntity.throwEntityException(collo);
|
||||
}
|
||||
}
|
||||
@@ -652,7 +654,7 @@ public class GiacenzaService {
|
||||
" ON mtb_aart.cod_mart = mtb_comp.cod_mart) art\n" +
|
||||
" ON mtb_colr.cod_mart = art.cod_mart\n" +
|
||||
" WHERE mtb_colt.cod_dtip_provv = 'RGIAC'\n" +
|
||||
" AND mtb_colt.data_distribuzione IS NULL\n" +
|
||||
" and exists (select * from carelli_giacenza_prog c where c.cod_mdep = mtb_colt.cod_mdep and c.cod_mart = art.cod_mart_mov and (c.data_reg < mtb_colt.data_ins or IsNull(tipo_car, 'G') = 'G' ))\n" +
|
||||
" AND mtb_colt.cod_mdep IN (" + whereCond + ")\n" +
|
||||
" GROUP BY art.cod_mart_mov, mtb_colt.data_collo, data_ins),\n" +
|
||||
" selezione_giacenza AS (SELECT ISNULL(ip.cod_mart, gp.cod_mart) AS cod_mart,\n" +
|
||||
|
||||
@@ -137,7 +137,7 @@ public class WMSUtility {
|
||||
MtbDepoPosizioni.class);
|
||||
|
||||
|
||||
canBeDeleted = !currentPosizione.isFlagMonoCollo();
|
||||
canBeDeleted = currentPosizione == null || !currentPosizione.isFlagMonoCollo();
|
||||
}
|
||||
|
||||
return canBeDeleted;
|
||||
|
||||
@@ -327,6 +327,85 @@ public class WMSAccettazioneService {
|
||||
.setSavedMtbColr(targetMtbColr);
|
||||
}
|
||||
|
||||
public InsertUDCRowsResponseDTO insertUDCRows(InsertUDCRowsRequestDTO inputData) throws Exception {
|
||||
if (!userSession.isAttivo()) {
|
||||
throw new UsernameNotFoundException("Utente " + userSession.getUsername() + " non riconoscuto!");
|
||||
}
|
||||
|
||||
List<String> codMarts = inputData.getRows().stream()
|
||||
.map(InsertUDCRowRequestDTO::getCodMart)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<MtbAart> mtbAarts = productServices.getArticoliByCodMarts(codMarts);
|
||||
|
||||
MtbColt targetMtbColt = inputData.getTargetMtbColt();
|
||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(targetMtbColt, multiDBTransactionManager);
|
||||
|
||||
for (InsertUDCRowRequestDTO insertUDCRowRequestDTO : inputData.getRows()) {
|
||||
|
||||
final MtbColr targetMtbColr = new MtbColr()
|
||||
.setCausale(MtbColr.Causale.DEFAULT)
|
||||
.setPartitaMag(insertUDCRowRequestDTO.getPartitaMag())
|
||||
.setDataScadPartita(UtilityDate.toDate(insertUDCRowRequestDTO.getDataScad()))
|
||||
.setQtaCol(insertUDCRowRequestDTO.getQtaTot())
|
||||
.setQtaCnf(insertUDCRowRequestDTO.getQtaCnf())
|
||||
.setNumCnf(insertUDCRowRequestDTO.getNumCnf())
|
||||
.setCodJcom(insertUDCRowRequestDTO.getCodJcom())
|
||||
.setGestioneRif(insertUDCRowRequestDTO.getGestioneRif())
|
||||
.setUtente(userSession.getFullname())
|
||||
|
||||
.setDataOrd(insertUDCRowRequestDTO.getDataOrd())
|
||||
.setNumOrd(insertUDCRowRequestDTO.getNumOrd())
|
||||
.setRigaOrd(insertUDCRowRequestDTO.getRigaOrd())
|
||||
|
||||
.setDataDoc(UtilityDate.toDate(insertUDCRowRequestDTO.getDataDoc()))
|
||||
.setNumDoc(insertUDCRowRequestDTO.getNumDoc())
|
||||
.setCodDtipDoc(insertUDCRowRequestDTO.getCodDtip())
|
||||
.setSerDoc(insertUDCRowRequestDTO.getSerDoc())
|
||||
|
||||
.setDatetimeRow(UtilityLocalDate.getNowTime());
|
||||
|
||||
|
||||
if (insertUDCRowRequestDTO.getCodMart() != null) {
|
||||
MtbAart mtbAart = mtbAarts.stream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(insertUDCRowRequestDTO.getCodMart()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
if (mtbAart == null)
|
||||
throw new InvalidArticoloException(insertUDCRowRequestDTO.getCodMart());
|
||||
|
||||
targetMtbColr
|
||||
.setCodMart(mtbAart.getCodMart())
|
||||
.setDescrizione(mtbAart.getDescrizioneEstesa());
|
||||
} else {
|
||||
targetMtbColr
|
||||
.setCodBarre(insertUDCRowRequestDTO.getBarcode());
|
||||
}
|
||||
|
||||
if (insertUDCRowRequestDTO.getDescrizione() != null) {
|
||||
targetMtbColr
|
||||
.setDescrizione(insertUDCRowRequestDTO.getDescrizione())
|
||||
.setNote(insertUDCRowRequestDTO.getDescrizione());
|
||||
}
|
||||
|
||||
targetMtbColr.setOperation(OperationType.INSERT);
|
||||
targetMtbColt.getMtbColr().add(targetMtbColr);
|
||||
|
||||
}
|
||||
|
||||
targetMtbColt.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
targetMtbColt.getMtbColr()
|
||||
.forEach(x -> x.setOperation(OperationType.SELECT_OBJECT));
|
||||
|
||||
|
||||
return new InsertUDCRowsResponseDTO()
|
||||
.setSavedMtbColrs(targetMtbColt.getMtbColr());
|
||||
}
|
||||
|
||||
public EditUDCRowResponseDTO editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO) throws Exception {
|
||||
if (!userSession.isAttivo()) {
|
||||
throw new UsernameNotFoundException("Utente " + userSession.getUsername() + " non riconoscuto!");
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package it.integry.ems.retail.wms.dto;
|
||||
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InsertUDCRowsRequestDTO {
|
||||
|
||||
private MtbColt targetMtbColt;
|
||||
|
||||
private List<InsertUDCRowRequestDTO> rows;
|
||||
|
||||
public MtbColt getTargetMtbColt() {
|
||||
return targetMtbColt;
|
||||
}
|
||||
|
||||
public InsertUDCRowsRequestDTO setTargetMtbColt(MtbColt targetMtbColt) {
|
||||
this.targetMtbColt = targetMtbColt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<InsertUDCRowRequestDTO> getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public InsertUDCRowsRequestDTO setRows(List<InsertUDCRowRequestDTO> rows) {
|
||||
this.rows = rows;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package it.integry.ems.retail.wms.dto;
|
||||
|
||||
|
||||
import it.integry.ems_model.entity.MtbColr;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InsertUDCRowsResponseDTO {
|
||||
|
||||
private List<MtbColr> savedMtbColrs;
|
||||
|
||||
public List<MtbColr> getSavedMtbColrs() {
|
||||
return savedMtbColrs;
|
||||
}
|
||||
|
||||
public InsertUDCRowsResponseDTO setSavedMtbColrs(List<MtbColr> savedMtbColrs) {
|
||||
this.savedMtbColrs = savedMtbColrs;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ public class InsertUDSRowRequestDTO {
|
||||
private String codJcom;
|
||||
|
||||
private String contrassegnoDa;
|
||||
private String barcode;
|
||||
private String systemNote;
|
||||
|
||||
public MtbColr getSourceMtbColr() {
|
||||
return sourceMtbColr;
|
||||
@@ -143,4 +145,22 @@ public class InsertUDSRowRequestDTO {
|
||||
this.contrassegnoDa = contrassegnoDa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarcode() {
|
||||
return barcode;
|
||||
}
|
||||
|
||||
public InsertUDSRowRequestDTO setBarcode(String barcode) {
|
||||
this.barcode = barcode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSystemNote() {
|
||||
return systemNote;
|
||||
}
|
||||
|
||||
public InsertUDSRowRequestDTO setSystemNote(String systemNote) {
|
||||
this.systemNote = systemNote;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package it.integry.ems.retail.wms.dto;
|
||||
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InsertUDSRowsRequestDTO {
|
||||
|
||||
private MtbColt targetMtbColt;
|
||||
|
||||
private List<InsertUDSRowRequestDTO> rows;
|
||||
|
||||
public MtbColt getTargetMtbColt() {
|
||||
return targetMtbColt;
|
||||
}
|
||||
|
||||
public InsertUDSRowsRequestDTO setTargetMtbColt(MtbColt targetMtbColt) {
|
||||
this.targetMtbColt = targetMtbColt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<InsertUDSRowRequestDTO> getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public InsertUDSRowsRequestDTO setRows(List<InsertUDSRowRequestDTO> rows) {
|
||||
this.rows = rows;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package it.integry.ems.retail.wms.dto;
|
||||
|
||||
|
||||
import it.integry.ems_model.entity.MtbColr;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InsertUDSRowsResponseDTO {
|
||||
|
||||
private List<MtbColr> savedMtbColrs;
|
||||
|
||||
public List<MtbColr> getSavedMtbColrs() {
|
||||
return savedMtbColrs;
|
||||
}
|
||||
|
||||
public InsertUDSRowsResponseDTO setSavedMtbColrs(List<MtbColr> savedMtbColrs) {
|
||||
this.savedMtbColrs = savedMtbColrs;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ public class WMSLavorazioneService {
|
||||
.setSerCollo(insertUDSRowRequestDTO.getTargetMtbColt().getSerCollo())
|
||||
.setGestione(insertUDSRowRequestDTO.getTargetMtbColt().getGestione());
|
||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(targetMtbColt,true, multiDBTransactionManager);
|
||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
|
||||
MtbAart mtbAart = productServices.getArticoloByCodMart(insertUDSRowRequestDTO.getCodMart());
|
||||
@@ -341,6 +341,111 @@ public class WMSLavorazioneService {
|
||||
.setSavedMtbColr(targetMtbColr);
|
||||
}
|
||||
|
||||
|
||||
public InsertUDSRowsResponseDTO insertUDSRows(InsertUDSRowsRequestDTO inputData) throws Exception {
|
||||
if (!userSession.isAttivo()) {
|
||||
throw new UsernameNotFoundException("Utente " + userSession.getUsername() + " non riconosciuto!");
|
||||
}
|
||||
|
||||
List<String> codMarts = inputData.getRows().stream()
|
||||
.map(InsertUDSRowRequestDTO::getCodMart)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<MtbAart> mtbAarts = productServices.getArticoliByCodMarts(codMarts);
|
||||
|
||||
//Prendo solo la chiave
|
||||
MtbColt targetMtbColt = new MtbColt()
|
||||
.setNumCollo(inputData.getTargetMtbColt().getNumCollo())
|
||||
.setDataCollo(inputData.getTargetMtbColt().getDataCollo())
|
||||
.setSerCollo(inputData.getTargetMtbColt().getSerCollo())
|
||||
.setGestione(inputData.getTargetMtbColt().getGestione());
|
||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
|
||||
for (InsertUDSRowRequestDTO row : inputData.getRows()) {
|
||||
|
||||
MtbAart mtbAart = mtbAarts.stream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart()))
|
||||
.findFirst().orElse(null);
|
||||
if (mtbAart == null)
|
||||
throw new InvalidArticoloException(row.getCodMart());
|
||||
|
||||
MtbColrInfoProd mtbColrInfoProd = null;
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(row.getContrassegnoDa())) {
|
||||
mtbColrInfoProd = new MtbColrInfoProd()
|
||||
.setContrassegnoDa(row.getContrassegnoDa());
|
||||
mtbColrInfoProd.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
|
||||
final MtbColr targetMtbColr = new MtbColr()
|
||||
.setCausale(MtbColr.Causale.DEFAULT)
|
||||
.setCodMart(mtbAart.getCodMart())
|
||||
.setPartitaMag(row.getPartitaMag())
|
||||
.setDataScadPartita(row.getDataScad())
|
||||
.setQtaCol(row.getQtaTot())
|
||||
.setQtaCnf(row.getQtaCnf())
|
||||
.setNumCnf(row.getNumCnf())
|
||||
.setDescrizione(mtbAart.getDescrizioneEstesa())
|
||||
.setUtente(userSession.getFullname())
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(row.getDataOrd()))
|
||||
.setNumOrd(row.getNumOrd())
|
||||
.setRigaOrd(row.getRigaOrd())
|
||||
.setDatetimeRow(UtilityLocalDate.getNowTime())
|
||||
.setCodJcom(row.getCodJcom())
|
||||
.setMtbColrInfoProd(mtbColrInfoProd)
|
||||
.setCodBarre(row.getBarcode())
|
||||
.setSystemNote(row.getSystemNote());
|
||||
targetMtbColr.setOperation(OperationType.INSERT);
|
||||
targetMtbColt.getMtbColr().add(targetMtbColr);
|
||||
|
||||
if (row.getSourceMtbColr() != null) {
|
||||
MtbColr sourceMtbColr = row.getSourceMtbColr();
|
||||
|
||||
MtbColt sourceMtbColt = new MtbColt(
|
||||
sourceMtbColr.getGestione(),
|
||||
sourceMtbColr.getDataCollo(),
|
||||
sourceMtbColr.getNumCollo(),
|
||||
sourceMtbColr.getSerCollo());
|
||||
sourceMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(sourceMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(targetMtbColt.getCodTcol()) && !UtilityString.isNullOrEmpty(sourceMtbColt.getCodTcol()))
|
||||
targetMtbColt.setCodTcol(sourceMtbColt.getCodTcol());
|
||||
|
||||
targetMtbColr
|
||||
// .setCodJcom(UtilityString.emptyStr2Null(sourceMtbColr.getCodJcom()))
|
||||
.setSerColloRif(sourceMtbColr.getSerCollo())
|
||||
.setDataColloRif(UtilityLocalDate.localDateToDate(sourceMtbColr.getDataCollo()))
|
||||
.setNumColloRif(sourceMtbColr.getNumCollo())
|
||||
.setGestioneRif(sourceMtbColr.getGestione());
|
||||
|
||||
if (sourceMtbColr.getPesoNettoKg() != null) {
|
||||
//Proporzione
|
||||
BigDecimal pesoNettoKg = UtilityBigDecimal.divide(UtilityBigDecimal.multiply(row.getQtaTot(), sourceMtbColr.getPesoNettoKg()), sourceMtbColr.getQtaCol());
|
||||
targetMtbColr.setPesoNettoKg(pesoNettoKg);
|
||||
}
|
||||
|
||||
if (sourceMtbColr.getPesoLordoKg() != null) {
|
||||
//Proporzione
|
||||
BigDecimal pesoLordoKg = UtilityBigDecimal.divide(UtilityBigDecimal.multiply(row.getQtaTot(), sourceMtbColr.getPesoLordoKg()), sourceMtbColr.getQtaCol());
|
||||
targetMtbColr.setPesoLordoKg(pesoLordoKg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
targetMtbColt.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
targetMtbColt.getMtbColr().forEach(x -> x.setOperation(OperationType.SELECT_OBJECT));
|
||||
return new InsertUDSRowsResponseDTO()
|
||||
.setSavedMtbColrs(targetMtbColt.getMtbColr());
|
||||
}
|
||||
|
||||
public EditUDSRowResponseDTO editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO) throws Exception {
|
||||
if (!userSession.isAttivo()) {
|
||||
throw new UsernameNotFoundException("Utente " + userSession.getUsername() + " non riconosciuto!");
|
||||
@@ -573,6 +678,7 @@ public class WMSLavorazioneService {
|
||||
|
||||
udcMtbColt.setOnlyPkMaster(false);
|
||||
udcMtbColt.setOperation(OperationType.SELECT);
|
||||
udcMtbColt.setMtbCols(new ArrayList<>());
|
||||
return udcMtbColt;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package it.integry.ems.retail.wms.punti_vendita.controller;
|
||||
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.retail.wms.punti_vendita.service.WMSVerificaGiacenzeService;
|
||||
import it.integry.ems.retail.wms.vendita.dto.SaveNewVerificaRequestDTO;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@Scope("request")
|
||||
@RequestMapping("wms/pv/verifica_giacenze")
|
||||
public class WMSVerificaGiacenzeController {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private WMSVerificaGiacenzeService wmsVerificaGiacenzeService;
|
||||
|
||||
|
||||
@PostMapping(value = "save_new_verifica")
|
||||
public @ResponseBody
|
||||
ServiceRestResponse saveNewVerifica(@RequestBody SaveNewVerificaRequestDTO saveNewVerificaRequest) throws Exception {
|
||||
try {
|
||||
wmsVerificaGiacenzeService.saveNewVerifica(saveNewVerificaRequest);
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package it.integry.ems.retail.wms.punti_vendita.service;
|
||||
|
||||
import it.integry.ems.retail.wms.dto.CreateUDSRequestDTO;
|
||||
import it.integry.ems.retail.wms.dto.InsertUDSRowRequestDTO;
|
||||
import it.integry.ems.retail.wms.dto.InsertUDSRowsRequestDTO;
|
||||
import it.integry.ems.retail.wms.lavorazione.service.WMSLavorazioneService;
|
||||
import it.integry.ems.retail.wms.vendita.dto.SaveNewVerificaRequestDTO;
|
||||
import it.integry.ems.retail.wms.vendita.dto.VerificaGiacenzeDTO;
|
||||
import it.integry.ems.retail.wms.vendita.dto.VerificaGiacenzeRowDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class WMSVerificaGiacenzeService {
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
|
||||
@Autowired
|
||||
private WMSLavorazioneService wmsLavorazioneService;
|
||||
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
public void saveNewVerifica(SaveNewVerificaRequestDTO saveNewVerificaRequestDTO) throws Exception {
|
||||
String codDtipProvv = setupGest.getSetup("DATI_AZIENDA", "GIACENZA_DA_INV", "TIPO_DOC_RETT");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codDtipProvv)) {
|
||||
throw new Exception("Per poter effettuare la verifica delle giacenze è necessario configurare il tipo documento da utilizzare (cod_dtip_provv)");
|
||||
}
|
||||
|
||||
VerificaGiacenzeDTO inputData = saveNewVerificaRequestDTO.getData();
|
||||
|
||||
final MtbColt uds = wmsLavorazioneService.createUDS(new CreateUDSRequestDTO()
|
||||
.setCodMdep(inputData.getCodMdep())
|
||||
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO));
|
||||
|
||||
uds.setDataVers(inputData.getDataVerifica())
|
||||
.setCodDtipProvv(codDtipProvv)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
entityProcessor.processEntity(uds, true, multiDBTransactionManager);
|
||||
|
||||
InsertUDSRowsRequestDTO insertUDSRowRequest = new InsertUDSRowsRequestDTO()
|
||||
.setTargetMtbColt(uds)
|
||||
.setRows(new ArrayList<>());
|
||||
|
||||
for (VerificaGiacenzeRowDTO inputDataRow : inputData.getRows()) {
|
||||
InsertUDSRowRequestDTO request = new InsertUDSRowRequestDTO()
|
||||
.setCodMart(inputDataRow.getCodMart())
|
||||
.setPartitaMag(inputDataRow.getPartitaMag())
|
||||
.setQtaTot(inputDataRow.getQta())
|
||||
.setQtaCnf(inputDataRow.getQtaCnf())
|
||||
.setNumCnf(inputDataRow.getNumCnf())
|
||||
.setBarcode(inputDataRow.getBarcode());
|
||||
|
||||
if (inputDataRow.getQtaInGiacenza() != null) {
|
||||
request.setSystemNote(String.format("{\"giacenza\":%s}", inputDataRow.getQtaInGiacenza()));
|
||||
}
|
||||
|
||||
|
||||
insertUDSRowRequest.getRows().add(request);
|
||||
}
|
||||
|
||||
wmsLavorazioneService.insertUDSRows(insertUDSRowRequest);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package it.integry.ems.retail.wms.vendita.dto;
|
||||
|
||||
public class SaveNewVerificaRequestDTO {
|
||||
|
||||
private VerificaGiacenzeDTO data;
|
||||
|
||||
|
||||
public VerificaGiacenzeDTO getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public SaveNewVerificaRequestDTO setData(VerificaGiacenzeDTO data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package it.integry.ems.retail.wms.vendita.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public class VerificaGiacenzeDTO {
|
||||
|
||||
private String codMdep;
|
||||
private LocalDateTime dataVerifica;
|
||||
|
||||
private List<VerificaGiacenzeRowDTO> rows;
|
||||
|
||||
public String getCodMdep() {
|
||||
return codMdep;
|
||||
}
|
||||
|
||||
public VerificaGiacenzeDTO setCodMdep(String codMdep) {
|
||||
this.codMdep = codMdep;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataVerifica() {
|
||||
return dataVerifica;
|
||||
}
|
||||
|
||||
public VerificaGiacenzeDTO setDataVerifica(LocalDateTime dataVerifica) {
|
||||
this.dataVerifica = dataVerifica;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<VerificaGiacenzeRowDTO> getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public VerificaGiacenzeDTO setRows(List<VerificaGiacenzeRowDTO> rows) {
|
||||
this.rows = rows;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package it.integry.ems.retail.wms.vendita.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class VerificaGiacenzeRowDTO {
|
||||
|
||||
private String codMart;
|
||||
private String partitaMag;
|
||||
private BigDecimal qtaInGiacenza;
|
||||
private BigDecimal qta;
|
||||
private BigDecimal qtaCnf;
|
||||
private BigDecimal numCnf;
|
||||
private String barcode;
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public VerificaGiacenzeRowDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public VerificaGiacenzeRowDTO setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaInGiacenza() {
|
||||
return qtaInGiacenza;
|
||||
}
|
||||
|
||||
public VerificaGiacenzeRowDTO setQtaInGiacenza(BigDecimal qtaInGiacenza) {
|
||||
this.qtaInGiacenza = qtaInGiacenza;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQta() {
|
||||
return qta;
|
||||
}
|
||||
|
||||
public VerificaGiacenzeRowDTO setQta(BigDecimal qta) {
|
||||
this.qta = qta;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaCnf() {
|
||||
return qtaCnf;
|
||||
}
|
||||
|
||||
public VerificaGiacenzeRowDTO setQtaCnf(BigDecimal qtaCnf) {
|
||||
this.qtaCnf = qtaCnf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getNumCnf() {
|
||||
return numCnf;
|
||||
}
|
||||
|
||||
public VerificaGiacenzeRowDTO setNumCnf(BigDecimal numCnf) {
|
||||
this.numCnf = numCnf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarcode() {
|
||||
return barcode;
|
||||
}
|
||||
|
||||
public VerificaGiacenzeRowDTO setBarcode(String barcode) {
|
||||
this.barcode = barcode;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<Property name="logPattern">%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1.1.9}.java:%L %X{username} - %m%n</Property>
|
||||
<!-- Enhanced pattern to better show DEBUG information -->
|
||||
<Property name="consolePattern">
|
||||
[%highlight{%-5level}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=black, DEBUG=green bold, TRACE=blue}] %d{yyyy-MM-dd HH:mm:ss} %style{%c{1.}}{cyan}: %msg%n%throwable
|
||||
%d{yyyy-MM-dd HH:mm:ss} %style{%-40c{1.}}{cyan} %highlight{ %.-1p }{FATAL=bg_red blink black bold, ERROR=bg_red black, WARN=bright bg_yellow black, INFO=bg_green, DEBUG=bg_cyan black, TRACE=bg_white black} %highlight{%msg%n%throwable}{FATAL=red blink bold, ERROR=red, WARN=bright yellow, INFO=green, DEBUG=cyan, TRACE=white}
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user