Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
9.3 kB
1
Indexable
Never
Index: api-model/src/main/java/com/penske/ce2/model/export/enumtypes/Column.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/api-model/src/main/java/com/penske/ce2/model/export/enumtypes/Column.java b/api-model/src/main/java/com/penske/ce2/model/export/enumtypes/Column.java
--- a/api-model/src/main/java/com/penske/ce2/model/export/enumtypes/Column.java	(revision ff44414a2251f43d3ee9fb8b825bbbd84dabd4b5)
+++ b/api-model/src/main/java/com/penske/ce2/model/export/enumtypes/Column.java	(date 1646737559489)
@@ -1,5 +1,10 @@
 package com.penske.ce2.model.export.enumtypes;
 
+import com.penske.ce2.model.fleet.FleetSummary;
+
+import java.util.List;
+import java.util.function.Function;
+
 import static com.penske.ce2.model.export.enumtypes.CellCustomType.CURRENCY;
 import static com.penske.ce2.model.export.enumtypes.CellCustomType.WRAP_TEXT;
 
@@ -90,7 +95,10 @@
     INVOICE_TOTAL("INVOICE TOTAL"),
     INVOICE_TYPE("INVOICE TYPE"),
     IN_APP("IN-APP"),
-    IN_SERVICE_DATE("IN SERVICE DATE"),
+    IN_SERVICE_DATE("IN SERVICE DATE", (ob)
+        -> {List<FleetSummary> list = (List<FleetSummary>) ob;
+    return list.stream().allMatch(lineItem -> lineItem.getStatus().equals("ORDERED") );
+    }),
     LAST_LOGGED_IN("LAST LOGGED IN"),
     LAST_MILEAGE_READING("LAST MILEAGE READING"),
     LAST_NAME("LAST NAME"),
@@ -198,10 +206,15 @@
 
     private String columnName;
     private CellCustomType cellCustomType;
+    private Function<Object, Boolean> function;
 
     Column(String columnName) {
         this.columnName = columnName;
     }
+    Column(String columnName, Function<Object, Boolean> function) {
+        this.columnName = columnName;
+        this.function = function;
+    }
     Column(String columnName, CellCustomType cellCustomType) {
         this.columnName = columnName;
         this.cellCustomType = cellCustomType;
@@ -214,4 +227,8 @@
     public CellCustomType getCellCustomType() {
         return cellCustomType;
     }
+
+    public Function<Object, Boolean> getFunction() {
+        return function;
+    }
 }
Index: api-services/src/main/java/com/penske/ce2/service/export/Exporter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/api-services/src/main/java/com/penske/ce2/service/export/Exporter.java b/api-services/src/main/java/com/penske/ce2/service/export/Exporter.java
--- a/api-services/src/main/java/com/penske/ce2/service/export/Exporter.java	(revision ff44414a2251f43d3ee9fb8b825bbbd84dabd4b5)
+++ b/api-services/src/main/java/com/penske/ce2/service/export/Exporter.java	(date 1646737559471)
@@ -4,12 +4,14 @@
 import com.penske.ce2.model.export.enumtypes.CellCustomType;
 import com.penske.ce2.model.export.enumtypes.Column;
 import com.penske.ce2.model.export.enumtypes.ManageColumnPageTab;
+import com.penske.ce2.model.fleet.FleetSummary;
 import com.penske.ce2.service.ManageColumnService;
 import com.penske.ce2.service.attachment.AttachmentFileService;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.List;
+import java.util.Objects;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -29,6 +31,7 @@
 
 import lombok.extern.slf4j.Slf4j;
 
+import static java.util.Objects.nonNull;
 import static org.apache.commons.lang3.StringUtils.isBlank;
 import static org.springframework.http.MediaType.parseMediaType;
 
@@ -46,19 +49,24 @@
     @Autowired
     AttachmentFileService attachmentFileService;
 
-
     @Autowired
     protected ManageColumnService manageColumnService;
 
+    @Autowired
+    protected Boolean removeInServiceDateColumn;
+
     abstract Function<T, String> getValueByColumnFunction(Column columnType);
 
     abstract List<Column> getColumnsByTabType(TabType tabType);
 
     protected List<Column> getColumnsByTabType(TabType tabType, boolean downloadAllAvailableColumns) {
+        List<Column> columns;
         if (downloadAllAvailableColumns) {
-            return getColumnsByTabType(tabType);
+            columns = getColumnsByTabType(tabType);
+        } else {
+            columns = manageColumnService.getUserDefinedColumnsByTab(tabType.getManageColumnValue());
         }
-        return manageColumnService.getUserDefinedColumnsByTab(tabType.getManageColumnValue());
+        return columns;
     }
 
     abstract String getFileName(TabType tabType) ;
@@ -83,7 +91,9 @@
 
     byte[] toXls(List<T> lineItems, TabType tabType, boolean downloadAllAvailableColumns) {
         List<Column> columnsByOrder = getColumnsByTabType(tabType, downloadAllAvailableColumns);
-
+        if (tabType == TabType.LEASE) {
+            columnsByOrder.removeIf(column -> nonNull(column.getFunction()) && column.getFunction().apply(tabType));
+        }
         SXSSFWorkbook workbook = getHeaderWorkBook(getColumnNames(columnsByOrder), getSheetName());
         SXSSFSheet sheet = workbook.getSheet(getSheetName());
         sheet.trackAllColumnsForAutoSizing();
Index: api-services/src/main/java/com/penske/ce2/service/export/ColumnsToExclude.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/api-services/src/main/java/com/penske/ce2/service/export/ColumnsToExclude.java b/api-services/src/main/java/com/penske/ce2/service/export/ColumnsToExclude.java
new file mode 100644
--- /dev/null	(date 1646649039409)
+++ b/api-services/src/main/java/com/penske/ce2/service/export/ColumnsToExclude.java	(date 1646649039409)
@@ -0,0 +1,13 @@
+package com.penske.ce2.service.export;
+
+import lombok.Data;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.annotation.RequestScope;
+
+
+@Data
+@Component
+@RequestScope
+public class ColumnsToExclude {
+    private Boolean removeInServiceDateColumn = false;
+}
Index: api-services/src/main/java/com/penske/ce2/service/browse/units/BrowseUnitsApiService.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/api-services/src/main/java/com/penske/ce2/service/browse/units/BrowseUnitsApiService.java b/api-services/src/main/java/com/penske/ce2/service/browse/units/BrowseUnitsApiService.java
--- a/api-services/src/main/java/com/penske/ce2/service/browse/units/BrowseUnitsApiService.java	(revision ff44414a2251f43d3ee9fb8b825bbbd84dabd4b5)
+++ b/api-services/src/main/java/com/penske/ce2/service/browse/units/BrowseUnitsApiService.java	(date 1646649039386)
@@ -67,6 +67,7 @@
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.tuple.MutablePair;
 import org.apache.commons.lang3.tuple.Pair;
@@ -91,14 +92,14 @@
 import static java.util.stream.Collectors.groupingBy;
 import static java.util.stream.Collectors.joining;
 import static java.util.stream.Collectors.mapping;
-import static org.apache.commons.collections4.CollectionUtils.isEmpty;
-import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;
+import static org.apache.commons.collections4.CollectionUtils.*;
 
 @Slf4j
 @Service
 @RequiredArgsConstructor
 public class BrowseUnitsApiService implements BrowseUnitsApiInterface {
 
+    public static final List<String> STATUSES_FOR_WHICH_IN_SERVICE_DATE_MUST_BE_REMOVED = asList("WIP", "ORDERED", "ACCRUED");
     private final BrowseUnitsCMLeaseExporter browseUnitsCMLeaseExporter;
     private final BrowseUnitsMapper browseUnitsMapper;
     private final BrowseUnitsRentalExporter browseUnitsRentalExporter;
@@ -385,6 +386,8 @@
 
         iterateTrucksInfo(units, FleetSummary::getVin, this::updateCmLeaseConnectedAssetInfo);
 
+        boolean removeInServiceDateColumn = isNotEmpty(request.getStatuses()) && containsAll(STATUSES_FOR_WHICH_IN_SERVICE_DATE_MUST_BE_REMOVED, request.getStatuses());
+
         return browseUnitsCMLeaseExporter.buildXlsFile(units, tabType, downloadAllAvailableColumns);
     }
 
Index: api-services/src/main/java/com/penske/ce2/service/export/BrowseUnitsCMLeaseExporter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/api-services/src/main/java/com/penske/ce2/service/export/BrowseUnitsCMLeaseExporter.java b/api-services/src/main/java/com/penske/ce2/service/export/BrowseUnitsCMLeaseExporter.java
--- a/api-services/src/main/java/com/penske/ce2/service/export/BrowseUnitsCMLeaseExporter.java	(revision ff44414a2251f43d3ee9fb8b825bbbd84dabd4b5)
+++ b/api-services/src/main/java/com/penske/ce2/service/export/BrowseUnitsCMLeaseExporter.java	(date 1646737151012)
@@ -91,7 +91,6 @@
         fileNames.put(CONTRACT_MAINTENANCE, CONTRACT_MAINTENANCE_FILE_NAME);
         fileNames.put(LEASE_AND_CM, LEASE_AND_CM_FILE_NAME);
         fileNames.put(CM_AND_LEASE, CM_AND_LEASE_FILE_NAME);
-        fileNames.put(CM_AND_LEASE, CM_AND_LEASE_FILE_NAME);
     }
 
     @Override