| Line 27... |
Line 27... |
| 27 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
27 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 28 |
import com.spice.profitmandi.service.AuthService;
|
28 |
import com.spice.profitmandi.service.AuthService;
|
| 29 |
import com.spice.profitmandi.service.PartnerCollectionService;
|
29 |
import com.spice.profitmandi.service.PartnerCollectionService;
|
| 30 |
import com.spice.profitmandi.service.RbmTargetService;
|
30 |
import com.spice.profitmandi.service.RbmTargetService;
|
| 31 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
31 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| - |
|
32 |
import com.spice.profitmandi.service.order.OrderService;
|
| 32 |
import com.spice.profitmandi.service.user.RetailerService;
|
33 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 33 |
import com.spice.profitmandi.web.model.LoginDetails;
|
34 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 34 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
35 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 35 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
36 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 36 |
import org.apache.commons.csv.CSVRecord;
|
37 |
import org.apache.commons.csv.CSVRecord;
|
| Line 137... |
Line 138... |
| 137 |
@Autowired
|
138 |
@Autowired
|
| 138 |
private ResponseSender<?> responseSender;
|
139 |
private ResponseSender<?> responseSender;
|
| 139 |
|
140 |
|
| 140 |
@Autowired
|
141 |
@Autowired
|
| 141 |
private BrandsService brandsService;
|
142 |
private BrandsService brandsService;
|
| - |
|
143 |
@Autowired
|
| - |
|
144 |
OrderService orderService;
|
| 142 |
|
145 |
|
| 143 |
List<LeadStatus> status = Arrays.asList(LeadStatus.notInterested, LeadStatus.finalized);
|
146 |
List<LeadStatus> status = Arrays.asList(LeadStatus.notInterested, LeadStatus.finalized);
|
| 144 |
|
147 |
|
| 145 |
@RequestMapping(value = "/getOpenLead", method = RequestMethod.GET)
|
148 |
@RequestMapping(value = "/getOpenLead", method = RequestMethod.GET)
|
| 146 |
public String getOpenLead(HttpServletRequest request, @RequestParam(name = "leadStatus", required = false, defaultValue = "All") List<LeadStatus> leadStatus, @RequestParam(name = "color", required = false, defaultValue = "All") List<String> color, @RequestParam(name = "leadDate", required = false, defaultValue = "") LocalDate leadDate, Model model) throws Exception {
|
149 |
public String getOpenLead(HttpServletRequest request, @RequestParam(name = "leadStatus", required = false, defaultValue = "All") List<LeadStatus> leadStatus, @RequestParam(name = "color", required = false, defaultValue = "All") List<String> color, @RequestParam(name = "leadDate", required = false, defaultValue = "") LocalDate leadDate, Model model) throws Exception {
|
| Line 448... |
Line 451... |
| 448 |
cm.setOptions(om);
|
451 |
cm.setOptions(om);
|
| 449 |
|
452 |
|
| 450 |
return cm;
|
453 |
return cm;
|
| 451 |
}
|
454 |
}
|
| 452 |
|
455 |
|
| - |
|
456 |
@RequestMapping(value = "/downloadDateWiseLead", method = RequestMethod.GET)
|
| - |
|
457 |
public ResponseEntity<?> getdownloadLeadDataByDate(HttpServletRequest request, @RequestParam(name = "leadStatus", required = false, defaultValue = "All") List<LeadStatus> leadStatus, @RequestParam(name = "color", required = false, defaultValue = "All") List<String> color, @RequestParam(name = "leadDate", required = false, defaultValue = "") LocalDate leadDate, Model model) throws Exception {
|
| - |
|
458 |
|
| - |
|
459 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
460 |
String emailId = fofoDetails.getEmailId();
|
| - |
|
461 |
LocalDateTime localDateTime = null;
|
| - |
|
462 |
if (leadDate != null) {
|
| - |
|
463 |
localDateTime = leadDate.atStartOfDay();
|
| - |
|
464 |
}
|
| - |
|
465 |
List<Lead> leads = new ArrayList<>();
|
| - |
|
466 |
|
| - |
|
467 |
AuthUser authUser = authRepository.selectByEmailOrMobile(emailId);
|
| - |
|
468 |
|
| - |
|
469 |
model.addAttribute("colors", color);
|
| - |
|
470 |
|
| - |
|
471 |
Map<Integer, List<LeadActivity>> leadActivityMap = new HashMap<>();
|
| - |
|
472 |
boolean authPositon = positionRepository.hasCategory(authUser.getId(), ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
| - |
|
473 |
List<Integer> authUserIds = null;
|
| - |
|
474 |
|
| - |
|
475 |
LOGGER.info("color111" + color);
|
| - |
|
476 |
|
| - |
|
477 |
List<Lead> leadFollowUp = new ArrayList<>();
|
| - |
|
478 |
|
| - |
|
479 |
if (authPositon) {
|
| - |
|
480 |
authUserIds = authService.getAllReportees(authUser.getId());
|
| - |
|
481 |
authUserIds.add(authUser.getId());
|
| - |
|
482 |
LOGGER.info("authIds" + authUserIds);
|
| - |
|
483 |
|
| - |
|
484 |
LOGGER.info("leadStatus" + leadStatus);
|
| - |
|
485 |
|
| - |
|
486 |
if (localDateTime == null) {
|
| - |
|
487 |
|
| - |
|
488 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| - |
|
489 |
|
| - |
|
490 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds, color, LocalDateTime.now().minusMonths(1));
|
| - |
|
491 |
}
|
| - |
|
492 |
|
| - |
|
493 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
| - |
|
494 |
leadFollowUp = leadRepository.selectByAssignAuthIdsAndStatus(authUserIds, LeadStatus.followUp);
|
| - |
|
495 |
leads.addAll(leadFollowUp);
|
| - |
|
496 |
}
|
| - |
|
497 |
|
| - |
|
498 |
} else {
|
| - |
|
499 |
|
| - |
|
500 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| - |
|
501 |
|
| - |
|
502 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds, color, localDateTime);
|
| - |
|
503 |
}
|
| - |
|
504 |
|
| - |
|
505 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
| - |
|
506 |
|
| - |
|
507 |
leadFollowUp = leadRepository.selectByAssignAuthIdsAndStatus(authUserIds, LeadStatus.followUp);
|
| - |
|
508 |
|
| - |
|
509 |
leads.addAll(leadFollowUp);
|
| - |
|
510 |
|
| - |
|
511 |
}
|
| - |
|
512 |
|
| - |
|
513 |
}
|
| - |
|
514 |
|
| - |
|
515 |
} else {
|
| - |
|
516 |
|
| - |
|
517 |
if (localDateTime == null) {
|
| - |
|
518 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| - |
|
519 |
|
| - |
|
520 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestamp(leadStatus, color, LocalDateTime.now().minusMonths(1));
|
| - |
|
521 |
}
|
| - |
|
522 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
| - |
|
523 |
|
| - |
|
524 |
leadFollowUp = leadRepository.selectAllByStatus(LeadStatus.followUp);
|
| - |
|
525 |
|
| - |
|
526 |
leads.addAll(leadFollowUp);
|
| - |
|
527 |
}
|
| - |
|
528 |
LOGGER.info("leadlocalDateTime1" + leads);
|
| - |
|
529 |
|
| - |
|
530 |
} else {
|
| - |
|
531 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| - |
|
532 |
|
| - |
|
533 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestamp(leadStatus, color, localDateTime);
|
| - |
|
534 |
}
|
| - |
|
535 |
|
| - |
|
536 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
| - |
|
537 |
|
| - |
|
538 |
leadFollowUp = leadRepository.selectAllByStatus(LeadStatus.followUp);
|
| - |
|
539 |
|
| - |
|
540 |
leads.addAll(leadFollowUp);
|
| - |
|
541 |
}
|
| - |
|
542 |
LOGGER.info("leadlocalDateTime2" + leads);
|
| - |
|
543 |
|
| - |
|
544 |
}
|
| - |
|
545 |
|
| - |
|
546 |
}
|
| - |
|
547 |
leadActivityMap = leadActivityRepository.selectAllByleadIds(leads.stream().map(x -> x.getId()).collect(Collectors.toList())).stream().collect(Collectors.groupingBy(LeadActivity::getLeadId, Collectors.toList()));
|
| - |
|
548 |
List<Integer> authIds = new ArrayList<>();
|
| - |
|
549 |
if (!leads.isEmpty()) {
|
| - |
|
550 |
authIds.addAll(leads.stream().map(x -> x.getAssignTo()).collect(Collectors.toList()));
|
| - |
|
551 |
}
|
| - |
|
552 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
553 |
List<List<?>> rows = new ArrayList<>();
|
| - |
|
554 |
for (Lead lead : leads) {
|
| - |
|
555 |
List<LeadActivity> activities = leadActivityMap.get(lead.getId());
|
| - |
|
556 |
String scheduleTimestamp = (activities != null && !activities.isEmpty())
|
| - |
|
557 |
? FormattingUtils.format(activities.get(0).getSchelduleTimestamp())
|
| - |
|
558 |
: null;
|
| - |
|
559 |
Double potental = 0d;
|
| - |
|
560 |
String outLetName = "";
|
| - |
|
561 |
|
| - |
|
562 |
if (lead.getPotential() >= 0) {
|
| - |
|
563 |
potental = lead.getPotential();
|
| - |
|
564 |
} else if (activities != null && !activities.isEmpty()) {
|
| - |
|
565 |
potental = activities.get(0).getPotential();
|
| - |
|
566 |
} else potental = 0d;
|
| - |
|
567 |
|
| - |
|
568 |
if (lead.getOutLetName() != null) {
|
| - |
|
569 |
outLetName = lead.getOutLetName();
|
| - |
|
570 |
} else if (activities != null && !activities.isEmpty()) {
|
| - |
|
571 |
outLetName = activities.get(0).getOutletName();
|
| - |
|
572 |
} else outLetName = "-";
|
| - |
|
573 |
|
| - |
|
574 |
String assignTo = "-";
|
| - |
|
575 |
if (authIdAndAuthUserMap.get(lead.getAssignTo()) != null) {
|
| - |
|
576 |
assignTo = authIdAndAuthUserMap.get(lead.getAssignTo()).getFirstName() + " " + authIdAndAuthUserMap.get(lead.getAssignTo()).getLastName();
|
| - |
|
577 |
} else assignTo = "-";
|
| - |
|
578 |
|
| - |
|
579 |
rows.add(Arrays.asList(lead.getSource(), lead.getFullName(), outLetName, potental, lead.getLeadMobile(),
|
| - |
|
580 |
lead.getAddress(), lead.getCity(), lead.getState(), lead.getCreatedBy(), lead.getStatus(),
|
| - |
|
581 |
FormattingUtils.format(lead.getCreatedTimestamp()), FormattingUtils.format(lead.getUpdatedTimestamp()), scheduleTimestamp, FormattingUtils.format(lead.getClosureTimestamp()), assignTo, lead.getColor()));
|
| - |
|
582 |
}
|
| - |
|
583 |
// #if($leadActivityMap.get($lead.getId()).get(0).getSchelduleTimestamp())
|
| - |
|
584 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| - |
|
585 |
Arrays.asList("Source", "Partner Name", "Outlet Name", "Potential", "Mobile", "Address", "City", "State",
|
| - |
|
586 |
"Created By", "Status", "Created On", "Updated On", "Scheduled Timestamp", "Closure Timestamp", "Assign To", "Color"
|
| - |
|
587 |
),
|
| - |
|
588 |
rows);
|
| - |
|
589 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Lead Details ");
|
| - |
|
590 |
return responseEntity;
|
| - |
|
591 |
|
| - |
|
592 |
}
|
| - |
|
593 |
|
| 453 |
|
594 |
|
| 454 |
@RequestMapping(value = "/getClosedLead", method = RequestMethod.GET)
|
595 |
@RequestMapping(value = "/getClosedLead", method = RequestMethod.GET)
|
| 455 |
public String getClosedLead(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model) throws Exception {
|
596 |
public String getClosedLead(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model) throws Exception {
|
| 456 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
597 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| 457 |
List<Lead> leads = null;
|
598 |
List<Lead> leads = null;
|