Fix check licenza

This commit is contained in:
2025-10-23 13:36:09 +02:00
parent 74227e6bf1
commit d9d2b5bef7
4 changed files with 18 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
package it.integry.ems.license;
import it.integry.common.var.CommonConstants;
import it.integry.ems.javabeans.RequestDataDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@@ -11,6 +11,8 @@ import java.util.Random;
public class LicenseCheckInterceptor extends HandlerInterceptorAdapter {
@Autowired
private RequestDataDTO requestData;
@Autowired
private LicenseComponent licenseComponent;
@@ -20,12 +22,7 @@ public class LicenseCheckInterceptor extends HandlerInterceptorAdapter {
HttpServletResponse response, Object handler) {
String profileDB = null;
if (request != null && request.getQueryString() != null && request.getQueryString().contains(CommonConstants.PROFILE_DB)) {
profileDB = request.getParameter(CommonConstants.PROFILE_DB);
} else if (request != null && request.getHeader(CommonConstants.PROFILE_DB) != null) {
profileDB = request.getHeader(CommonConstants.PROFILE_DB);
}
String profileDB = requestData.getProfileDB();
LicenseStatusDTO licenseStatusDTO = null;
if (profileDB != null) licenseStatusDTO = licenseComponent.getLicenseStatus(profileDB);

View File

@@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
@Component
@@ -105,14 +106,19 @@ public class LicenseComponent {
} else {
List<LicenseStatusDTO> licenses = response.getDTO(new TypeReference<List<LicenseStatusDTO>>() {
});
if (licenses == null) return;
if (licenses == null || licenses.isEmpty()) return;
listAziende.forEach((key, value) -> {
cachedLicenseStatus.remove(key);
licenses.stream().filter(x -> x.getPartIva().equalsIgnoreCase(value))
.findFirst()
.ifPresent(license -> cachedLicenseStatus.put(key, license));
final Optional<LicenseStatusDTO> licenseSearch = licenses.stream().filter(x -> x.getPartIva().equalsIgnoreCase(value))
.findFirst();
if (licenseSearch.isPresent()) {
cachedLicenseStatus.put(key, licenseSearch.get());
} else {
cachedLicenseStatus.put(key, licenses.get(0));
}
});
}

View File

@@ -10,10 +10,13 @@ import java.util.Date;
public class LicenseStatusDTO {
@SqlField("part_iva")
private String partIva;
@SqlField("classe_merito")
private Quality quality;
@SqlField
private Status status;
@SqlField("data_scad_license")
private Date expiringDate;

View File

@@ -1915,7 +1915,7 @@ public class SystemService {
" ELSE 0 END AS status,\n" +
" CAST(gg_scoperto AS INT) AS gg_scoperto,\n" +
" data_scad_license,\n" +
" CAST(classe_merito AS INT) AS classe_merito\n" +
" IIF(CAST(classe_merito AS INT) > 0, 0, CAST(classe_merito AS INT)) AS classe_merito\n" +
"FROM (SELECT DISTINCT crl_part_iva_cod_fatt.part_iva,\n" +
" ISNULL(max(DATEDIFF(day, ctb_scad.data_scad, GETDATE()))\n" +
" OVER (PARTITION BY crl_part_iva_cod_fatt.cod_anag_fatt),\n" +