Fix errore null in getConsumiMedi
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:
@@ -150,7 +150,7 @@ public class MrpConsumiHandlerService {
|
||||
} else if (d.getKey().equals("S")) {
|
||||
queryconsumi = getQueryConsumiSettimanali(d.getValue(), d.getKey().toString(), whereCondDepo, codDtipMix);
|
||||
} else {
|
||||
throw new Exception(String.format("Tipo %s non contemplato"));
|
||||
throw new Exception(String.format("Tipo %s non contemplato", d.getKey()));
|
||||
}
|
||||
|
||||
List<MRPDailyConsumiDTO> c = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), queryconsumi, MRPDailyConsumiDTO.class);
|
||||
@@ -243,11 +243,8 @@ public class MrpConsumiHandlerService {
|
||||
if (!saveCache()) {
|
||||
return getConsumi(multiDBTransactionManager);
|
||||
} else {
|
||||
HashMap<String, HashMap<String, Map<String, List<MRPDailyConsumiDTO>>>> inputMap = consumiCachedData;
|
||||
new ArrayList<>();
|
||||
|
||||
String dbName = multiDBTransactionManager.getPrimaryDatasource().getDbName();
|
||||
Map<String, List<MRPDailyConsumiDTO>> consumiList = getSectionConsumiByDBName(inputMap, dbName).get(dbName);
|
||||
Map<String, List<MRPDailyConsumiDTO>> consumiList = getSectionConsumiByDBName(consumiCachedData, dbName).get(dbName);
|
||||
if (consumiList == null)
|
||||
return getConsumi(multiDBTransactionManager);
|
||||
return consumiList;
|
||||
|
||||
@@ -41,11 +41,11 @@ public class MrpDailyMaterialReqService {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private final String gestName = "PVM";
|
||||
private final String section = "MRP";
|
||||
private static final String GEST_NAME = "PVM";
|
||||
private static final String SECTION = "MRP";
|
||||
|
||||
public List<MrpDailyMaterialReqDTO> mrpDailyMaterialReq(MrpDailyMaterialInputDTO mrpDailyMaterialInputDTO, boolean loadDetails, boolean includiArrivi, String userName) throws Exception {
|
||||
HashMap<String, String> setupSection = setupGest.getSetupSection(multiDBTransactionManager.getPrimaryConnection(), gestName, section);
|
||||
HashMap<String, String> setupSection = setupGest.getSetupSection(multiDBTransactionManager.getPrimaryConnection(), GEST_NAME, SECTION);
|
||||
List<MRPDailySetupGruppiDTO> setupGruppi = mrpSetupHandlerService.getSetupGruppi();
|
||||
List<MRPDailySetupSottogruppiDTO> setupSottogruppi = mrpSetupHandlerService.getSetupSottogruppi();
|
||||
String depositi = getElencoDepositi(mrpDailyMaterialInputDTO, setupSection);
|
||||
@@ -321,16 +321,19 @@ public class MrpDailyMaterialReqService {
|
||||
|
||||
private static BigDecimal getConsumiMedi(List<MRPDailyConsumiDTO> consumiArt, List<MRPDailySetupSottogruppiDTO> setupNumAvg, MrpDailyMaterialReqDTO art) {
|
||||
List<Integer> numAvg = getNumAvg(setupNumAvg, art.getCodMgrp(), art.getCodMsgr());
|
||||
BigDecimal consumiMedi;
|
||||
|
||||
if (consumiArt == null) {
|
||||
consumiArt = new ArrayList<>();
|
||||
}
|
||||
|
||||
consumiArt = Stream.of(consumiArt)
|
||||
.sorted(Comparator.comparing(MRPDailyConsumiDTO::getData, Comparator.reverseOrder()))
|
||||
.toList();
|
||||
|
||||
consumiMedi = BigDecimal.valueOf(
|
||||
return BigDecimal.valueOf(
|
||||
Stream.of(consumiArt.subList(numAvg.get(0), Math.min(numAvg.get(1), consumiArt.size() - 1)))
|
||||
.map(MRPDailyConsumiDTO::getQta)
|
||||
.collect(Collectors.averagingDouble(BigDecimal::doubleValue)));
|
||||
return consumiMedi;
|
||||
}
|
||||
|
||||
private String getElencoDepositi(MrpDailyMaterialInputDTO mrpDailyMaterialInputDTO, HashMap<String, String> setupSection) throws Exception {
|
||||
@@ -383,7 +386,7 @@ public class MrpDailyMaterialReqService {
|
||||
|
||||
private List<MrpDailyMaterialReqDTO> getElencoArticoli(MrpDailyMaterialInputDTO mrpDailyMaterialInputDTO, String depositi, String userName, boolean loadDetails) throws Exception {
|
||||
|
||||
String whereCondUser = setupGest.getSetupUserWeb(multiDBTransactionManager.getPrimaryConnection(), gestName, section, "WHERECOND_ARTICOLI", userName);
|
||||
String whereCondUser = setupGest.getSetupUserWeb(multiDBTransactionManager.getPrimaryConnection(), GEST_NAME, SECTION, "WHERECOND_ARTICOLI", userName);
|
||||
|
||||
String sql = String.format(
|
||||
"SELECT mtb_aart.cod_mart,\n" +
|
||||
|
||||
Reference in New Issue
Block a user