| Line 69... |
Line 69... |
| 69 |
import java.time.format.DateTimeFormatter;
|
69 |
import java.time.format.DateTimeFormatter;
|
| 70 |
import java.time.temporal.TemporalAdjusters;
|
70 |
import java.time.temporal.TemporalAdjusters;
|
| 71 |
import java.util.*;
|
71 |
import java.util.*;
|
| 72 |
import java.util.Map.Entry;
|
72 |
import java.util.Map.Entry;
|
| 73 |
import java.util.stream.Collectors;
|
73 |
import java.util.stream.Collectors;
|
| - |
|
74 |
import java.util.stream.Stream;
|
| 74 |
|
75 |
|
| 75 |
@Controller
|
76 |
@Controller
|
| 76 |
@Transactional(rollbackFor = Throwable.class)
|
77 |
@Transactional(rollbackFor = Throwable.class)
|
| 77 |
public class LeadController {
|
78 |
public class LeadController {
|
| 78 |
private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
|
79 |
private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
|
| Line 689... |
Line 690... |
| 689 |
@RequestMapping(value = "/downloadDateWiseLead", method = RequestMethod.GET)
|
690 |
@RequestMapping(value = "/downloadDateWiseLead", method = RequestMethod.GET)
|
| 690 |
public ResponseEntity<?> getdownloadLeadDataByDate(HttpServletRequest request,
|
691 |
public ResponseEntity<?> getdownloadLeadDataByDate(HttpServletRequest request,
|
| 691 |
@RequestParam(name = "leadStatus", required = false, defaultValue = "All") List<LeadStatus> leadStatus,
|
692 |
@RequestParam(name = "leadStatus", required = false, defaultValue = "All") List<LeadStatus> leadStatus,
|
| 692 |
@RequestParam(name = "color", required = false, defaultValue = "All") List<String> color,
|
693 |
@RequestParam(name = "color", required = false, defaultValue = "All") List<String> color,
|
| 693 |
@RequestParam(name = "startDate", required = false) LocalDate startDate,
|
694 |
@RequestParam(name = "startDate", required = false) LocalDate startDate,
|
| 694 |
@RequestParam(name = "endDate", required = false) LocalDate endDate) throws Exception {
|
695 |
@RequestParam(name = "endDate", required = false) LocalDate endDate,
|
| - |
|
696 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm) throws Exception {
|
| 695 |
|
697 |
|
| 696 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
698 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 697 |
String emailId = fofoDetails.getEmailId();
|
699 |
String emailId = fofoDetails.getEmailId();
|
| 698 |
LocalDateTime startDateTime = startDate != null ? startDate.atStartOfDay() : null;
|
700 |
LocalDateTime startDateTime = startDate != null ? startDate.atStartOfDay() : null;
|
| 699 |
LocalDateTime endDateTime = endDate != null ? endDate.atTime(23, 59, 59) : null;
|
701 |
LocalDateTime endDateTime = endDate != null ? endDate.atTime(23, 59, 59) : null;
|
| Line 775... |
Line 777... |
| 775 |
.collect(Collectors.toMap(AuthUser::getId, x -> x));
|
777 |
.collect(Collectors.toMap(AuthUser::getId, x -> x));
|
| 776 |
}
|
778 |
}
|
| 777 |
|
779 |
|
| 778 |
// Build CSV rows (USE DIRECT LEAD PROPERTIES - NO ACTIVITY FALLBACK)
|
780 |
// Build CSV rows (USE DIRECT LEAD PROPERTIES - NO ACTIVITY FALLBACK)
|
| 779 |
List<List<?>> rows = new ArrayList<>();
|
781 |
List<List<?>> rows = new ArrayList<>();
|
| - |
|
782 |
// Mirror the on-screen table's search box: keep only leads whose exported fields contain the term,
|
| - |
|
783 |
// so the CSV matches what the user is looking at.
|
| - |
|
784 |
if (searchTerm != null && !searchTerm.trim().isEmpty()) {
|
| - |
|
785 |
String term = searchTerm.trim().toLowerCase();
|
| - |
|
786 |
leads = leads.stream().filter(l -> Stream.of(l.getId(), l.getSource(), l.getFullName(), l.getOutLetName(),
|
| - |
|
787 |
l.getLeadMobile(), l.getAddress(), l.getCity(), l.getState(), l.getCreatedBy(), l.getStatus(), l.getColor())
|
| - |
|
788 |
.anyMatch(v -> v != null && String.valueOf(v).toLowerCase().contains(term)))
|
| - |
|
789 |
.collect(Collectors.toList());
|
| - |
|
790 |
}
|
| - |
|
791 |
|
| 780 |
for (Lead lead : leads) {
|
792 |
for (Lead lead : leads) {
|
| 781 |
List<LeadActivity> activities = leadActivityMap.get(lead.getId());
|
793 |
List<LeadActivity> activities = leadActivityMap.get(lead.getId());
|
| 782 |
|
794 |
|
| 783 |
// Use FIRST activity's schedule timestamp if exists
|
795 |
// Use FIRST activity's schedule timestamp if exists
|
| 784 |
String scheduleTimestamp = (activities != null && !activities.isEmpty())
|
796 |
String scheduleTimestamp = (activities != null && !activities.isEmpty())
|