| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.io.ByteArrayInputStream;
|
| - |
|
4 |
import java.io.InputStream;
|
| - |
|
5 |
import java.time.LocalDate;
|
| - |
|
6 |
import java.time.LocalDateTime;
|
| - |
|
7 |
import java.time.format.DateTimeFormatter;
|
| - |
|
8 |
import java.util.ArrayList;
|
| - |
|
9 |
import java.util.Arrays;
|
| - |
|
10 |
import java.util.Comparator;
|
| - |
|
11 |
import java.util.HashMap;
|
| - |
|
12 |
import java.util.HashSet;
|
| - |
|
13 |
import java.util.List;
|
| - |
|
14 |
import java.util.Map;
|
| - |
|
15 |
import java.util.Map.Entry;
|
| - |
|
16 |
import java.util.Optional;
|
| - |
|
17 |
import java.util.Set;
|
| - |
|
18 |
import java.util.TreeMap;
|
| - |
|
19 |
import java.util.stream.Collectors;
|
| - |
|
20 |
|
| - |
|
21 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
22 |
import javax.servlet.http.HttpServletResponse;
|
| - |
|
23 |
import javax.transaction.Transactional;
|
| - |
|
24 |
|
| - |
|
25 |
import org.apache.commons.csv.CSVRecord;
|
| - |
|
26 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
27 |
import org.apache.logging.log4j.Logger;
|
| - |
|
28 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
29 |
import org.springframework.core.io.InputStreamResource;
|
| - |
|
30 |
import org.springframework.http.HttpHeaders;
|
| - |
|
31 |
import org.springframework.http.HttpStatus;
|
| - |
|
32 |
import org.springframework.http.MediaType;
|
| - |
|
33 |
import org.springframework.http.ResponseEntity;
|
| - |
|
34 |
import org.springframework.stereotype.Controller;
|
| - |
|
35 |
import org.springframework.ui.Model;
|
| - |
|
36 |
import org.springframework.util.StringUtils;
|
| - |
|
37 |
import org.springframework.web.bind.annotation.RequestBody;
|
| - |
|
38 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| - |
|
39 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
40 |
import org.springframework.web.bind.annotation.RequestParam;
|
| - |
|
41 |
import org.springframework.web.bind.annotation.RequestPart;
|
| - |
|
42 |
import org.springframework.web.multipart.MultipartFile;
|
| - |
|
43 |
|
| 3 |
import com.google.gson.Gson;
|
44 |
import com.google.gson.Gson;
|
| 4 |
import com.mongodb.DBObject;
|
45 |
import com.mongodb.DBObject;
|
| 5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
46 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
47 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 6 |
import com.spice.profitmandi.common.model.*;
|
48 |
import com.spice.profitmandi.common.model.Legend;
|
| - |
|
49 |
import com.spice.profitmandi.common.model.OptionModel;
|
| - |
|
50 |
import com.spice.profitmandi.common.model.PieLables;
|
| - |
|
51 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 7 |
import com.spice.profitmandi.common.util.FileUtil;
|
52 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 8 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
53 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 9 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
54 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| - |
|
55 |
import com.spice.profitmandi.dao.entity.catalog.BrandCatalog;
|
| 10 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
56 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| - |
|
57 |
import com.spice.profitmandi.dao.entity.user.FranchiseeActivity;
|
| - |
|
58 |
import com.spice.profitmandi.dao.entity.user.FranchiseeVisit;
|
| 11 |
import com.spice.profitmandi.dao.entity.user.*;
|
59 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
| - |
|
60 |
import com.spice.profitmandi.dao.entity.user.LeadActivity;
|
| - |
|
61 |
import com.spice.profitmandi.dao.entity.user.LeadBrand;
|
| - |
|
62 |
import com.spice.profitmandi.dao.entity.user.LeadDetail;
|
| - |
|
63 |
import com.spice.profitmandi.dao.entity.user.VisitRequest;
|
| 12 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
64 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 13 |
import com.spice.profitmandi.dao.enumuration.dtr.CommunicationType;
|
65 |
import com.spice.profitmandi.dao.enumuration.dtr.CommunicationType;
|
| 14 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadSource;
|
66 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadSource;
|
| 15 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
67 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
| - |
|
68 |
import com.spice.profitmandi.dao.model.ChartLeadModel;
|
| - |
|
69 |
import com.spice.profitmandi.dao.model.CreateLeacdActivityRequest;
|
| - |
|
70 |
import com.spice.profitmandi.dao.model.CreateRefferalRequest;
|
| 16 |
import com.spice.profitmandi.dao.model.*;
|
71 |
import com.spice.profitmandi.dao.model.DataLeadModel;
|
| - |
|
72 |
import com.spice.profitmandi.dao.model.DateRangeModel;
|
| - |
|
73 |
import com.spice.profitmandi.dao.model.LeadBrandModel;
|
| - |
|
74 |
import com.spice.profitmandi.dao.model.LeadDetailModel;
|
| - |
|
75 |
import com.spice.profitmandi.dao.model.LeadStatusData;
|
| - |
|
76 |
import com.spice.profitmandi.dao.model.PartnerCollectionPlanModel;
|
| - |
|
77 |
import com.spice.profitmandi.dao.model.RBMPerformanceSummaryModel;
|
| - |
|
78 |
import com.spice.profitmandi.dao.model.TeamCommitmentModel;
|
| - |
|
79 |
import com.spice.profitmandi.dao.model.TotalTargetColectionModel;
|
| - |
|
80 |
import com.spice.profitmandi.dao.model.UserVisitModel;
|
| - |
|
81 |
import com.spice.profitmandi.dao.model.VisitDescriptionModel;
|
| 17 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
82 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 18 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionPlanRepository;
|
83 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionPlanRepository;
|
| 19 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
|
84 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
|
| 20 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
85 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 21 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
86 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| - |
|
87 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
88 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeActivityRepository;
|
| - |
|
89 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeVisitRepository;
|
| - |
|
90 |
import com.spice.profitmandi.dao.repository.dtr.LeadActivityRepository;
|
| - |
|
91 |
import com.spice.profitmandi.dao.repository.dtr.LeadBrandRepository;
|
| - |
|
92 |
import com.spice.profitmandi.dao.repository.dtr.LeadDetailRepository;
|
| - |
|
93 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 22 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
94 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| - |
|
95 |
import com.spice.profitmandi.dao.repository.dtr.VisitRequestRepository;
|
| 23 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
96 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
97 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
98 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 26 |
import com.spice.profitmandi.service.AuthService;
|
99 |
import com.spice.profitmandi.service.AuthService;
|
| 27 |
import com.spice.profitmandi.service.PartnerCollectionService;
|
100 |
import com.spice.profitmandi.service.PartnerCollectionService;
|
| - |
|
101 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| 28 |
import com.spice.profitmandi.service.user.RetailerService;
|
102 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 29 |
import com.spice.profitmandi.web.model.LoginDetails;
|
103 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 30 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
104 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 31 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
105 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 32 |
import org.apache.commons.csv.CSVRecord;
|
- |
|
| 33 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 34 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 35 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 36 |
import org.springframework.core.io.InputStreamResource;
|
- |
|
| 37 |
import org.springframework.http.HttpHeaders;
|
- |
|
| 38 |
import org.springframework.http.HttpStatus;
|
- |
|
| 39 |
import org.springframework.http.MediaType;
|
- |
|
| 40 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 41 |
import org.springframework.stereotype.Controller;
|
- |
|
| 42 |
import org.springframework.ui.Model;
|
- |
|
| 43 |
import org.springframework.util.StringUtils;
|
- |
|
| 44 |
import org.springframework.web.bind.annotation.*;
|
- |
|
| 45 |
import org.springframework.web.multipart.MultipartFile;
|
- |
|
| 46 |
|
- |
|
| 47 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 48 |
import javax.servlet.http.HttpServletResponse;
|
- |
|
| 49 |
import javax.transaction.Transactional;
|
- |
|
| 50 |
import java.io.ByteArrayInputStream;
|
- |
|
| 51 |
import java.io.InputStream;
|
- |
|
| 52 |
import java.time.LocalDate;
|
- |
|
| 53 |
import java.time.LocalDateTime;
|
- |
|
| 54 |
import java.time.format.DateTimeFormatter;
|
- |
|
| 55 |
import java.util.*;
|
- |
|
| 56 |
import java.util.Map.Entry;
|
- |
|
| 57 |
import java.util.stream.Collectors;
|
- |
|
| 58 |
|
106 |
|
| 59 |
@Controller
|
107 |
@Controller
|
| 60 |
@Transactional(rollbackOn = Throwable.class)
|
108 |
@Transactional(rollbackOn = Throwable.class)
|
| 61 |
public class LeadController {
|
109 |
public class LeadController {
|
| 62 |
private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
|
110 |
private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
|
| - |
|
111 |
|
| - |
|
112 |
@Autowired
|
| - |
|
113 |
private LeadRepository leadRepository;
|
| - |
|
114 |
|
| - |
|
115 |
@Autowired
|
| - |
|
116 |
private LeadActivityRepository leadActivityRepository;
|
| - |
|
117 |
|
| - |
|
118 |
@Autowired
|
| - |
|
119 |
private StateRepository stateRepository;
|
| - |
|
120 |
|
| - |
|
121 |
@Autowired
|
| - |
|
122 |
private AuthService authService;
|
| - |
|
123 |
|
| - |
|
124 |
@Autowired
|
| - |
|
125 |
private AuthRepository authRepository;
|
| - |
|
126 |
|
| - |
|
127 |
@Autowired
|
| - |
|
128 |
private Gson gson;
|
| - |
|
129 |
|
| - |
|
130 |
@Autowired
|
| - |
|
131 |
private CookiesProcessor cookiesProcessor;
|
| - |
|
132 |
|
| - |
|
133 |
@Autowired
|
| - |
|
134 |
PositionRepository positionRepository;
|
| - |
|
135 |
|
| - |
|
136 |
@Autowired
|
| - |
|
137 |
private MVCResponseSender mvcResponseSender;
|
| - |
|
138 |
|
| - |
|
139 |
@Autowired
|
| - |
|
140 |
private PartnerCollectionPlanRepository partnerCollectionPlanRepository;
|
| - |
|
141 |
|
| - |
|
142 |
@Autowired
|
| - |
|
143 |
private CsService csService;
|
| - |
|
144 |
|
| - |
|
145 |
@Autowired
|
| - |
|
146 |
private FofoStoreRepository fofoStoreRepository;
|
| - |
|
147 |
|
| - |
|
148 |
@Autowired
|
| - |
|
149 |
private PartnerCollectionService partnerCollectionService;
|
| - |
|
150 |
|
| - |
|
151 |
@Autowired
|
| - |
|
152 |
private RetailerService retailerService;
|
| - |
|
153 |
|
| - |
|
154 |
@Autowired
|
| - |
|
155 |
private PartnerCollectionRemarkRepository partnerCollectionRemarkRepository;
|
| - |
|
156 |
|
| - |
|
157 |
@Autowired
|
| - |
|
158 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| - |
|
159 |
|
| - |
|
160 |
@Autowired
|
| - |
|
161 |
private UserWalletRepository userWalletRepository;
|
| - |
|
162 |
|
| - |
|
163 |
@Autowired
|
| - |
|
164 |
private FranchiseeVisitRepository franchiseeVisitRepository;
|
| - |
|
165 |
|
| - |
|
166 |
@Autowired
|
| - |
|
167 |
private FranchiseeActivityRepository franchiseeActivityRepository;
|
| 63 |
|
168 |
|
| 64 |
@Autowired
|
169 |
@Autowired
|
| 65 |
private LeadRepository leadRepository;
|
170 |
private VisitRequestRepository visitRequestRepository;
|
| 66 |
|
171 |
|
| 67 |
@Autowired
|
172 |
@Autowired
|
| 68 |
private LeadActivityRepository leadActivityRepository;
|
173 |
private LeadBrandRepository leadBrandRepository;
|
| 69 |
|
174 |
|
| 70 |
@Autowired
|
175 |
@Autowired
|
| 71 |
private StateRepository stateRepository;
|
176 |
private LeadDetailRepository leadDetailRepository;
|
| 72 |
|
177 |
|
| 73 |
@Autowired
|
178 |
@Autowired
|
| 74 |
private AuthService authService;
|
179 |
private Mongo mongoClient;
|
| 75 |
|
180 |
|
| 76 |
@Autowired
|
181 |
@Autowired
|
| 77 |
private AuthRepository authRepository;
|
182 |
private ResponseSender<?> responseSender;
|
| 78 |
|
183 |
|
| 79 |
@Autowired
|
184 |
@Autowired
|
| 80 |
private Gson gson;
|
185 |
private BrandsService brandsService;
|
| 81 |
|
186 |
|
| 82 |
@Autowired
|
- |
|
| 83 |
private CookiesProcessor cookiesProcessor;
|
187 |
List<LeadStatus> status = Arrays.asList(LeadStatus.notInterested, LeadStatus.finalized);
|
| 84 |
|
188 |
|
| 85 |
@Autowired
|
189 |
@RequestMapping(value = "/getOpenLead", method = RequestMethod.GET)
|
| 86 |
PositionRepository positionRepository;
|
190 |
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 {
|
| 87 |
|
191 |
|
| - |
|
192 |
LocalDateTime localDateTime = null;
|
| - |
|
193 |
if (leadDate != null) {
|
| - |
|
194 |
localDateTime = leadDate.atStartOfDay();
|
| 88 |
@Autowired
|
195 |
}
|
| 89 |
private MVCResponseSender mvcResponseSender;
|
196 |
LOGGER.info("localDateTime" + localDateTime);
|
| 90 |
|
197 |
|
| - |
|
198 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 91 |
@Autowired
|
199 |
String emailId = loginDetails.getEmailId();
|
| 92 |
private PartnerCollectionPlanRepository partnerCollectionPlanRepository;
|
200 |
AuthUser authUser = authRepository.selectByEmailOrMobile(emailId);
|
| 93 |
|
201 |
|
| 94 |
@Autowired
|
- |
|
| 95 |
private CsService csService;
|
202 |
boolean authPositon = positionRepository.hasCategory(authUser.getId(), ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
| 96 |
|
203 |
|
| 97 |
@Autowired
|
- |
|
| 98 |
private FofoStoreRepository fofoStoreRepository;
|
204 |
if (leadStatus.contains(LeadStatus.All)) {
|
| 99 |
|
205 |
|
| 100 |
@Autowired
|
206 |
leadStatus.add(LeadStatus.pending);
|
| 101 |
private PartnerCollectionService partnerCollectionService;
|
207 |
leadStatus.add(LeadStatus.notInterested);
|
| - |
|
208 |
leadStatus.add(LeadStatus.finalized);
|
| - |
|
209 |
}
|
| 102 |
|
210 |
|
| - |
|
211 |
if (color.contains("All")) {
|
| 103 |
@Autowired
|
212 |
color.add("yellow");
|
| 104 |
private RetailerService retailerService;
|
213 |
color.add("green");
|
| - |
|
214 |
}
|
| 105 |
|
215 |
|
| 106 |
@Autowired
|
- |
|
| 107 |
private PartnerCollectionRemarkRepository partnerCollectionRemarkRepository;
|
216 |
List<Lead> leads = new ArrayList<>();
|
| 108 |
|
217 |
|
| 109 |
@Autowired
|
- |
|
| 110 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
218 |
model.addAttribute("colors", color);
|
| 111 |
|
219 |
|
| 112 |
@Autowired
|
- |
|
| 113 |
private UserWalletRepository userWalletRepository;
|
220 |
Map<Integer, List<LeadActivity>> leadActivityMap = new HashMap<>();
|
| 114 |
|
221 |
|
| 115 |
@Autowired
|
- |
|
| 116 |
private FranchiseeVisitRepository franchiseeVisitRepository;
|
222 |
List<Integer> authUserIds = null;
|
| 117 |
|
223 |
|
| 118 |
@Autowired
|
- |
|
| 119 |
private FranchiseeActivityRepository franchiseeActivityRepository;
|
224 |
LOGGER.info("color111" + color);
|
| 120 |
|
225 |
|
| 121 |
@Autowired
|
- |
|
| 122 |
private VisitRequestRepository visitRequestRepository;
|
226 |
List<Lead> leadFollowUp = new ArrayList<>();
|
| 123 |
|
227 |
|
| 124 |
@Autowired
|
228 |
if (authPositon) {
|
| - |
|
229 |
authUserIds = authService.getAllReportees(authUser.getId());
|
| 125 |
private LeadBrandRepository leadBrandRepository;
|
230 |
authUserIds.add(authUser.getId());
|
| - |
|
231 |
LOGGER.info("authIds" + authUserIds);
|
| 126 |
|
232 |
|
| 127 |
@Autowired
|
- |
|
| 128 |
private LeadDetailRepository leadDetailRepository;
|
233 |
LOGGER.info("leadStatus" + leadStatus);
|
| 129 |
|
234 |
|
| 130 |
@Autowired
|
- |
|
| 131 |
private Mongo mongoClient;
|
235 |
if (localDateTime == null) {
|
| 132 |
|
236 |
|
| 133 |
@Autowired
|
- |
|
| 134 |
private ResponseSender<?> responseSender;
|
237 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| 135 |
|
238 |
|
| 136 |
List<LeadStatus> status = Arrays.asList(LeadStatus.notInterested, LeadStatus.finalized);
|
239 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds, color, LocalDateTime.now().minusMonths(1));
|
| - |
|
240 |
}
|
| 137 |
|
241 |
|
| 138 |
@RequestMapping(value = "/getOpenLead", method = RequestMethod.GET)
|
- |
|
| 139 |
public String getOpenLead(HttpServletRequest request,
|
- |
|
| 140 |
@RequestParam(name = "leadStatus", required = false, defaultValue = "All") List<LeadStatus> leadStatus,
|
242 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
| 141 |
@RequestParam(name = "color", required = false, defaultValue = "All") List<String> color,
|
243 |
leadFollowUp = leadRepository.selectByAssignAuthIdsAndStatus(authUserIds, LeadStatus.followUp);
|
| 142 |
@RequestParam(name = "leadDate", required = false, defaultValue = "") LocalDate leadDate, Model model)
|
244 |
leads.addAll(leadFollowUp);
|
| 143 |
throws Exception {
|
245 |
}
|
| 144 |
|
246 |
|
| 145 |
LocalDateTime localDateTime = null;
|
- |
|
| 146 |
if (leadDate != null) {
|
247 |
} else {
|
| 147 |
localDateTime = leadDate.atStartOfDay();
|
- |
|
| 148 |
}
|
- |
|
| 149 |
LOGGER.info("localDateTime" + localDateTime);
|
- |
|
| 150 |
|
248 |
|
| 151 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 152 |
String emailId = loginDetails.getEmailId();
|
- |
|
| 153 |
AuthUser authUser = authRepository.selectByEmailOrMobile(emailId);
|
249 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| 154 |
|
250 |
|
| 155 |
boolean authPositon = positionRepository.hasCategory(authUser.getId(),
|
251 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds, color, localDateTime);
|
| 156 |
ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
252 |
}
|
| 157 |
|
253 |
|
| 158 |
if (leadStatus.contains(LeadStatus.All)) {
|
254 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
| 159 |
|
255 |
|
| 160 |
leadStatus.add(LeadStatus.pending);
|
- |
|
| 161 |
leadStatus.add(LeadStatus.notInterested);
|
- |
|
| 162 |
leadStatus.add(LeadStatus.finalized);
|
256 |
leadFollowUp = leadRepository.selectByAssignAuthIdsAndStatus(authUserIds, LeadStatus.followUp);
|
| 163 |
}
|
- |
|
| 164 |
|
257 |
|
| 165 |
if (color.contains("All")) {
|
- |
|
| 166 |
color.add("yellow");
|
258 |
leads.addAll(leadFollowUp);
|
| 167 |
color.add("green");
|
- |
|
| 168 |
}
|
- |
|
| 169 |
|
259 |
|
| 170 |
List<Lead> leads = new ArrayList<>();
|
260 |
}
|
| 171 |
|
261 |
|
| 172 |
model.addAttribute("colors", color);
|
262 |
}
|
| 173 |
|
263 |
|
| 174 |
Map<Integer, List<LeadActivity>> leadActivityMap = new HashMap<>();
|
264 |
} else {
|
| 175 |
|
265 |
|
| 176 |
List<Integer> authUserIds = null;
|
266 |
if (localDateTime == null) {
|
| - |
|
267 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| 177 |
|
268 |
|
| - |
|
269 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestamp(leadStatus, color, LocalDateTime.now().minusMonths(1));
|
| 178 |
LOGGER.info("color111" + color);
|
270 |
}
|
| - |
|
271 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
| 179 |
|
272 |
|
| 180 |
List<Lead> leadFollowUp = new ArrayList<>();
|
273 |
leadFollowUp = leadRepository.selectAllByStatus(LeadStatus.followUp);
|
| 181 |
|
274 |
|
| 182 |
if (authPositon) {
|
- |
|
| 183 |
authUserIds = authService.getAllReportees(authUser.getId());
|
275 |
leads.addAll(leadFollowUp);
|
| 184 |
authUserIds.add(authUser.getId());
|
276 |
}
|
| 185 |
LOGGER.info("authIds" + authUserIds);
|
277 |
LOGGER.info("leadlocalDateTime1" + leads);
|
| 186 |
|
278 |
|
| - |
|
279 |
} else {
|
| 187 |
LOGGER.info("leadStatus" + leadStatus);
|
280 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| 188 |
|
281 |
|
| - |
|
282 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestamp(leadStatus, color, localDateTime);
|
| 189 |
if (localDateTime == null) {
|
283 |
}
|
| 190 |
|
284 |
|
| 191 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
285 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
| 192 |
|
286 |
|
| 193 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds,
|
287 |
leadFollowUp = leadRepository.selectAllByStatus(LeadStatus.followUp);
|
| 194 |
color, LocalDateTime.now().minusMonths(1));
|
- |
|
| 195 |
}
|
- |
|
| 196 |
|
288 |
|
| 197 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
- |
|
| 198 |
leadFollowUp = leadRepository.selectByAssignAuthIdsAndStatus(authUserIds, LeadStatus.followUp);
|
- |
|
| 199 |
leads.addAll(leadFollowUp);
|
289 |
leads.addAll(leadFollowUp);
|
| 200 |
}
|
290 |
}
|
| - |
|
291 |
LOGGER.info("leadlocalDateTime2" + leads);
|
| 201 |
|
292 |
|
| 202 |
} else {
|
293 |
}
|
| 203 |
|
294 |
|
| 204 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
295 |
}
|
| 205 |
|
296 |
|
| - |
|
297 |
if (authPositon && authUserIds.size() > 0) {
|
| - |
|
298 |
List<String> leadCreators = new ArrayList<>();
|
| - |
|
299 |
leadCreators.add("daily-sync");
|
| 206 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds,
|
300 |
leadCreators.addAll(authRepository.selectAllAuthUserByIds(authUserIds).stream().map(x -> x.getFullName()).collect(Collectors.toList()));
|
| 207 |
color, localDateTime);
|
301 |
model.addAttribute("leadCreators", leadCreators);
|
| 208 |
}
|
302 |
}
|
| - |
|
303 |
List<Lead> weekLast = new ArrayList<>();
|
| - |
|
304 |
List<Lead> weekThird = new ArrayList<>();
|
| - |
|
305 |
List<Lead> weekSecond = new ArrayList<>();
|
| - |
|
306 |
List<Lead> weekFirst = new ArrayList<>();
|
| - |
|
307 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
308 |
List<LeadWeakWiseModel> lwDays = new ArrayList<>();
|
| 209 |
|
309 |
|
| - |
|
310 |
for (int i = 7; i >= 1; i--) {
|
| 210 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
311 |
LocalDateTime startOfDay = curDate.minusDays(i);
|
| 211 |
|
312 |
|
| 212 |
leadFollowUp = leadRepository.selectByAssignAuthIdsAndStatus(authUserIds, LeadStatus.followUp);
|
313 |
LeadWeakWiseModel lm = new LeadWeakWiseModel();
|
| - |
|
314 |
lm.setMonth(startOfDay.toLocalDate());
|
| - |
|
315 |
lwDays.add(lm);
|
| - |
|
316 |
}
|
| - |
|
317 |
if (!leads.isEmpty()) {
|
| 213 |
|
318 |
|
| 214 |
leads.addAll(leadFollowUp);
|
319 |
weekLast.addAll(
|
| - |
|
320 |
leads.stream().filter(x -> x.getCreatedTimestamp().isAfter(curDate.minusDays(28)) && x.getCreatedTimestamp().isBefore(curDate.minusDays(21))).collect(Collectors.toList()));
|
| 215 |
|
321 |
|
| 216 |
}
|
- |
|
| - |
|
322 |
weekThird.addAll(leads.stream().filter(x -> x.getCreatedTimestamp().isAfter(curDate.minusDays(21)) && x.getCreatedTimestamp().isBefore(curDate.minusDays(14))).collect(Collectors.toList()));
|
| 217 |
|
323 |
|
| 218 |
}
|
- |
|
| - |
|
324 |
weekSecond.addAll(leads.stream().filter(x -> x.getCreatedTimestamp().isAfter(curDate.minusDays(14)) && x.getCreatedTimestamp().isBefore(curDate.minusDays(7))).collect(Collectors.toList()));
|
| 219 |
|
325 |
|
| 220 |
} else {
|
- |
|
| - |
|
326 |
weekFirst.addAll(leads.stream().filter(x -> x.getCreatedTimestamp().isAfter(curDate.minusDays(7))).collect(Collectors.toList()));
|
| 221 |
|
327 |
|
| - |
|
328 |
}
|
| - |
|
329 |
LOGGER.info("weekLast" + weekLast);
|
| 222 |
if (localDateTime == null) {
|
330 |
LOGGER.info("weekThird" + weekThird);
|
| 223 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
331 |
LOGGER.info("weekSecond" + weekSecond);
|
| - |
|
332 |
Map<String, Long> leadLasts = weekLast.stream().collect(Collectors.groupingBy(x -> x.getCreatedBy(), Collectors.counting()));
|
| - |
|
333 |
Map<String, Long> leadThirds = weekThird.stream().collect(Collectors.groupingBy(x -> x.getCreatedBy(), Collectors.counting()));
|
| - |
|
334 |
Map<String, Long> leadSeconds = weekSecond.stream().collect(Collectors.groupingBy(x -> x.getCreatedBy(), Collectors.mapping(Lead::getCreatedBy, Collectors.counting())));
|
| 224 |
|
335 |
|
| 225 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestamp(leadStatus, color,
|
336 |
Map<String, Map<LocalDate, Long>> leadFirsts = weekFirst.stream().collect(Collectors.groupingBy(x -> x.getCreatedBy(), Collectors.groupingBy(x -> x.getCreatedTimestamp().toLocalDate(), Collectors.counting())));
|
| 226 |
LocalDateTime.now().minusMonths(1));
|
- |
|
| 227 |
}
|
- |
|
| 228 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
- |
|
| 229 |
|
337 |
|
| 230 |
leadFollowUp = leadRepository.selectAllByStatus(LeadStatus.followUp);
|
338 |
LOGGER.info("leadFirsts" + leadFirsts);
|
| 231 |
|
339 |
|
| 232 |
leads.addAll(leadFollowUp);
|
340 |
List<Integer> authIds = new ArrayList<>();
|
| 233 |
}
|
- |
|
| 234 |
LOGGER.info("leadlocalDateTime1" + leads);
|
341 |
if (!leads.isEmpty()) {
|
| 235 |
|
342 |
|
| 236 |
} else {
|
- |
|
| 237 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
343 |
authIds.addAll(leads.stream().map(x -> x.getAssignTo()).collect(Collectors.toList()));
|
| 238 |
|
344 |
|
| 239 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestamp(leadStatus, color, localDateTime);
|
345 |
leadActivityMap = leadActivityRepository.selectAllByleadIds(leads.stream().map(x -> x.getId()).collect(Collectors.toList())).stream().collect(Collectors.groupingBy(LeadActivity::getLeadId, Collectors.toList()));
|
| 240 |
}
|
- |
|
| 241 |
|
346 |
|
| - |
|
347 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 242 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
348 |
model.addAttribute("leadActivityMap", leadActivityMap);
|
| - |
|
349 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
350 |
}
|
| 243 |
|
351 |
|
| - |
|
352 |
ChartLeadModel cm = this.getLeadChart(leads);
|
| 244 |
leadFollowUp = leadRepository.selectAllByStatus(LeadStatus.followUp);
|
353 |
model.addAttribute("chartLead", gson.toJson(cm));
|
| 245 |
|
354 |
|
| 246 |
leads.addAll(leadFollowUp);
|
355 |
LOGGER.info("ChartLeadModel" + gson.toJson(cm));
|
| 247 |
}
|
- |
|
| 248 |
LOGGER.info("leadlocalDateTime2" + leads);
|
356 |
LOGGER.info("lwDays" + lwDays);
|
| 249 |
|
357 |
|
| 250 |
}
|
- |
|
| - |
|
358 |
LOGGER.info("leads" + leads);
|
| - |
|
359 |
List<String> stateNames = stateRepository.selectAll().stream().map(x -> x.getName()).collect(Collectors.toList());
|
| - |
|
360 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| - |
|
361 |
LocalDate lastDate = curDate.minusDays(1).toLocalDate();
|
| 251 |
|
362 |
|
| 252 |
}
|
- |
|
| - |
|
363 |
List<LocalDate> weekDates = new ArrayList<>();
|
| 253 |
|
364 |
|
| 254 |
if (authPositon && authUserIds.size() > 0) {
|
365 |
weekDates.add(curDate.minusDays(28).toLocalDate());
|
| 255 |
List<String> leadCreators = new ArrayList<>();
|
366 |
weekDates.add(curDate.minusDays(22).toLocalDate());
|
| 256 |
leadCreators.add("daily-sync");
|
367 |
weekDates.add(curDate.minusDays(21).toLocalDate());
|
| 257 |
leadCreators.addAll(authRepository.selectAllAuthUserByIds(authUserIds).stream().map(x -> x.getFullName())
|
- |
|
| 258 |
.collect(Collectors.toList()));
|
368 |
weekDates.add(curDate.minusDays(15).toLocalDate());
|
| 259 |
model.addAttribute("leadCreators", leadCreators);
|
369 |
weekDates.add(curDate.minusDays(14).toLocalDate());
|
| 260 |
}
|
- |
|
| 261 |
List<Lead> weekLast = new ArrayList<>();
|
- |
|
| 262 |
List<Lead> weekThird = new ArrayList<>();
|
- |
|
| 263 |
List<Lead> weekSecond = new ArrayList<>();
|
370 |
weekDates.add(curDate.minusDays(8).toLocalDate());
|
| 264 |
List<Lead> weekFirst = new ArrayList<>();
|
- |
|
| 265 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
371 |
weekDates.add(curDate.minusDays(7).toLocalDate());
|
| 266 |
List<LeadWeakWiseModel> lwDays = new ArrayList<>();
|
372 |
LOGGER.info("lastDate" + lastDate);
|
| 267 |
|
373 |
|
| 268 |
for (int i = 7; i >= 1; i--) {
|
- |
|
| 269 |
LocalDateTime startOfDay = curDate.minusDays(i);
|
374 |
model.addAttribute("weekDates", weekDates);
|
| 270 |
|
375 |
|
| 271 |
LeadWeakWiseModel lm = new LeadWeakWiseModel();
|
376 |
model.addAttribute("leadDate", leadDate);
|
| 272 |
lm.setMonth(startOfDay.toLocalDate());
|
377 |
model.addAttribute("lastDate", lastDate);
|
| 273 |
lwDays.add(lm);
|
- |
|
| 274 |
}
|
- |
|
| 275 |
if (!leads.isEmpty()) {
|
378 |
model.addAttribute("stateNames", stateNames);
|
| 276 |
|
379 |
|
| 277 |
weekLast.addAll(
|
- |
|
| 278 |
leads.stream()
|
- |
|
| 279 |
.filter(x -> x.getCreatedTimestamp().isAfter(curDate.minusDays(28))
|
- |
|
| 280 |
&& x.getCreatedTimestamp().isBefore(curDate.minusDays(21)))
|
380 |
model.addAttribute("communicationTypes", CommunicationType.values());
|
| 281 |
.collect(Collectors.toList()));
|
- |
|
| 282 |
|
381 |
|
| 283 |
weekThird
|
382 |
model.addAttribute("authUsers", authUsers);
|
| 284 |
.addAll(leads.stream()
|
383 |
model.addAttribute("lead", leads);
|
| 285 |
.filter(x -> x.getCreatedTimestamp().isAfter(curDate.minusDays(21))
|
384 |
model.addAttribute("leadStatus", LeadStatus.values());
|
| - |
|
385 |
model.addAttribute("leadLasts", leadLasts);
|
| - |
|
386 |
model.addAttribute("leadThirds", leadThirds);
|
| - |
|
387 |
model.addAttribute("leadSeconds", leadSeconds);
|
| 286 |
&& x.getCreatedTimestamp().isBefore(curDate.minusDays(14)))
|
388 |
model.addAttribute("leadFirsts", leadFirsts);
|
| 287 |
.collect(Collectors.toList()));
|
389 |
model.addAttribute("lwDays", lwDays);
|
| 288 |
|
390 |
|
| 289 |
weekSecond
|
- |
|
| 290 |
.addAll(leads.stream()
|
- |
|
| 291 |
.filter(x -> x.getCreatedTimestamp().isAfter(curDate.minusDays(14))
|
- |
|
| 292 |
&& x.getCreatedTimestamp().isBefore(curDate.minusDays(7)))
|
391 |
model.addAttribute("selectedLeadStatus", leadStatus.get(0));
|
| 293 |
.collect(Collectors.toList()));
|
- |
|
| 294 |
|
392 |
|
| 295 |
weekFirst.addAll(leads.stream().filter(x -> x.getCreatedTimestamp().isAfter(curDate.minusDays(7)))
|
- |
|
| 296 |
.collect(Collectors.toList()));
|
- |
|
| 297 |
|
393 |
|
| 298 |
}
|
- |
|
| 299 |
LOGGER.info("weekLast" + weekLast);
|
- |
|
| 300 |
LOGGER.info("weekThird" + weekThird);
|
- |
|
| 301 |
LOGGER.info("weekSecond" + weekSecond);
|
- |
|
| 302 |
Map<String, Long> leadLasts = weekLast.stream()
|
- |
|
| 303 |
.collect(Collectors.groupingBy(x -> x.getCreatedBy(), Collectors.counting()));
|
394 |
List<BrandCatalog> brandsDisplays = brandsService.getBrandsToDisplay(3);
|
| 304 |
Map<String, Long> leadThirds = weekThird.stream()
|
395 |
brandsDisplays.addAll(brandsService.getBrandsToDisplay(6));
|
| 305 |
.collect(Collectors.groupingBy(x -> x.getCreatedBy(), Collectors.counting()));
|
396 |
model.addAttribute("brandsDisplays", brandsDisplays.stream().distinct().collect(Collectors.toList()));
|
| 306 |
Map<String, Long> leadSeconds = weekSecond.stream().collect(Collectors.groupingBy(x -> x.getCreatedBy(),
|
- |
|
| 307 |
Collectors.mapping(Lead::getCreatedBy, Collectors.counting())));
|
- |
|
| 308 |
|
397 |
|
| 309 |
Map<String, Map<LocalDate, Long>> leadFirsts = weekFirst.stream()
|
- |
|
| 310 |
.collect(Collectors.groupingBy(x -> x.getCreatedBy(),
|
398 |
LOGGER.info("brandsDisplays" + brandsDisplays);
|
| 311 |
Collectors.groupingBy(x -> x.getCreatedTimestamp().toLocalDate(), Collectors.counting())));
|
- |
|
| 312 |
|
399 |
|
| 313 |
LOGGER.info("leadFirsts" + leadFirsts);
|
- |
|
| 314 |
|
400 |
|
| 315 |
List<Integer> authIds = new ArrayList<>();
|
- |
|
| 316 |
if (!leads.isEmpty()) {
|
401 |
return "lead";
|
| 317 |
|
402 |
|
| 318 |
authIds.addAll(leads.stream().map(x -> x.getAssignTo()).collect(Collectors.toList()));
|
- |
|
| - |
|
403 |
}
|
| 319 |
|
404 |
|
| 320 |
leadActivityMap = leadActivityRepository
|
- |
|
| 321 |
.selectAllByleadIds(leads.stream().map(x -> x.getId()).collect(Collectors.toList())).stream()
|
405 |
public ChartLeadModel getLeadChart(List<Lead> leads) throws ProfitMandiBusinessException {
|
| 322 |
.collect(Collectors.groupingBy(LeadActivity::getLeadId, Collectors.toList()));
|
- |
|
| 323 |
|
406 |
|
| 324 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
- |
|
| 325 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 326 |
model.addAttribute("leadActivityMap", leadActivityMap);
|
407 |
Map<LeadStatus, Long> leadStatusMap = leads.stream().collect(
|
| 327 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
408 |
Collectors.groupingBy(x -> x.getStatus(), Collectors.mapping(Lead::getStatus, Collectors.counting())));
|
| 328 |
}
|
- |
|
| 329 |
|
409 |
|
| 330 |
ChartLeadModel cm = this.getLeadChart(leads);
|
410 |
Map<String, Long> hotLeadsMap = leads.stream().collect(
|
| 331 |
model.addAttribute("chartLead", gson.toJson(cm));
|
411 |
Collectors.groupingBy(x -> x.getColor(), Collectors.mapping(Lead::getColor, Collectors.counting())));
|
| 332 |
|
412 |
|
| 333 |
LOGGER.info("ChartLeadModel" + gson.toJson(cm));
|
413 |
LOGGER.info("hotLeadsMap" + hotLeadsMap);
|
| 334 |
LOGGER.info("lwDays" + lwDays);
|
414 |
ChartLeadModel cm = new ChartLeadModel();
|
| 335 |
|
415 |
|
| 336 |
LOGGER.info("leads" + leads);
|
- |
|
| 337 |
List<String> stateNames = stateRepository.selectAll().stream().map(x -> x.getName())
|
- |
|
| 338 |
.collect(Collectors.toList());
|
- |
|
| 339 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
416 |
HashSet<LeadStatus> labels = new HashSet<LeadStatus>();
|
| 340 |
LocalDate lastDate = curDate.minusDays(1).toLocalDate();
|
417 |
labels.addAll(leadStatusMap.keySet());
|
| 341 |
|
418 |
|
| 342 |
List<LocalDate> weekDates = new ArrayList<>();
|
419 |
List<String> hotLeads = new ArrayList<>();
|
| - |
|
420 |
hotLeads.addAll(leadStatusMap.keySet().stream().map(x -> x.toString()).collect(Collectors.toSet()));
|
| - |
|
421 |
hotLeads.add("HotLead");
|
| 343 |
|
422 |
|
| 344 |
weekDates.add(curDate.minusDays(28).toLocalDate());
|
- |
|
| 345 |
weekDates.add(curDate.minusDays(22).toLocalDate());
|
- |
|
| 346 |
weekDates.add(curDate.minusDays(21).toLocalDate());
|
- |
|
| 347 |
weekDates.add(curDate.minusDays(15).toLocalDate());
|
- |
|
| 348 |
weekDates.add(curDate.minusDays(14).toLocalDate());
|
423 |
List<String> hotLeadKeys = new ArrayList<>();
|
| 349 |
weekDates.add(curDate.minusDays(8).toLocalDate());
|
- |
|
| 350 |
weekDates.add(curDate.minusDays(7).toLocalDate());
|
- |
|
| 351 |
LOGGER.info("lastDate" + lastDate);
|
- |
|
| 352 |
|
424 |
|
| 353 |
model.addAttribute("weekDates", weekDates);
|
425 |
hotLeadKeys.add("HotLead");
|
| - |
|
426 |
List<String> hotLeadGreen = new ArrayList<>(hotLeadKeys);
|
| 354 |
|
427 |
|
| 355 |
model.addAttribute("leadDate", leadDate);
|
- |
|
| 356 |
model.addAttribute("lastDate", lastDate);
|
- |
|
| 357 |
model.addAttribute("stateNames", stateNames);
|
428 |
LOGGER.info("hotLeads" + hotLeads);
|
| 358 |
|
429 |
|
| 359 |
model.addAttribute("communicationTypes", CommunicationType.values());
|
430 |
List<LeadStatus> labelList = new ArrayList<>(labels);
|
| - |
|
431 |
List<String> backgroundColor = new ArrayList<>();
|
| - |
|
432 |
LOGGER.info("hotLeadKeys" + hotLeadKeys);
|
| - |
|
433 |
List<Long> values = new ArrayList<>();
|
| 360 |
|
434 |
|
| 361 |
model.addAttribute("authUsers", authUsers);
|
- |
|
| 362 |
model.addAttribute("lead", leads);
|
435 |
for (String hotLead : hotLeads) {
|
| 363 |
model.addAttribute("leadStatus", LeadStatus.values());
|
- |
|
| 364 |
model.addAttribute("leadLasts", leadLasts);
|
- |
|
| 365 |
model.addAttribute("leadThirds", leadThirds);
|
- |
|
| 366 |
model.addAttribute("leadSeconds", leadSeconds);
|
- |
|
| 367 |
model.addAttribute("leadFirsts", leadFirsts);
|
- |
|
| 368 |
model.addAttribute("lwDays", lwDays);
|
- |
|
| 369 |
|
436 |
|
| - |
|
437 |
if (hotLead.equals("pending")) {
|
| - |
|
438 |
backgroundColor.add("pink");
|
| 370 |
model.addAttribute("selectedLeadStatus", leadStatus.get(0));
|
439 |
values.add(leadStatusMap.get(LeadStatus.pending));
|
| - |
|
440 |
}
|
| - |
|
441 |
if (hotLead.equals("notInterested")) {
|
| - |
|
442 |
backgroundColor.add("red");
|
| - |
|
443 |
values.add(leadStatusMap.get(LeadStatus.notInterested));
|
| - |
|
444 |
}
|
| - |
|
445 |
if (hotLead.equals("followUp")) {
|
| - |
|
446 |
backgroundColor.add("#9ACD32");
|
| - |
|
447 |
values.add(leadStatusMap.get(LeadStatus.followUp));
|
| - |
|
448 |
}
|
| - |
|
449 |
if (hotLead.equals("finalized")) {
|
| - |
|
450 |
backgroundColor.add("blue");
|
| - |
|
451 |
values.add(leadStatusMap.get(LeadStatus.finalized));
|
| - |
|
452 |
}
|
| 371 |
|
453 |
|
| - |
|
454 |
if (hotLead.equals("HotLead")) {
|
| - |
|
455 |
backgroundColor.add("green");
|
| 372 |
List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
|
456 |
values.add(hotLeadsMap.get("Green"));
|
| 373 |
|
457 |
|
| 374 |
List<String> brands = mobileBrands.stream().map(x -> (String) x.get("name")).collect(Collectors.toList());
|
- |
|
| - |
|
458 |
}
|
| 375 |
|
459 |
|
| - |
|
460 |
}
|
| 376 |
model.addAttribute("brands", brands);
|
461 |
LOGGER.info("labelList" + labelList);
|
| 377 |
|
462 |
|
| - |
|
463 |
LOGGER.info("backgroundColor" + backgroundColor);
|
| - |
|
464 |
LOGGER.info("labelsChartLead" + labels);
|
| - |
|
465 |
LeadStatusData data = new LeadStatusData();
|
| 378 |
return "lead";
|
466 |
data.setData(values);
|
| - |
|
467 |
data.setBackgroundColor(backgroundColor);
|
| - |
|
468 |
data.setLabel("DataSet 1");
|
| 379 |
|
469 |
|
| 380 |
}
|
- |
|
| - |
|
470 |
PieLables label = new PieLables();
|
| - |
|
471 |
label.setFontColor("black");
|
| - |
|
472 |
label.setFontSize(15);
|
| 381 |
|
473 |
|
| - |
|
474 |
Legend legend = new Legend();
|
| - |
|
475 |
legend.setLabels(label);
|
| 382 |
public ChartLeadModel getLeadChart(List<Lead> leads) throws ProfitMandiBusinessException {
|
476 |
legend.setPosition("left");
|
| 383 |
|
477 |
|
| 384 |
Map<LeadStatus, Long> leadStatusMap = leads.stream().collect(
|
478 |
List<LeadStatusData> dataList = new ArrayList<>();
|
| 385 |
Collectors.groupingBy(x -> x.getStatus(), Collectors.mapping(Lead::getStatus, Collectors.counting())));
|
479 |
dataList.add(data);
|
| 386 |
|
480 |
|
| 387 |
Map<String, Long> hotLeadsMap = leads.stream().collect(
|
481 |
DataLeadModel datasets = new DataLeadModel();
|
| 388 |
Collectors.groupingBy(x -> x.getColor(), Collectors.mapping(Lead::getColor, Collectors.counting())));
|
482 |
datasets.setDatasets(dataList);
|
| - |
|
483 |
datasets.setLabels(hotLeads);
|
| 389 |
|
484 |
|
| 390 |
LOGGER.info("hotLeadsMap" + hotLeadsMap);
|
485 |
OptionModel om = new OptionModel();
|
| 391 |
ChartLeadModel cm = new ChartLeadModel();
|
486 |
om.setLegend(legend);
|
| 392 |
|
487 |
|
| 393 |
HashSet<LeadStatus> labels = new HashSet<LeadStatus>();
|
488 |
cm.setType("pie");
|
| 394 |
labels.addAll(leadStatusMap.keySet());
|
489 |
cm.setData(datasets);
|
| - |
|
490 |
cm.setOptions(om);
|
| 395 |
|
491 |
|
| 396 |
List<String> hotLeads = new ArrayList<>();
|
- |
|
| 397 |
hotLeads.addAll(leadStatusMap.keySet().stream().map(x -> x.toString()).collect(Collectors.toSet()));
|
- |
|
| 398 |
hotLeads.add("HotLead");
|
492 |
return cm;
|
| - |
|
493 |
}
|
| 399 |
|
494 |
|
| 400 |
List<String> hotLeadKeys = new ArrayList<>();
|
- |
|
| 401 |
|
495 |
|
| - |
|
496 |
@RequestMapping(value = "/getClosedLead", method = RequestMethod.GET)
|
| 402 |
hotLeadKeys.add("HotLead");
|
497 |
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 {
|
| 403 |
List<String> hotLeadGreen = new ArrayList<>(hotLeadKeys);
|
498 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| - |
|
499 |
List<Lead> leads = null;
|
| - |
|
500 |
long size = 0;
|
| - |
|
501 |
leads = leadRepository.selectAllByStatus(status, offset, limit);
|
| - |
|
502 |
size = leadRepository.selectCountByStatus(status);
|
| 404 |
|
503 |
|
| - |
|
504 |
if (!leads.isEmpty()) {
|
| - |
|
505 |
List<Integer> authIds = new ArrayList<>();
|
| 405 |
LOGGER.info("hotLeads" + hotLeads);
|
506 |
for (Lead lead : leads) {
|
| - |
|
507 |
authIds.add(lead.getAssignTo());
|
| - |
|
508 |
}
|
| - |
|
509 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 406 |
|
510 |
|
| 407 |
List<LeadStatus> labelList = new ArrayList<>(labels);
|
511 |
model.addAttribute("leads", leads);
|
| 408 |
List<String> backgroundColor = new ArrayList<>();
|
512 |
model.addAttribute("start", offset + 1);
|
| 409 |
LOGGER.info("hotLeadKeys" + hotLeadKeys);
|
513 |
model.addAttribute("size", size);
|
| 410 |
List<Long> values = new ArrayList<>();
|
514 |
model.addAttribute("searchTerm", searchTerm);
|
| - |
|
515 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
516 |
model.addAttribute("url", "/getPaginatedClosedLeads");
|
| 411 |
|
517 |
|
| 412 |
for (String hotLead : hotLeads) {
|
518 |
if (leads.size() < limit) {
|
| - |
|
519 |
model.addAttribute("end", offset + leads.size());
|
| - |
|
520 |
} else {
|
| - |
|
521 |
model.addAttribute("end", offset + limit);
|
| - |
|
522 |
}
|
| 413 |
|
523 |
|
| 414 |
if (hotLead.equals("pending")) {
|
524 |
} else {
|
| 415 |
backgroundColor.add("pink");
|
- |
|
| 416 |
values.add(leadStatusMap.get(LeadStatus.pending));
|
525 |
model.addAttribute("lead", leads);
|
| 417 |
}
|
- |
|
| 418 |
if (hotLead.equals("notInterested")) {
|
- |
|
| 419 |
backgroundColor.add("red");
|
- |
|
| 420 |
values.add(leadStatusMap.get(LeadStatus.notInterested));
|
- |
|
| 421 |
}
|
- |
|
| 422 |
if (hotLead.equals("followUp")) {
|
- |
|
| 423 |
backgroundColor.add("#9ACD32");
|
- |
|
| 424 |
values.add(leadStatusMap.get(LeadStatus.followUp));
|
- |
|
| 425 |
}
|
- |
|
| 426 |
if (hotLead.equals("finalized")) {
|
- |
|
| 427 |
backgroundColor.add("blue");
|
- |
|
| 428 |
values.add(leadStatusMap.get(LeadStatus.finalized));
|
- |
|
| 429 |
}
|
- |
|
| 430 |
|
526 |
|
| 431 |
if (hotLead.equals("HotLead")) {
|
527 |
model.addAttribute("size", size);
|
| 432 |
backgroundColor.add("green");
|
528 |
}
|
| 433 |
values.add(hotLeadsMap.get("Green"));
|
- |
|
| 434 |
|
529 |
|
| - |
|
530 |
model.addAttribute("authUsers", authUsers);
|
| - |
|
531 |
return "lead-close";
|
| 435 |
}
|
532 |
}
|
| 436 |
|
533 |
|
| 437 |
}
|
- |
|
| - |
|
534 |
@RequestMapping(value = "/getPaginatedClosedLeads", method = RequestMethod.GET)
|
| - |
|
535 |
public String getPaginatedClosedLeads(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws ProfitMandiBusinessException {
|
| 438 |
LOGGER.info("labelList" + labelList);
|
536 |
List<Lead> leads = null;
|
| - |
|
537 |
leads = leadRepository.selectAllByStatus(status, offset, limit);
|
| 439 |
|
538 |
|
| - |
|
539 |
if (!leads.isEmpty()) {
|
| 440 |
LOGGER.info("backgroundColor" + backgroundColor);
|
540 |
List<Integer> authIds = new ArrayList<>();
|
| 441 |
LOGGER.info("labelsChartLead" + labels);
|
541 |
for (Lead lead : leads) {
|
| 442 |
LeadStatusData data = new LeadStatusData();
|
542 |
authIds.add(lead.getAssignTo());
|
| 443 |
data.setData(values);
|
543 |
}
|
| - |
|
544 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
545 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| 444 |
data.setBackgroundColor(backgroundColor);
|
546 |
model.addAttribute("leads", leads);
|
| 445 |
data.setLabel("DataSet 1");
|
547 |
model.addAttribute("url", "/getPaginatedClosedLeads");
|
| 446 |
|
548 |
|
| 447 |
PieLables label = new PieLables();
|
549 |
} else {
|
| 448 |
label.setFontColor("black");
|
550 |
model.addAttribute("leads", leads);
|
| 449 |
label.setFontSize(15);
|
- |
|
| 450 |
|
551 |
|
| 451 |
Legend legend = new Legend();
|
552 |
}
|
| 452 |
legend.setLabels(label);
|
553 |
return "lead-close-paginated";
|
| 453 |
legend.setPosition("left");
|
554 |
}
|
| 454 |
|
555 |
|
| - |
|
556 |
@RequestMapping(value = "/searchLeads")
|
| 455 |
List<LeadStatusData> dataList = new ArrayList<>();
|
557 |
public String getClosedLeads(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 ProfitMandiBusinessException {
|
| - |
|
558 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| 456 |
dataList.add(data);
|
559 |
List<Lead> leads = null;
|
| - |
|
560 |
long size = 0;
|
| - |
|
561 |
if (!(searchTerm.equals(""))) {
|
| - |
|
562 |
leads = leadRepository.selectBySearchTerm(status, searchTerm, offset, limit);
|
| - |
|
563 |
if (!(leads.size() == 0)) {
|
| - |
|
564 |
size = leadRepository.selectCountByStatus(status);
|
| - |
|
565 |
List<Integer> authIds = new ArrayList<>();
|
| - |
|
566 |
for (Lead lead : leads) {
|
| - |
|
567 |
authIds.add(lead.getAssignTo());
|
| - |
|
568 |
}
|
| - |
|
569 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
570 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
571 |
model.addAttribute("leads", leads);
|
| - |
|
572 |
model.addAttribute("start", offset + 1);
|
| - |
|
573 |
model.addAttribute("size", size);
|
| - |
|
574 |
model.addAttribute("searchTerm", searchTerm);
|
| 457 |
|
575 |
|
| - |
|
576 |
if (leads.size() < limit) {
|
| 458 |
DataLeadModel datasets = new DataLeadModel();
|
577 |
model.addAttribute("end", offset + leads.size());
|
| 459 |
datasets.setDatasets(dataList);
|
578 |
} else {
|
| - |
|
579 |
model.addAttribute("end", offset + limit);
|
| - |
|
580 |
}
|
| 460 |
datasets.setLabels(hotLeads);
|
581 |
} else {
|
| - |
|
582 |
throw new ProfitMandiBusinessException("lead", searchTerm, "leads Not Found");
|
| - |
|
583 |
}
|
| - |
|
584 |
} else {
|
| - |
|
585 |
leads = leadRepository.selectAllByStatus(status, offset, limit);
|
| - |
|
586 |
size = leadRepository.selectCountByStatus(status);
|
| 461 |
|
587 |
|
| 462 |
OptionModel om = new OptionModel();
|
588 |
if (!leads.isEmpty()) {
|
| - |
|
589 |
List<Integer> authIds = new ArrayList<>();
|
| 463 |
om.setLegend(legend);
|
590 |
for (Lead lead : leads) {
|
| - |
|
591 |
authIds.add(lead.getAssignTo());
|
| - |
|
592 |
}
|
| - |
|
593 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 464 |
|
594 |
|
| 465 |
cm.setType("pie");
|
595 |
model.addAttribute("leads", leads);
|
| 466 |
cm.setData(datasets);
|
596 |
model.addAttribute("start", offset + 1);
|
| 467 |
cm.setOptions(om);
|
597 |
model.addAttribute("size", size);
|
| - |
|
598 |
model.addAttribute("searchTerm", searchTerm);
|
| - |
|
599 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| 468 |
|
600 |
|
| - |
|
601 |
if (leads.size() < limit) {
|
| - |
|
602 |
model.addAttribute("end", offset + leads.size());
|
| 469 |
return cm;
|
603 |
} else {
|
| - |
|
604 |
model.addAttribute("end", offset + limit);
|
| 470 |
}
|
605 |
}
|
| 471 |
|
606 |
|
| 472 |
@RequestMapping(value = "/getClosedLead", method = RequestMethod.GET)
|
- |
|
| 473 |
public String getClosedLead(HttpServletRequest request,
|
- |
|
| 474 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 475 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
- |
|
| 476 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
- |
|
| 477 |
throws Exception {
|
607 |
}
|
| 478 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
- |
|
| 479 |
List<Lead> leads = null;
|
- |
|
| 480 |
long size = 0;
|
608 |
}
|
| 481 |
leads = leadRepository.selectAllByStatus(status, offset, limit);
|
- |
|
| 482 |
size = leadRepository.selectCountByStatus(status);
|
- |
|
| 483 |
|
609 |
|
| 484 |
if (!leads.isEmpty()) {
|
- |
|
| 485 |
List<Integer> authIds = new ArrayList<>();
|
610 |
model.addAttribute("authUsers", authUsers);
|
| 486 |
for (Lead lead : leads) {
|
611 |
return "lead-close";
|
| 487 |
authIds.add(lead.getAssignTo());
|
- |
|
| 488 |
}
|
612 |
}
|
| 489 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
- |
|
| 490 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 491 |
|
613 |
|
| - |
|
614 |
@RequestMapping(value = "/searchLeadPaginated")
|
| 492 |
model.addAttribute("leads", leads);
|
615 |
public String searchLeadPaginated(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 ProfitMandiBusinessException {
|
| 493 |
model.addAttribute("start", offset + 1);
|
616 |
LOGGER.info("In search Item....");
|
| 494 |
model.addAttribute("size", size);
|
617 |
List<Lead> leads = null;
|
| 495 |
model.addAttribute("searchTerm", searchTerm);
|
618 |
if (!searchTerm.equals("")) {
|
| 496 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
619 |
leads = leadRepository.selectBySearchTerm(status, searchTerm, offset, limit);
|
| 497 |
model.addAttribute("url", "/getPaginatedClosedLeads");
|
620 |
if (!(leads.size() == 0)) {
|
| 498 |
|
621 |
|
| - |
|
622 |
List<Integer> authIds = new ArrayList<>();
|
| 499 |
if (leads.size() < limit) {
|
623 |
for (Lead lead : leads) {
|
| 500 |
model.addAttribute("end", offset + leads.size());
|
624 |
authIds.add(lead.getAssignTo());
|
| 501 |
} else {
|
625 |
}
|
| - |
|
626 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
627 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| 502 |
model.addAttribute("end", offset + limit);
|
628 |
model.addAttribute("leads", leads);
|
| - |
|
629 |
}
|
| 503 |
}
|
630 |
}
|
| 504 |
|
631 |
|
| 505 |
} else {
|
- |
|
| 506 |
model.addAttribute("lead", leads);
|
632 |
return "lead-close-paginated";
|
| 507 |
|
633 |
|
| 508 |
model.addAttribute("size", size);
|
- |
|
| 509 |
}
|
634 |
}
|
| 510 |
|
635 |
|
| 511 |
model.addAttribute("authUsers", authUsers);
|
636 |
@RequestMapping(value = "/getLeadActivity", method = RequestMethod.GET)
|
| - |
|
637 |
public String getLeadActivity(HttpServletRequest request, @RequestParam int leadId, Model model) throws Exception {
|
| 512 |
return "lead-close";
|
638 |
List<LeadActivity> leadActivity = leadActivityRepository.selectBYLeadId(leadId);
|
| 513 |
}
|
- |
|
| 514 |
|
639 |
|
| 515 |
@RequestMapping(value = "/getPaginatedClosedLeads", method = RequestMethod.GET)
|
- |
|
| 516 |
public String getPaginatedClosedLeads(HttpServletRequest request,
|
- |
|
| 517 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 518 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
- |
|
| 519 |
throws ProfitMandiBusinessException {
|
- |
|
| 520 |
List<Lead> leads = null;
|
- |
|
| 521 |
leads = leadRepository.selectAllByStatus(status, offset, limit);
|
640 |
LOGGER.info("leadActivity" + leadActivity);
|
| 522 |
|
641 |
|
| 523 |
if (!leads.isEmpty()) {
|
- |
|
| 524 |
List<Integer> authIds = new ArrayList<>();
|
- |
|
| 525 |
for (Lead lead : leads) {
|
- |
|
| 526 |
authIds.add(lead.getAssignTo());
|
- |
|
| 527 |
}
|
- |
|
| 528 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
- |
|
| 529 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 530 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
- |
|
| 531 |
model.addAttribute("leads", leads);
|
642 |
model.addAttribute("leadActivity", leadActivity);
|
| 532 |
model.addAttribute("url", "/getPaginatedClosedLeads");
|
643 |
model.addAttribute("authUserMap", authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x)));
|
| 533 |
|
644 |
|
| - |
|
645 |
return "lead_activity_modal";
|
| 534 |
} else {
|
646 |
}
|
| 535 |
model.addAttribute("leads", leads);
|
- |
|
| 536 |
|
647 |
|
| 537 |
}
|
- |
|
| - |
|
648 |
@RequestMapping(value = "/getLead", method = RequestMethod.GET)
|
| - |
|
649 |
public ResponseEntity<?> getLead(HttpServletRequest request, @RequestParam int leadId) throws Exception {
|
| 538 |
return "lead-close-paginated";
|
650 |
Lead lead = leadRepository.selectById(leadId);
|
| 539 |
}
|
- |
|
| 540 |
|
651 |
|
| 541 |
@RequestMapping(value = "/searchLeads")
|
- |
|
| 542 |
public String getClosedLeads(HttpServletRequest request,
|
- |
|
| 543 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 544 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
- |
|
| 545 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
- |
|
| 546 |
throws ProfitMandiBusinessException {
|
- |
|
| 547 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
652 |
LeadDetail leadDetail = leadDetailRepository.selectByLeadId(lead.getId());
|
| 548 |
List<Lead> leads = null;
|
- |
|
| 549 |
long size = 0;
|
- |
|
| 550 |
if (!(searchTerm.equals(""))) {
|
- |
|
| 551 |
leads = leadRepository.selectBySearchTerm(status, searchTerm, offset, limit);
|
- |
|
| 552 |
if (!(leads.size() == 0)) {
|
653 |
if (leadDetail != null) {
|
| 553 |
size = leadRepository.selectCountByStatus(status);
|
654 |
lead.setOutLetName(leadDetail.getOutletName());
|
| 554 |
List<Integer> authIds = new ArrayList<>();
|
- |
|
| 555 |
for (Lead lead : leads) {
|
- |
|
| 556 |
authIds.add(lead.getAssignTo());
|
- |
|
| 557 |
}
|
655 |
}
|
| 558 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
- |
|
| 559 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 560 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
- |
|
| 561 |
model.addAttribute("leads", leads);
|
- |
|
| 562 |
model.addAttribute("start", offset + 1);
|
- |
|
| 563 |
model.addAttribute("size", size);
|
- |
|
| 564 |
model.addAttribute("searchTerm", searchTerm);
|
- |
|
| 565 |
|
656 |
|
| 566 |
if (leads.size() < limit) {
|
- |
|
| 567 |
model.addAttribute("end", offset + leads.size());
|
- |
|
| 568 |
} else {
|
- |
|
| 569 |
model.addAttribute("end", offset + limit);
|
- |
|
| 570 |
}
|
- |
|
| 571 |
} else {
|
- |
|
| 572 |
throw new ProfitMandiBusinessException("lead", searchTerm, "leads Not Found");
|
- |
|
| 573 |
}
|
- |
|
| 574 |
} else {
|
- |
|
| 575 |
leads = leadRepository.selectAllByStatus(status, offset, limit);
|
- |
|
| 576 |
size = leadRepository.selectCountByStatus(status);
|
657 |
return responseSender.ok(lead);
|
| 577 |
|
658 |
|
| 578 |
if (!leads.isEmpty()) {
|
- |
|
| 579 |
List<Integer> authIds = new ArrayList<>();
|
- |
|
| 580 |
for (Lead lead : leads) {
|
- |
|
| 581 |
authIds.add(lead.getAssignTo());
|
- |
|
| 582 |
}
|
659 |
}
|
| 583 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
- |
|
| 584 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 585 |
|
660 |
|
| 586 |
model.addAttribute("leads", leads);
|
- |
|
| 587 |
model.addAttribute("start", offset + 1);
|
661 |
@RequestMapping(value = "/createLead", method = RequestMethod.POST)
|
| 588 |
model.addAttribute("size", size);
|
- |
|
| 589 |
model.addAttribute("searchTerm", searchTerm);
|
662 |
public String CreateLead(HttpServletRequest request, @RequestBody CreateRefferalRequest createRefferalRequest, Model model) throws Exception {
|
| 590 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
663 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 591 |
|
664 |
|
| - |
|
665 |
LOGGER.info("createRefferalRequest" + createRefferalRequest.getSchelduleTimestamp());
|
| 592 |
if (leads.size() < limit) {
|
666 |
Lead lead = new Lead();
|
| - |
|
667 |
lead.setFirstName(createRefferalRequest.getFirstName());
|
| - |
|
668 |
lead.setLastName(createRefferalRequest.getLastName());
|
| - |
|
669 |
lead.setLeadMobile(createRefferalRequest.getMobile());
|
| - |
|
670 |
lead.setState(createRefferalRequest.getState());
|
| 593 |
model.addAttribute("end", offset + leads.size());
|
671 |
lead.setCity(createRefferalRequest.getCity());
|
| - |
|
672 |
lead.setAddress(createRefferalRequest.getAddress());
|
| - |
|
673 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
674 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
675 |
lead.setStatus(createRefferalRequest.getStatus());
|
| - |
|
676 |
lead.setAssignTo(createRefferalRequest.getAssignTo());
|
| - |
|
677 |
lead.setSource(createRefferalRequest.getSource());
|
| - |
|
678 |
lead.setColor("yellow");
|
| 594 |
} else {
|
679 |
// change
|
| - |
|
680 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| - |
|
681 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
| - |
|
682 |
lead.setCreatedBy(authUserName);
|
| - |
|
683 |
lead.setAuthId(authUser.getId());
|
| - |
|
684 |
LOGGER.info("lead --- {}", lead);
|
| - |
|
685 |
leadRepository.persist(lead);
|
| - |
|
686 |
LeadActivity leadActivity = new LeadActivity();
|
| 595 |
model.addAttribute("end", offset + limit);
|
687 |
leadActivity.setLeadId(lead.getId());
|
| 596 |
}
|
- |
|
| - |
|
688 |
leadActivity.setRemark(createRefferalRequest.getRemark());
|
| - |
|
689 |
leadActivity.setAuthId(authUser.getId());
|
| - |
|
690 |
LOGGER.info("createRefferalRequest" + createRefferalRequest.getCommunicationType());
|
| 597 |
|
691 |
|
| 598 |
}
|
- |
|
| 599 |
}
|
- |
|
| - |
|
692 |
if (createRefferalRequest.getStatus() == LeadStatus.followUp) {
|
| - |
|
693 |
leadActivity.setSchelduleTimestamp(createRefferalRequest.getSchelduleTimestamp());
|
| - |
|
694 |
leadActivity.setCommunicationType(createRefferalRequest.getCommunicationType());
|
| 600 |
|
695 |
|
| 601 |
model.addAttribute("authUsers", authUsers);
|
696 |
if (leadActivity.getCommunicationType().equals(CommunicationType.VISIT)) {
|
| - |
|
697 |
visitRequestRepository.createVisitRequest(lead.getId(), "lead", lead.getAssignTo(), createRefferalRequest.getSchelduleTimestamp());
|
| - |
|
698 |
}
|
| 602 |
return "lead-close";
|
699 |
} else {
|
| - |
|
700 |
leadActivity.setSchelduleTimestamp(null);
|
| 603 |
}
|
701 |
}
|
| - |
|
702 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
703 |
leadActivityRepository.persist(leadActivity);
|
| 604 |
|
704 |
|
| 605 |
@RequestMapping(value = "/searchLeadPaginated")
|
705 |
LeadDetailModel leadDetail = new LeadDetailModel();
|
| 606 |
public String searchLeadPaginated(HttpServletRequest request,
|
706 |
leadDetail.setLeadId(lead.getId());
|
| 607 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
- |
|
| 608 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
707 |
leadDetail.setOutletName(createRefferalRequest.getOutletName());
|
| 609 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
- |
|
| 610 |
throws ProfitMandiBusinessException {
|
- |
|
| 611 |
LOGGER.info("In search Item....");
|
- |
|
| 612 |
List<Lead> leads = null;
|
- |
|
| 613 |
if (!searchTerm.equals("")) {
|
- |
|
| 614 |
leads = leadRepository.selectBySearchTerm(status, searchTerm, offset, limit);
|
708 |
leadDetail.setCounterSize(createRefferalRequest.getCounterSize());
|
| 615 |
if (!(leads.size() == 0)) {
|
- |
|
| 616 |
|
709 |
|
| 617 |
List<Integer> authIds = new ArrayList<>();
|
- |
|
| 618 |
for (Lead lead : leads) {
|
- |
|
| 619 |
authIds.add(lead.getAssignTo());
|
- |
|
| 620 |
}
|
- |
|
| 621 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
- |
|
| 622 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 623 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
- |
|
| 624 |
model.addAttribute("leads", leads);
|
- |
|
| 625 |
}
|
- |
|
| 626 |
}
|
- |
|
| 627 |
|
710 |
|
| 628 |
return "lead-close-paginated";
|
711 |
leadDetail.setFrontp(createRefferalRequest.getFrontp());
|
| - |
|
712 |
leadDetail.setFrontWithMarket(createRefferalRequest.getFrontWithMarket());
|
| 629 |
|
713 |
|
| 630 |
}
|
- |
|
| 631 |
|
714 |
|
| 632 |
@RequestMapping(value = "/getLeadActivity", method = RequestMethod.GET)
|
- |
|
| 633 |
public String getLeadActivity(HttpServletRequest request, @RequestParam int leadId, Model model) throws Exception {
|
- |
|
| 634 |
List<LeadActivity> leadActivity = leadActivityRepository.selectBYLeadId(leadId);
|
715 |
leadDetail.setInternalLongShot(createRefferalRequest.getInternalLongShot());
|
| 635 |
|
716 |
|
| 636 |
LOGGER.info("leadActivity" + leadActivity);
|
717 |
leadDetail.setInternalLeftWall(createRefferalRequest.getInternalLeftWall());
|
| 637 |
|
718 |
|
| 638 |
model.addAttribute("leadActivity", leadActivity);
|
719 |
leadDetail.setInternalRightWall(createRefferalRequest.getInternalRightWall());
|
| 639 |
model.addAttribute("authUserMap",
|
- |
|
| 640 |
authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x)));
|
720 |
List<LeadBrandModel> brandModels = new ArrayList<LeadBrandModel>();
|
| 641 |
|
721 |
|
| 642 |
return "lead_activity_modal";
|
722 |
for (LeadBrandModel leadBrandModel : createRefferalRequest.getLeadBrands()) {
|
| 643 |
}
|
- |
|
| 644 |
|
723 |
|
| 645 |
@RequestMapping(value = "/getLead", method = RequestMethod.GET)
|
724 |
LeadBrandModel leadBrand = new LeadBrandModel();
|
| 646 |
public ResponseEntity<?> getLead(HttpServletRequest request, @RequestParam int leadId) throws Exception {
|
725 |
leadBrand.setBrand(leadBrandModel.getBrand());
|
| 647 |
Lead lead = leadRepository.selectById(leadId);
|
726 |
leadBrand.setValue(leadBrandModel.getValue());
|
| 648 |
|
727 |
|
| 649 |
LeadDetail leadDetail = leadDetailRepository.selectByLeadId(lead.getId());
|
- |
|
| 650 |
if (leadDetail != null) {
|
- |
|
| 651 |
lead.setOutLetName(leadDetail.getOutletName());
|
728 |
brandModels.add(leadBrand);
|
| 652 |
}
|
- |
|
| 653 |
|
729 |
|
| 654 |
return responseSender.ok(lead);
|
730 |
}
|
| 655 |
|
731 |
|
| 656 |
}
|
- |
|
| - |
|
732 |
leadDetail.setLeadBrands(brandModels);
|
| 657 |
|
733 |
|
| 658 |
@RequestMapping(value = "/createLead", method = RequestMethod.POST)
|
734 |
this.persistLeadDetail(leadDetail, authUser);
|
| 659 |
public String CreateLead(HttpServletRequest request, @RequestBody CreateRefferalRequest createRefferalRequest,
|
735 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 660 |
Model model) throws Exception {
|
- |
|
| 661 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 662 |
|
736 |
|
| 663 |
LOGGER.info("createRefferalRequest" + createRefferalRequest.getSchelduleTimestamp());
|
- |
|
| 664 |
Lead lead = new Lead();
|
- |
|
| 665 |
lead.setFirstName(createRefferalRequest.getFirstName());
|
- |
|
| 666 |
lead.setLastName(createRefferalRequest.getLastName());
|
- |
|
| 667 |
lead.setLeadMobile(createRefferalRequest.getMobile());
|
- |
|
| 668 |
lead.setState(createRefferalRequest.getState());
|
- |
|
| 669 |
lead.setCity(createRefferalRequest.getCity());
|
- |
|
| 670 |
lead.setAddress(createRefferalRequest.getAddress());
|
- |
|
| 671 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
- |
|
| 672 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
- |
|
| 673 |
lead.setStatus(createRefferalRequest.getStatus());
|
- |
|
| 674 |
lead.setAssignTo(createRefferalRequest.getAssignTo());
|
- |
|
| 675 |
lead.setSource(createRefferalRequest.getSource());
|
- |
|
| 676 |
lead.setColor("yellow");
|
737 |
return "response";
|
| 677 |
// change
|
- |
|
| 678 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
- |
|
| 679 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
- |
|
| 680 |
lead.setCreatedBy(authUserName);
|
- |
|
| 681 |
lead.setAuthId(authUser.getId());
|
- |
|
| 682 |
LOGGER.info("lead --- {}", lead);
|
- |
|
| 683 |
leadRepository.persist(lead);
|
- |
|
| 684 |
LeadActivity leadActivity = new LeadActivity();
|
- |
|
| 685 |
leadActivity.setLeadId(lead.getId());
|
- |
|
| 686 |
leadActivity.setRemark(createRefferalRequest.getRemark());
|
- |
|
| 687 |
leadActivity.setAuthId(authUser.getId());
|
- |
|
| 688 |
LOGGER.info("createRefferalRequest" + createRefferalRequest.getCommunicationType());
|
- |
|
| 689 |
|
738 |
|
| 690 |
if (createRefferalRequest.getStatus() == LeadStatus.followUp) {
|
- |
|
| 691 |
leadActivity.setSchelduleTimestamp(createRefferalRequest.getSchelduleTimestamp());
|
- |
|
| 692 |
leadActivity.setCommunicationType(createRefferalRequest.getCommunicationType());
|
- |
|
| - |
|
739 |
}
|
| 693 |
|
740 |
|
| 694 |
if (leadActivity.getCommunicationType().equals(CommunicationType.VISIT)) {
|
741 |
private void persistLeadDetail(LeadDetailModel leadDetailModel, AuthUser authUser) throws ProfitMandiBusinessException {
|
| 695 |
visitRequestRepository.createVisitRequest(lead.getId(), "lead", lead.getAssignTo(),
|
742 |
LeadDetail leadDetail = leadDetailRepository.selectByLeadId(leadDetailModel.getLeadId());
|
| 696 |
createRefferalRequest.getSchelduleTimestamp());
|
743 |
if (leadDetail == null) {
|
| 697 |
}
|
- |
|
| 698 |
} else {
|
744 |
leadDetail = new LeadDetail();
|
| 699 |
leadActivity.setSchelduleTimestamp(null);
|
745 |
leadDetail.setLeadId(leadDetailModel.getLeadId());
|
| 700 |
}
|
- |
|
| 701 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
746 |
leadDetail.setOutletName(leadDetailModel.getOutletName());
|
| 702 |
leadActivityRepository.persist(leadActivity);
|
747 |
leadDetail.setCounterSize(leadDetailModel.getCounterSize());
|
| 703 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
748 |
leadDetail.setCreatedBy(authUser.getId());
|
| 704 |
|
749 |
|
| 705 |
return "response";
|
- |
|
| - |
|
750 |
LOGGER.info("dd {}", leadDetailModel.getFrontp(), leadDetailModel.getFrontWithMarket(), leadDetailModel.getInternalLongShot(), leadDetailModel.getInternalLeftWall(), leadDetailModel.getInternalRightWall());
|
| 706 |
|
751 |
|
| - |
|
752 |
if (leadDetailModel.getFrontp() != 0) {
|
| - |
|
753 |
leadDetail.setFrontp(leadDetailModel.getFrontp());
|
| 707 |
}
|
754 |
} else {
|
| - |
|
755 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Front Image is Required");
|
| 708 |
|
756 |
|
| 709 |
@RequestMapping(value = "/editLead", method = RequestMethod.POST)
|
- |
|
| 710 |
public String EditLead(HttpServletRequest request,
|
757 |
}
|
| 711 |
@RequestBody CreateLeacdActivityRequest createLeadActivityRequest, Model model) throws Exception {
|
- |
|
| 712 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 713 |
|
758 |
|
| - |
|
759 |
if (leadDetailModel.getFrontWithMarket() != 0) {
|
| 714 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
760 |
leadDetail.setFrontWithMarket(leadDetailModel.getFrontWithMarket());
|
| - |
|
761 |
} else {
|
| - |
|
762 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Front With Market Image is Required");
|
| 715 |
|
763 |
|
| 716 |
LeadDetail leadDetail = leadDetailRepository.selectByLeadId(createLeadActivityRequest.getId());
|
- |
|
| - |
|
764 |
}
|
| 717 |
|
765 |
|
| 718 |
if (leadDetail == null && !createLeadActivityRequest.getStatus().equals(LeadStatus.notInterested)) {
|
766 |
if (leadDetailModel.getInternalLongShot() != 0) {
|
| 719 |
|
767 |
|
| - |
|
768 |
leadDetail.setInternalLongShot(leadDetailModel.getInternalLongShot());
|
| - |
|
769 |
} else {
|
| 720 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Please fill lead detail");
|
770 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Internal Long Shot Image is Required");
|
| 721 |
}
|
- |
|
| 722 |
|
771 |
|
| 723 |
LeadActivity leadActivity = new LeadActivity();
|
772 |
}
|
| 724 |
leadActivity.setLeadId(createLeadActivityRequest.getId());
|
- |
|
| 725 |
leadActivity.setRemark(createLeadActivityRequest.getRemark());
|
- |
|
| 726 |
|
773 |
|
| 727 |
LOGGER.info("createRefferalRequest" + createLeadActivityRequest);
|
774 |
if (leadDetailModel.getInternalLeftWall() != 0) {
|
| 728 |
|
775 |
|
| 729 |
if (createLeadActivityRequest.getStatus() == LeadStatus.followUp) {
|
- |
|
| 730 |
leadActivity.setSchelduleTimestamp(createLeadActivityRequest.getScheldule());
|
776 |
leadDetail.setInternalLeftWall(leadDetailModel.getInternalLeftWall());
|
| 731 |
leadActivity.setCommunicationType(createLeadActivityRequest.getCommunicationType());
|
- |
|
| 732 |
if (leadActivity.getCommunicationType().equals(CommunicationType.VISIT)) {
|
- |
|
| 733 |
visitRequestRepository.createVisitRequest(createLeadActivityRequest.getId(), "lead",
|
- |
|
| 734 |
createLeadActivityRequest.getAssignTo(), createLeadActivityRequest.getScheldule());
|
- |
|
| 735 |
}
|
- |
|
| 736 |
} else {
|
777 |
} else {
|
| 737 |
leadActivity.setSchelduleTimestamp(null);
|
- |
|
| 738 |
}
|
- |
|
| 739 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
- |
|
| 740 |
leadActivity.setAuthId(authUser.getId());
|
- |
|
| 741 |
leadActivityRepository.persist(leadActivity);
|
- |
|
| 742 |
Lead lead = leadRepository.selectById(createLeadActivityRequest.getId());
|
- |
|
| 743 |
lead.setAssignTo(createLeadActivityRequest.getAssignTo());
|
- |
|
| 744 |
lead.setStatus(createLeadActivityRequest.getStatus());
|
- |
|
| 745 |
lead.setNotinterestedReason(createLeadActivityRequest.getReason());
|
778 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Internal Left Wall Image is Required");
|
| 746 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
- |
|
| 747 |
|
779 |
|
| - |
|
780 |
}
|
| 748 |
lead = leadRepository.selectById(createLeadActivityRequest.getId());
|
781 |
if (leadDetailModel.getInternalRightWall() != 0) {
|
| 749 |
|
782 |
|
| 750 |
int authId = 0;
|
783 |
leadDetail.setInternalRightWall(leadDetailModel.getInternalRightWall());
|
| 751 |
if (lead != null) {
|
784 |
} else {
|
| - |
|
785 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Internal Right Wall Image is Required");
|
| 752 |
|
786 |
|
| 753 |
authId = lead.getAssignTo();
|
787 |
}
|
| 754 |
Map<Integer, LeadActivity> leadActivityMap = new HashMap<>();
|
- |
|
| 755 |
|
788 |
|
| 756 |
List<LeadActivity> leadActivitys = leadActivityRepository.selectBYLeadId(lead.getId());
|
789 |
leadDetail.setCreatedTimestamp(LocalDateTime.now());
|
| 757 |
|
790 |
|
| 758 |
if (!leadActivitys.isEmpty()) {
|
791 |
leadDetailRepository.persist(leadDetail);
|
| 759 |
leadActivityMap.put(lead.getId(), leadActivitys.get(0));
|
792 |
for (LeadBrandModel leadBrandModel : leadDetailModel.getLeadBrands()) {
|
| 760 |
}
|
- |
|
| 761 |
|
793 |
|
| 762 |
Map<Integer, AuthUser> authIdAndAuthUserMap = new HashMap<>();
|
794 |
LeadBrand leadBrand = new LeadBrand();
|
| - |
|
795 |
leadBrand.setBrand(leadBrandModel.getBrand());
|
| - |
|
796 |
leadBrand.setValue(leadBrandModel.getValue());
|
| - |
|
797 |
leadBrand.setLeadDetailId(leadDetail.getId());
|
| - |
|
798 |
leadBrand.setLeadId(leadDetail.getLeadId());
|
| - |
|
799 |
leadBrand.setCreatedTimestamp(LocalDateTime.now());
|
| 763 |
AuthUser AuthUser = authRepository.selectById(authId);
|
800 |
leadBrandRepository.persist(leadBrand);
|
| 764 |
|
801 |
|
| - |
|
802 |
}
|
| - |
|
803 |
} else {
|
| 765 |
authIdAndAuthUserMap.put(AuthUser.getId(), AuthUser);
|
804 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Lead Detail Already Created");
|
| - |
|
805 |
}
|
| 766 |
|
806 |
|
| 767 |
model.addAttribute("leadActivityMap", leadActivityMap);
|
- |
|
| 768 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
- |
|
| 769 |
}
|
- |
|
| 770 |
|
807 |
|
| 771 |
model.addAttribute("request", lead);
|
808 |
}
|
| 772 |
|
809 |
|
| 773 |
return "edit-lead";
|
810 |
@RequestMapping(value = "/editLead", method = RequestMethod.POST)
|
| - |
|
811 |
public String EditLead(HttpServletRequest request, @RequestBody CreateLeacdActivityRequest createLeadActivityRequest, Model model) throws Exception {
|
| - |
|
812 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 774 |
|
813 |
|
| 775 |
}
|
- |
|
| - |
|
814 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 776 |
|
815 |
|
| 777 |
@RequestMapping(value = "/downloadIvoryLead", method = RequestMethod.GET)
|
- |
|
| 778 |
public ResponseEntity<?> downloadDelayDayTemplate(HttpServletRequest request) throws Exception {
|
- |
|
| 779 |
List<String> stateNames = stateRepository.selectAll().stream().map(x -> x.getName())
|
816 |
LeadDetail leadDetail = leadDetailRepository.selectByLeadId(createLeadActivityRequest.getId());
|
| 780 |
.collect(Collectors.toList());
|
- |
|
| 781 |
|
817 |
|
| 782 |
List<List<?>> rows = new ArrayList<>();
|
818 |
if (leadDetail == null && !createLeadActivityRequest.getStatus().equals(LeadStatus.notInterested)) {
|
| 783 |
|
819 |
|
| 784 |
List<LeadSource> lss = LeadSource.enumValues;
|
820 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Please fill lead detail");
|
| - |
|
821 |
}
|
| 785 |
|
822 |
|
| 786 |
for (LeadSource ls : lss) {
|
823 |
LeadActivity leadActivity = new LeadActivity();
|
| 787 |
rows.add(Arrays.asList("-", "-", "-", "-", "-", "-", "-", ls));
|
824 |
leadActivity.setLeadId(createLeadActivityRequest.getId());
|
| - |
|
825 |
leadActivity.setRemark(createLeadActivityRequest.getRemark());
|
| 788 |
|
826 |
|
| 789 |
}
|
- |
|
| 790 |
for (String stateName : stateNames) {
|
- |
|
| 791 |
rows.add(Arrays.asList("-", "-", "-", "-", stateName, "-", "-", "-"));
|
827 |
LOGGER.info("createRefferalRequest" + createLeadActivityRequest);
|
| 792 |
|
828 |
|
| - |
|
829 |
if (createLeadActivityRequest.getStatus() == LeadStatus.followUp) {
|
| - |
|
830 |
leadActivity.setSchelduleTimestamp(createLeadActivityRequest.getScheldule());
|
| - |
|
831 |
leadActivity.setCommunicationType(createLeadActivityRequest.getCommunicationType());
|
| - |
|
832 |
if (leadActivity.getCommunicationType().equals(CommunicationType.VISIT)) {
|
| - |
|
833 |
visitRequestRepository.createVisitRequest(createLeadActivityRequest.getId(), "lead", createLeadActivityRequest.getAssignTo(), createLeadActivityRequest.getScheldule());
|
| - |
|
834 |
}
|
| - |
|
835 |
} else {
|
| - |
|
836 |
leadActivity.setSchelduleTimestamp(null);
|
| 793 |
}
|
837 |
}
|
| - |
|
838 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
839 |
leadActivity.setAuthId(authUser.getId());
|
| - |
|
840 |
leadActivityRepository.persist(leadActivity);
|
| - |
|
841 |
Lead lead = leadRepository.selectById(createLeadActivityRequest.getId());
|
| - |
|
842 |
lead.setAssignTo(createLeadActivityRequest.getAssignTo());
|
| - |
|
843 |
lead.setStatus(createLeadActivityRequest.getStatus());
|
| - |
|
844 |
lead.setNotinterestedReason(createLeadActivityRequest.getReason());
|
| - |
|
845 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
| 794 |
|
846 |
|
| 795 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(Arrays.asList("First Name",
|
- |
|
| 796 |
"Last Name", "Address", "City", "State", "Mobile", "Assign To(email)", "Source"), rows);
|
847 |
lead = leadRepository.selectById(createLeadActivityRequest.getId());
|
| 797 |
|
848 |
|
| 798 |
final HttpHeaders headers = new HttpHeaders();
|
849 |
int authId = 0;
|
| 799 |
headers.set("Content-Type", "text/csv");
|
850 |
if (lead != null) {
|
| 800 |
headers.set("Content-disposition", "inline; filename=leads.format.csv");
|
- |
|
| 801 |
headers.setContentLength(baos.toByteArray().length);
|
- |
|
| 802 |
|
851 |
|
| 803 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
852 |
authId = lead.getAssignTo();
|
| 804 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
- |
|
| 805 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
853 |
Map<Integer, LeadActivity> leadActivityMap = new HashMap<>();
|
| 806 |
|
854 |
|
| 807 |
}
|
- |
|
| - |
|
855 |
List<LeadActivity> leadActivitys = leadActivityRepository.selectBYLeadId(lead.getId());
|
| 808 |
|
856 |
|
| 809 |
@RequestMapping(value = "/csvFileAndSetLead", method = RequestMethod.POST)
|
857 |
if (!leadActivitys.isEmpty()) {
|
| 810 |
public String readCsvFileAndSetLead(HttpServletRequest request, Model model, HttpServletResponse response,
|
858 |
leadActivityMap.put(lead.getId(), leadActivitys.get(0));
|
| 811 |
@RequestPart MultipartFile file) throws Throwable {
|
859 |
}
|
| 812 |
|
860 |
|
| 813 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
861 |
Map<Integer, AuthUser> authIdAndAuthUserMap = new HashMap<>();
|
| 814 |
String email = loginDetails.getEmailId();
|
862 |
AuthUser AuthUser = authRepository.selectById(authId);
|
| 815 |
|
863 |
|
| 816 |
AuthUser createdBy = authRepository.selectByEmailOrMobile(email);
|
864 |
authIdAndAuthUserMap.put(AuthUser.getId(), AuthUser);
|
| 817 |
|
865 |
|
| 818 |
LOGGER.info("file" + file.toString());
|
866 |
model.addAttribute("leadActivityMap", leadActivityMap);
|
| - |
|
867 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
868 |
}
|
| 819 |
|
869 |
|
| 820 |
String fileName = file.getName();
|
870 |
model.addAttribute("request", lead);
|
| 821 |
|
871 |
|
| 822 |
String fileNames = file.getOriginalFilename();
|
872 |
return "edit-lead";
|
| 823 |
|
873 |
|
| 824 |
LOGGER.info("fileName" + fileName);
|
874 |
}
|
| 825 |
LOGGER.info("fileNames" + fileNames);
|
- |
|
| 826 |
|
875 |
|
| 827 |
List<CSVRecord> records = FileUtil.readFile(file);
|
876 |
@RequestMapping(value = "/downloadIvoryLead", method = RequestMethod.GET)
|
| - |
|
877 |
public ResponseEntity<?> downloadDelayDayTemplate(HttpServletRequest request) throws Exception {
|
| - |
|
878 |
List<String> stateNames = stateRepository.selectAll().stream().map(x -> x.getName()).collect(Collectors.toList());
|
| 828 |
|
879 |
|
| 829 |
for (CSVRecord record : records) {
|
880 |
List<List<?>> rows = new ArrayList<>();
|
| 830 |
|
881 |
|
| 831 |
Lead lead = new Lead();
|
- |
|
| 832 |
lead.setFirstName(record.get(0));
|
- |
|
| 833 |
lead.setLastName(record.get(1));
|
- |
|
| 834 |
lead.setAddress(record.get(2));
|
- |
|
| 835 |
lead.setCity(record.get(3));
|
- |
|
| 836 |
lead.setState(record.get(4));
|
- |
|
| 837 |
lead.setLeadMobile(record.get(5));
|
882 |
List<LeadSource> lss = LeadSource.enumValues;
|
| 838 |
LOGGER.info("record" + record.get(6));
|
- |
|
| 839 |
|
883 |
|
| - |
|
884 |
for (LeadSource ls : lss) {
|
| 840 |
AuthUser assignTo = authRepository.selectByEmailOrMobile(record.get(6));
|
885 |
rows.add(Arrays.asList("-", "-", "-", "-", "-", "-", "-", ls));
|
| 841 |
|
886 |
|
| - |
|
887 |
}
|
| 842 |
if (assignTo == null) {
|
888 |
for (String stateName : stateNames) {
|
| 843 |
throw new ProfitMandiBusinessException("Assign To ", record.get(6), "email id not exist");
|
889 |
rows.add(Arrays.asList("-", "-", "-", "-", stateName, "-", "-", "-"));
|
| 844 |
}
|
- |
|
| 845 |
|
890 |
|
| 846 |
lead.setAssignTo(assignTo.getId());
|
- |
|
| 847 |
lead.setSource(record.get(7));
|
891 |
}
|
| 848 |
|
892 |
|
| 849 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
893 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(Arrays.asList("First Name", "Last Name", "Address", "City", "State", "Mobile", "Assign To(email)", "Source"), rows);
|
| 850 |
|
894 |
|
| 851 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
895 |
final HttpHeaders headers = new HttpHeaders();
|
| 852 |
lead.setStatus(LeadStatus.pending);
|
896 |
headers.set("Content-Type", "text/csv");
|
| 853 |
lead.setColor("yellow");
|
- |
|
| 854 |
// change
|
- |
|
| 855 |
lead.setCreatedBy(createdBy.getFullName());
|
897 |
headers.set("Content-disposition", "inline; filename=leads.format.csv");
|
| 856 |
lead.setAuthId(createdBy.getId());
|
898 |
headers.setContentLength(baos.toByteArray().length);
|
| 857 |
|
899 |
|
| - |
|
900 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
| 858 |
leadRepository.persist(lead);
|
901 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| - |
|
902 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| 859 |
|
903 |
|
| 860 |
LeadActivity leadActivity = new LeadActivity();
|
904 |
}
|
| 861 |
leadActivity.setLeadId(lead.getId());
|
- |
|
| 862 |
leadActivity.setRemark("New Lead");
|
- |
|
| 863 |
leadActivity.setSchelduleTimestamp(null);
|
- |
|
| 864 |
|
905 |
|
| 865 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
906 |
@RequestMapping(value = "/csvFileAndSetLead", method = RequestMethod.POST)
|
| 866 |
leadActivityRepository.persist(leadActivity);
|
- |
|
| 867 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
907 |
public String readCsvFileAndSetLead(HttpServletRequest request, Model model, HttpServletResponse response, @RequestPart MultipartFile file) throws Throwable {
|
| 868 |
|
908 |
|
| 869 |
}
|
- |
|
| - |
|
909 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
910 |
String email = loginDetails.getEmailId();
|
| 870 |
|
911 |
|
| 871 |
model.addAttribute("responseSTG", mvcResponseSender.createResponseString(true));
|
912 |
AuthUser createdBy = authRepository.selectByEmailOrMobile(email);
|
| 872 |
|
913 |
|
| 873 |
return "response";
|
914 |
LOGGER.info("file" + file.toString());
|
| 874 |
|
915 |
|
| 875 |
}
|
- |
|
| - |
|
916 |
String fileName = file.getName();
|
| 876 |
|
917 |
|
| 877 |
@RequestMapping(value = "/teamCommitment", method = RequestMethod.GET)
|
918 |
String fileNames = file.getOriginalFilename();
|
| 878 |
public String teamCommitments(HttpServletRequest request, Model model) throws Exception {
|
- |
|
| 879 |
|
919 |
|
| 880 |
return "team-commitment";
|
920 |
LOGGER.info("fileName" + fileName);
|
| - |
|
921 |
LOGGER.info("fileNames" + fileNames);
|
| 881 |
|
922 |
|
| 882 |
}
|
- |
|
| - |
|
923 |
List<CSVRecord> records = FileUtil.readFile(file);
|
| 883 |
|
924 |
|
| 884 |
@RequestMapping(value = "/leadDetail", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
- |
|
| 885 |
public String leadDetail(HttpServletRequest request, @RequestBody LeadDetailModel leadDetailModel, Model model)
|
- |
|
| 886 |
throws Exception {
|
925 |
for (CSVRecord record : records) {
|
| 887 |
|
926 |
|
| 888 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
927 |
Lead lead = new Lead();
|
| 889 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
- |
|
| 890 |
LeadDetail leadDetail = leadDetailRepository.selectByLeadId(leadDetailModel.getLeadId());
|
928 |
lead.setFirstName(record.get(0));
|
| 891 |
if (leadDetail == null) {
|
929 |
lead.setLastName(record.get(1));
|
| 892 |
leadDetail = new LeadDetail();
|
930 |
lead.setAddress(record.get(2));
|
| 893 |
leadDetail.setLeadId(leadDetailModel.getLeadId());
|
931 |
lead.setCity(record.get(3));
|
| 894 |
leadDetail.setOutletName(leadDetailModel.getOutletName());
|
932 |
lead.setState(record.get(4));
|
| 895 |
leadDetail.setCounterSize(leadDetailModel.getCounterSize());
|
933 |
lead.setLeadMobile(record.get(5));
|
| 896 |
leadDetail.setCreatedBy(authUser.getId());
|
934 |
LOGGER.info("record" + record.get(6));
|
| 897 |
|
935 |
|
| 898 |
LOGGER.info("dd {}", leadDetailModel.getFrontp(), leadDetailModel.getFrontWithMarket(),
|
- |
|
| 899 |
leadDetailModel.getInternalLongShot(), leadDetailModel.getInternalLeftWall(),
|
936 |
AuthUser assignTo = authRepository.selectByEmailOrMobile(record.get(6));
|
| 900 |
leadDetailModel.getInternalRightWall());
|
- |
|
| 901 |
|
937 |
|
| 902 |
if (leadDetailModel.getFrontp() != 0) {
|
938 |
if (assignTo == null) {
|
| 903 |
leadDetail.setFrontp(leadDetailModel.getFrontp());
|
939 |
throw new ProfitMandiBusinessException("Assign To ", record.get(6), "email id not exist");
|
| 904 |
} else {
|
940 |
}
|
| 905 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Front Image is Required");
|
- |
|
| 906 |
|
941 |
|
| 907 |
}
|
- |
|
| - |
|
942 |
lead.setAssignTo(assignTo.getId());
|
| - |
|
943 |
lead.setSource(record.get(7));
|
| 908 |
|
944 |
|
| 909 |
if (leadDetailModel.getFrontWithMarket() != 0) {
|
945 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
| 910 |
leadDetail.setFrontWithMarket(leadDetailModel.getFrontWithMarket());
|
- |
|
| 911 |
} else {
|
- |
|
| 912 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Front With Market Image is Required");
|
- |
|
| 913 |
|
946 |
|
| - |
|
947 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
948 |
lead.setStatus(LeadStatus.pending);
|
| - |
|
949 |
lead.setColor("yellow");
|
| 914 |
}
|
950 |
// change
|
| - |
|
951 |
lead.setCreatedBy(createdBy.getFullName());
|
| - |
|
952 |
lead.setAuthId(createdBy.getId());
|
| 915 |
|
953 |
|
| 916 |
if (leadDetailModel.getInternalLongShot() != 0) {
|
954 |
leadRepository.persist(lead);
|
| 917 |
|
955 |
|
| 918 |
leadDetail.setInternalLongShot(leadDetailModel.getInternalLongShot());
|
956 |
LeadActivity leadActivity = new LeadActivity();
|
| - |
|
957 |
leadActivity.setLeadId(lead.getId());
|
| 919 |
} else {
|
958 |
leadActivity.setRemark("New Lead");
|
| 920 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Internal Long Shot Image is Required");
|
959 |
leadActivity.setSchelduleTimestamp(null);
|
| 921 |
|
960 |
|
| 922 |
}
|
- |
|
| - |
|
961 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
962 |
leadActivityRepository.persist(leadActivity);
|
| - |
|
963 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 923 |
|
964 |
|
| 924 |
if (leadDetailModel.getInternalLeftWall() != 0) {
|
965 |
}
|
| 925 |
|
966 |
|
| 926 |
leadDetail.setInternalLeftWall(leadDetailModel.getInternalLeftWall());
|
967 |
model.addAttribute("responseSTG", mvcResponseSender.createResponseString(true));
|
| 927 |
} else {
|
- |
|
| 928 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Internal Left Wall Image is Required");
|
- |
|
| 929 |
|
968 |
|
| 930 |
}
|
- |
|
| 931 |
if (leadDetailModel.getInternalRightWall() != 0) {
|
969 |
return "response";
|
| 932 |
|
970 |
|
| 933 |
leadDetail.setInternalRightWall(leadDetailModel.getInternalRightWall());
|
- |
|
| 934 |
} else {
|
971 |
}
|
| 935 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Internal Right Wall Image is Required");
|
- |
|
| 936 |
|
972 |
|
| 937 |
}
|
- |
|
| - |
|
973 |
@RequestMapping(value = "/teamCommitment", method = RequestMethod.GET)
|
| - |
|
974 |
public String teamCommitments(HttpServletRequest request, Model model) throws Exception {
|
| 938 |
|
975 |
|
| 939 |
leadDetail.setCreatedTimestamp(LocalDateTime.now());
|
976 |
return "team-commitment";
|
| 940 |
|
977 |
|
| 941 |
leadDetailRepository.persist(leadDetail);
|
- |
|
| 942 |
for (LeadBrandModel leadBrandModel : leadDetailModel.getLeadBrands()) {
|
- |
|
| - |
|
978 |
}
|
| 943 |
|
979 |
|
| 944 |
LeadBrand leadBrand = new LeadBrand();
|
- |
|
| 945 |
leadBrand.setBrand(leadBrandModel.getBrand());
|
- |
|
| 946 |
leadBrand.setValue(leadBrandModel.getValue());
|
980 |
@RequestMapping(value = "/leadDetail", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
| 947 |
leadBrand.setLeadDetailId(leadDetail.getId());
|
981 |
public String leadDetail(HttpServletRequest request, @RequestBody LeadDetailModel leadDetailModel, Model model) throws Exception {
|
| 948 |
leadBrand.setLeadId(leadDetail.getLeadId());
|
- |
|
| 949 |
leadBrand.setCreatedTimestamp(LocalDateTime.now());
|
- |
|
| 950 |
leadBrandRepository.persist(leadBrand);
|
- |
|
| 951 |
|
982 |
|
| 952 |
}
|
- |
|
| 953 |
} else {
|
983 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 954 |
throw new ProfitMandiBusinessException("LeadDetail", "", "Lead Detail Already Created");
|
984 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 955 |
}
|
- |
|
| 956 |
|
985 |
|
| - |
|
986 |
this.persistLeadDetail(leadDetailModel, authUser);
|
| 957 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
987 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 958 |
|
988 |
|
| 959 |
return "response";
|
989 |
return "response";
|
| 960 |
|
990 |
|
| 961 |
}
|
991 |
}
|
| 962 |
|
992 |
|
| 963 |
@RequestMapping(value = "/getLeadDetail", method = RequestMethod.GET)
|
993 |
@RequestMapping(value = "/getLeadDetail", method = RequestMethod.GET)
|
| 964 |
public String getLeadDetail(HttpServletRequest request, Model model) throws Exception {
|
994 |
public String getLeadDetail(HttpServletRequest request, Model model) throws Exception {
|
| 965 |
List<Integer> followUpleadIds = leadRepository.selectAllByStatus(LeadStatus.followUp).stream()
|
995 |
List<Integer> followUpleadIds = leadRepository.selectAllByStatus(LeadStatus.followUp).stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 966 |
.map(x -> x.getId()).collect(Collectors.toList());
|
- |
|
| 967 |
List<LeadDetail> leadDetails = leadDetailRepository.selectByLeadIds(followUpleadIds);
|
996 |
List<LeadDetail> leadDetails = leadDetailRepository.selectByLeadIds(followUpleadIds);
|
| 968 |
|
997 |
|
| 969 |
List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
|
998 |
List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
|
| 970 |
|
999 |
|
| 971 |
List<String> brands = mobileBrands.stream().map(x -> (String) x.get("name")).collect(Collectors.toList());
|
1000 |
List<String> brands = mobileBrands.stream().map(x -> (String) x.get("name")).collect(Collectors.toList());
|
| 972 |
|
1001 |
|
| 973 |
model.addAttribute("brands", brands);
|
1002 |
model.addAttribute("brands", brands);
|
| 974 |
if (!leadDetails.isEmpty()) {
|
1003 |
if (!leadDetails.isEmpty()) {
|
| 975 |
|
1004 |
|
| 976 |
List<Integer> detailsIds = leadDetails.stream().map(x -> x.getId()).collect(Collectors.toList());
|
1005 |
List<Integer> detailsIds = leadDetails.stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 977 |
|
1006 |
|
| 978 |
List<Integer> leadIds = leadDetails.stream().map(x -> x.getLeadId()).collect(Collectors.toList());
|
1007 |
List<Integer> leadIds = leadDetails.stream().map(x -> x.getLeadId()).collect(Collectors.toList());
|
| 979 |
|
1008 |
|
| 980 |
Map<Integer, Lead> leadMap = leadRepository.selectAllByIds(leadIds).stream()
|
1009 |
Map<Integer, Lead> leadMap = leadRepository.selectAllByIds(leadIds).stream().filter(x -> x.getStatus().equals(LeadStatus.followUp)).collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 981 |
.filter(x -> x.getStatus().equals(LeadStatus.followUp))
|
- |
|
| 982 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 983 |
|
1010 |
|
| 984 |
Map<Integer, Optional<LeadActivity>> leadActivityMap = leadActivityRepository.selectAllByleadIds(leadIds)
|
1011 |
Map<Integer, Optional<LeadActivity>> leadActivityMap = leadActivityRepository.selectAllByleadIds(leadIds).stream().collect(Collectors.groupingBy(x -> x.getLeadId(), Collectors.maxBy(Comparator.comparing(LeadActivity::getId))));
|
| 985 |
.stream().collect(Collectors.groupingBy(x -> x.getLeadId(),
|
- |
|
| 986 |
Collectors.maxBy(Comparator.comparing(LeadActivity::getId))));
|
- |
|
| 987 |
|
1012 |
|
| 988 |
model.addAttribute("leadActivityMap", leadActivityMap);
|
1013 |
model.addAttribute("leadActivityMap", leadActivityMap);
|
| 989 |
|
1014 |
|
| 990 |
List<LeadBrand> leadBrands = leadBrandRepository.selectByLeadDetailId(detailsIds);
|
1015 |
List<LeadBrand> leadBrands = leadBrandRepository.selectByLeadDetailId(detailsIds);
|
| 991 |
|
1016 |
|
| 992 |
LOGGER.info("leadBrands {}" + leadBrands);
|
1017 |
LOGGER.info("leadBrands {}" + leadBrands);
|
| 993 |
|
1018 |
|
| 994 |
Map<Integer, Map<String, Integer>> leadDetailBrandValue = new HashMap<>();
|
1019 |
Map<Integer, Map<String, Integer>> leadDetailBrandValue = new HashMap<>();
|
| 995 |
|
1020 |
|
| 996 |
Map<Integer, List<LeadBrand>> leadDetail = leadBrands.stream()
|
- |
|
| 997 |
.collect(Collectors.groupingBy(x -> x.getLeadDetailId(), Collectors.toList()));
|
1021 |
Map<Integer, List<LeadBrand>> leadDetail = leadBrands.stream().collect(Collectors.groupingBy(x -> x.getLeadDetailId(), Collectors.toList()));
|
| 998 |
|
1022 |
|
| 999 |
for (Entry<Integer, List<LeadBrand>> leadDetailEntry : leadDetail.entrySet()) {
|
1023 |
for (Entry<Integer, List<LeadBrand>> leadDetailEntry : leadDetail.entrySet()) {
|
| 1000 |
|
1024 |
|
| 1001 |
Map<String, Integer> brandValue = new HashMap<>();
|
1025 |
Map<String, Integer> brandValue = new HashMap<>();
|
| 1002 |
|
1026 |
|
| 1003 |
for (LeadBrand leadBrand : leadDetailEntry.getValue()) {
|
1027 |
for (LeadBrand leadBrand : leadDetailEntry.getValue()) {
|
| 1004 |
brandValue.put(leadBrand.getBrand(), leadBrand.getValue());
|
1028 |
brandValue.put(leadBrand.getBrand(), leadBrand.getValue());
|
| 1005 |
|
1029 |
|
| 1006 |
}
|
1030 |
}
|
| 1007 |
leadDetailBrandValue.put(leadDetailEntry.getKey(), brandValue);
|
1031 |
leadDetailBrandValue.put(leadDetailEntry.getKey(), brandValue);
|
| 1008 |
}
|
1032 |
}
|
| 1009 |
|
1033 |
|
| 1010 |
LOGGER.info("leadDetailBrandValue {}" + leadDetailBrandValue);
|
1034 |
LOGGER.info("leadDetailBrandValue {}" + leadDetailBrandValue);
|
| 1011 |
|
1035 |
|
| 1012 |
model.addAttribute("leadDetailBrandValue", leadDetailBrandValue);
|
1036 |
model.addAttribute("leadDetailBrandValue", leadDetailBrandValue);
|
| 1013 |
|
1037 |
|
| 1014 |
model.addAttribute("leadMap", leadMap);
|
1038 |
model.addAttribute("leadMap", leadMap);
|
| 1015 |
}
|
1039 |
}
|
| 1016 |
|
1040 |
|
| 1017 |
model.addAttribute("leadDetails", leadDetails);
|
1041 |
model.addAttribute("leadDetails", leadDetails);
|
| 1018 |
|
1042 |
|
| 1019 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllActiveUser().stream()
|
1043 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllActiveUser().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 1020 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 1021 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
1044 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| 1022 |
|
1045 |
|
| 1023 |
return "lead-detail";
|
1046 |
return "lead-detail";
|
| 1024 |
|
1047 |
|
| 1025 |
}
|
1048 |
}
|
| 1026 |
|
1049 |
|
| 1027 |
@RequestMapping(value = "/getLeadDetailByLeadId", method = RequestMethod.GET)
|
1050 |
@RequestMapping(value = "/getLeadDetailByLeadId", method = RequestMethod.GET)
|
| 1028 |
public ResponseEntity<?> getLeadDetailByLeadId(HttpServletRequest request, @RequestParam int leadId, Model model)
|
1051 |
public ResponseEntity<?> getLeadDetailByLeadId(HttpServletRequest request, @RequestParam int leadId, Model model) throws Exception {
|
| 1029 |
throws Exception {
|
- |
|
| 1030 |
|
1052 |
|
| 1031 |
LeadDetail leadDetail = leadDetailRepository.selectByLeadId(leadId);
|
1053 |
LeadDetail leadDetail = leadDetailRepository.selectByLeadId(leadId);
|
| 1032 |
return responseSender.ok(leadDetail);
|
1054 |
return responseSender.ok(leadDetail);
|
| 1033 |
|
1055 |
|
| 1034 |
}
|
1056 |
}
|
| 1035 |
|
1057 |
|
| 1036 |
@RequestMapping(value = "/getTeamCommitment", method = RequestMethod.GET)
|
1058 |
@RequestMapping(value = "/getTeamCommitment", method = RequestMethod.GET)
|
| 1037 |
public String getTeamCommitments(HttpServletRequest request, @RequestParam LocalDateTime date, Model model)
|
1059 |
public String getTeamCommitments(HttpServletRequest request, @RequestParam LocalDateTime date, Model model) throws Exception {
|
| 1038 |
throws Exception {
|
- |
|
| 1039 |
|
1060 |
|
| 1040 |
List<TeamCommitmentModel> commitments = partnerCollectionPlanRepository
|
1061 |
List<TeamCommitmentModel> commitments = partnerCollectionPlanRepository.selectTeamCommitmentByDate(date.toLocalDate());
|
| 1041 |
.selectTeamCommitmentByDate(date.toLocalDate());
|
- |
|
| 1042 |
|
1062 |
|
| 1043 |
model.addAttribute("commitments", commitments);
|
1063 |
model.addAttribute("commitments", commitments);
|
| 1044 |
return "team-commitment-table";
|
1064 |
return "team-commitment-table";
|
| 1045 |
|
1065 |
|
| 1046 |
}
|
1066 |
}
|
| 1047 |
|
1067 |
|
| 1048 |
@RequestMapping(value = "/partnerHealth", method = RequestMethod.GET)
|
1068 |
@RequestMapping(value = "/partnerHealth", method = RequestMethod.GET)
|
| 1049 |
public String partnerHealth(HttpServletRequest request,
|
- |
|
| 1050 |
@RequestParam(name = "email", required = false) String email, Model model) throws Exception {
|
1069 |
public String partnerHealth(HttpServletRequest request, @RequestParam(name = "email", required = false) String email, Model model) throws Exception {
|
| 1051 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
1070 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 1052 |
|
1071 |
|
| 1053 |
if (StringUtils.isEmpty(email)) {
|
1072 |
if (StringUtils.isEmpty(email)) {
|
| 1054 |
email = loginDetails.getEmailId();
|
1073 |
email = loginDetails.getEmailId();
|
| 1055 |
} else {
|
1074 |
} else {
|
| 1056 |
AuthUser selectedUser = authRepository.selectByEmailOrMobile(email);
|
1075 |
AuthUser selectedUser = authRepository.selectByEmailOrMobile(email);
|
| 1057 |
|
1076 |
|
| 1058 |
model.addAttribute("selectedUser", selectedUser);
|
1077 |
model.addAttribute("selectedUser", selectedUser);
|
| 1059 |
|
1078 |
|
| 1060 |
}
|
1079 |
}
|
| 1061 |
|
1080 |
|
| 1062 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
1081 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 1063 |
|
1082 |
|
| 1064 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
1083 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 1065 |
List<Integer> fofoIds = new ArrayList<>(storeGuyMap.get(email));
|
1084 |
List<Integer> fofoIds = new ArrayList<>(storeGuyMap.get(email));
|
| 1066 |
LocalDateTime startDate = LocalDate.now().atStartOfDay();
|
1085 |
LocalDateTime startDate = LocalDate.now().atStartOfDay();
|
| 1067 |
if (fofoIds != null && fofoIds.size() > 0) {
|
1086 |
if (fofoIds != null && fofoIds.size() > 0) {
|
| 1068 |
List<Integer> fofoIdList = fofoStoreRepository.selectByRetailerIds(fofoIds).stream()
|
1087 |
List<Integer> fofoIdList = fofoStoreRepository.selectByRetailerIds(fofoIds).stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toList());
|
| 1069 |
.filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toList());
|
- |
|
| 1070 |
|
1088 |
|
| 1071 |
Map<Integer, PartnerCollectionPlanModel> foundCollectionMap = partnerCollectionService
|
1089 |
Map<Integer, PartnerCollectionPlanModel> foundCollectionMap = partnerCollectionService.getCollectionMap(fofoIdList, startDate);
|
| 1072 |
.getCollectionMap(fofoIdList, startDate);
|
- |
|
| 1073 |
|
1090 |
|
| 1074 |
List<Integer> remarkIds = partnerCollectionRemarkRepository.selectMaxRemarkId(fofoIdList);
|
1091 |
List<Integer> remarkIds = partnerCollectionRemarkRepository.selectMaxRemarkId(fofoIdList);
|
| 1075 |
|
1092 |
|
| 1076 |
LOGGER.info("remarkIds {}", remarkIds);
|
1093 |
LOGGER.info("remarkIds {}", remarkIds);
|
| 1077 |
|
1094 |
|
| 1078 |
long todayOverallCall = 0;
|
1095 |
long todayOverallCall = 0;
|
| 1079 |
if (!remarkIds.isEmpty()) {
|
1096 |
if (!remarkIds.isEmpty()) {
|
| 1080 |
|
1097 |
|
| 1081 |
if (authUser.getEmailId().equals(email)) {
|
1098 |
if (authUser.getEmailId().equals(email)) {
|
| 1082 |
|
1099 |
|
| 1083 |
todayOverallCall = partnerCollectionRemarkRepository.selectByIds(remarkIds).stream()
|
1100 |
todayOverallCall = partnerCollectionRemarkRepository.selectByIds(remarkIds).stream().filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now())).collect(Collectors.counting());
|
| 1084 |
.filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now()))
|
- |
|
| 1085 |
.collect(Collectors.counting());
|
- |
|
| 1086 |
} else {
|
1101 |
} else {
|
| 1087 |
|
1102 |
|
| 1088 |
todayOverallCall = partnerCollectionRemarkRepository
|
- |
|
| 1089 |
.selectByAuthIdAndIds(authRepository.selectByEmailOrMobile(email).getId(), remarkIds)
|
- |
|
| 1090 |
.stream().filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now()))
|
1103 |
todayOverallCall = partnerCollectionRemarkRepository.selectByAuthIdAndIds(authRepository.selectByEmailOrMobile(email).getId(), remarkIds).stream().filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now())).collect(Collectors.counting());
|
| 1091 |
.collect(Collectors.counting());
|
- |
|
| 1092 |
|
1104 |
|
| 1093 |
}
|
1105 |
}
|
| 1094 |
|
1106 |
|
| 1095 |
}
|
1107 |
}
|
| 1096 |
ChartLeadModel cm = new ChartLeadModel();
|
1108 |
ChartLeadModel cm = new ChartLeadModel();
|
| 1097 |
|
1109 |
|
| 1098 |
if (!foundCollectionMap.isEmpty()) {
|
1110 |
if (!foundCollectionMap.isEmpty()) {
|
| 1099 |
cm = this.getCollectionCount(foundCollectionMap.values().stream().collect(Collectors.toList()));
|
1111 |
cm = this.getCollectionCount(foundCollectionMap.values().stream().collect(Collectors.toList()));
|
| 1100 |
|
1112 |
|
| 1101 |
}
|
1113 |
}
|
| 1102 |
model.addAttribute("chartPartnerHealth", gson.toJson(cm));
|
1114 |
model.addAttribute("chartPartnerHealth", gson.toJson(cm));
|
| 1103 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
1115 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
| 1104 |
|
1116 |
|
| 1105 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
1117 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository.selectAll(fofoIdList, startDate.toLocalDate().minusDays(1));
|
| 1106 |
.selectAll(fofoIdList, startDate.toLocalDate().minusDays(1));
|
- |
|
| 1107 |
if (!partnerDailyInvestments.isEmpty()) {
|
1118 |
if (!partnerDailyInvestments.isEmpty()) {
|
| 1108 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream()
|
1119 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 1109 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 1110 |
}
|
1120 |
}
|
| 1111 |
|
1121 |
|
| 1112 |
Map<LocalDate, Map<Integer, PartnerCollectionPlanModel>> pcpmMap = new TreeMap<>();
|
1122 |
Map<LocalDate, Map<Integer, PartnerCollectionPlanModel>> pcpmMap = new TreeMap<>();
|
| 1113 |
for (int i = 0; i <= 6; i++) {
|
1123 |
for (int i = 0; i <= 6; i++) {
|
| 1114 |
|
1124 |
|
| 1115 |
Map<Integer, PartnerCollectionPlanModel> collectionMap = partnerCollectionService
|
1125 |
Map<Integer, PartnerCollectionPlanModel> collectionMap = partnerCollectionService.getCollectionMap(fofoIdList, startDate.minusDays(i));
|
| 1116 |
.getCollectionMap(fofoIdList, startDate.minusDays(i));
|
- |
|
| 1117 |
|
1126 |
|
| 1118 |
pcpmMap.put(startDate.minusDays(i).toLocalDate(), collectionMap);
|
1127 |
pcpmMap.put(startDate.minusDays(i).toLocalDate(), collectionMap);
|
| 1119 |
}
|
1128 |
}
|
| 1120 |
|
1129 |
|
| 1121 |
Map<Integer, PartnerCollectionPlanModel> todayPcpmMap = pcpmMap.get(startDate.toLocalDate());
|
1130 |
Map<Integer, PartnerCollectionPlanModel> todayPcpmMap = pcpmMap.get(startDate.toLocalDate());
|
| 1122 |
model.addAttribute("todayPcpmMap", todayPcpmMap);
|
1131 |
model.addAttribute("todayPcpmMap", todayPcpmMap);
|
| 1123 |
|
1132 |
|
| 1124 |
TotalTargetColectionModel totalTargetCollection = partnerCollectionService
|
1133 |
TotalTargetColectionModel totalTargetCollection = partnerCollectionService.getTotalTargetCollection(todayPcpmMap, startDate);
|
| 1125 |
.getTotalTargetCollection(todayPcpmMap, startDate);
|
- |
|
| 1126 |
model.addAttribute("totalPartnerTargetCollection", totalTargetCollection.getTotalTarget());
|
1134 |
model.addAttribute("totalPartnerTargetCollection", totalTargetCollection.getTotalTarget());
|
| 1127 |
|
1135 |
|
| 1128 |
model.addAttribute("totalPartnerAchievement", totalTargetCollection.getTotalAchievement());
|
1136 |
model.addAttribute("totalPartnerAchievement", totalTargetCollection.getTotalAchievement());
|
| 1129 |
|
1137 |
|
| 1130 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
1138 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 1131 |
Map<Integer, CustomRetailer> customRetailers = fofoIdList.stream().distinct()
|
- |
|
| 1132 |
.map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream()
|
1139 |
Map<Integer, CustomRetailer> customRetailers = fofoIdList.stream().distinct().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 1133 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
- |
|
| 1134 |
List<Integer> allReportees = authService.getAllReportees(authUser.getId());
|
1140 |
List<Integer> allReportees = authService.getAllReportees(authUser.getId());
|
| 1135 |
|
1141 |
|
| 1136 |
List<Integer> salesPositionsAuthIds = positionRepository
|
- |
|
| 1137 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES).stream()
|
1142 |
List<Integer> salesPositionsAuthIds = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES).stream().map(x -> x.getAuthUserId()).collect(Collectors.toList());
|
| 1138 |
.map(x -> x.getAuthUserId()).collect(Collectors.toList());
|
- |
|
| 1139 |
List<Integer> rbmPositionsAuthIds = positionRepository
|
- |
|
| 1140 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM).stream()
|
1143 |
List<Integer> rbmPositionsAuthIds = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM).stream().map(x -> x.getAuthUserId()).collect(Collectors.toList());
|
| 1141 |
.map(x -> x.getAuthUserId()).collect(Collectors.toList());
|
- |
|
| 1142 |
|
1144 |
|
| 1143 |
salesPositionsAuthIds.addAll(rbmPositionsAuthIds);
|
1145 |
salesPositionsAuthIds.addAll(rbmPositionsAuthIds);
|
| 1144 |
|
1146 |
|
| 1145 |
Set<Integer> empHierarchy = allReportees.stream().filter(x -> salesPositionsAuthIds.contains(x))
|
1147 |
Set<Integer> empHierarchy = allReportees.stream().filter(x -> salesPositionsAuthIds.contains(x)).collect(Collectors.toSet());
|
| 1146 |
.collect(Collectors.toSet());
|
- |
|
| 1147 |
|
1148 |
|
| 1148 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(new ArrayList<>(empHierarchy));
|
1149 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(new ArrayList<>(empHierarchy));
|
| 1149 |
|
1150 |
|
| 1150 |
Map<Integer, AuthUser> authUserMap = authRepository.selectAll().stream()
|
1151 |
Map<Integer, AuthUser> authUserMap = authRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 1151 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 1152 |
|
1152 |
|
| 1153 |
LOGGER.info("todayPcpmMap {}", todayPcpmMap);
|
1153 |
LOGGER.info("todayPcpmMap {}", todayPcpmMap);
|
| 1154 |
|
1154 |
|
| 1155 |
model.addAttribute("authUsers", authUsers);
|
1155 |
model.addAttribute("authUsers", authUsers);
|
| 1156 |
model.addAttribute("authUserMap", authUserMap);
|
1156 |
model.addAttribute("authUserMap", authUserMap);
|
| 1157 |
model.addAttribute("partnerCollectionPlanMap", pcpmMap);
|
1157 |
model.addAttribute("partnerCollectionPlanMap", pcpmMap);
|
| 1158 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
1158 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
| 1159 |
model.addAttribute("customRetailers", customRetailers);
|
1159 |
model.addAttribute("customRetailers", customRetailers);
|
| 1160 |
model.addAttribute("rankColorMap", ProfitMandiConstants.Rank_Color_Map);
|
1160 |
model.addAttribute("rankColorMap", ProfitMandiConstants.Rank_Color_Map);
|
| 1161 |
model.addAttribute("todayOverallCall", todayOverallCall);
|
1161 |
model.addAttribute("todayOverallCall", todayOverallCall);
|
| 1162 |
|
1162 |
|
| 1163 |
}
|
1163 |
}
|
| 1164 |
return "partner-health";
|
1164 |
return "partner-health";
|
| 1165 |
|
1165 |
|
| 1166 |
}
|
1166 |
}
|
| 1167 |
|
1167 |
|
| 1168 |
public ChartLeadModel getCollectionCount(List<PartnerCollectionPlanModel> pcpm)
|
1168 |
public ChartLeadModel getCollectionCount(List<PartnerCollectionPlanModel> pcpm) throws ProfitMandiBusinessException {
|
| 1169 |
throws ProfitMandiBusinessException {
|
- |
|
| 1170 |
|
1169 |
|
| 1171 |
Map<Integer, Long> rankCount = pcpm.stream().collect(Collectors.groupingBy(x -> x.getRank(),
|
1170 |
Map<Integer, Long> rankCount = pcpm.stream().collect(Collectors.groupingBy(x -> x.getRank(), Collectors.mapping(PartnerCollectionPlanModel::getRank, Collectors.counting())));
|
| 1172 |
Collectors.mapping(PartnerCollectionPlanModel::getRank, Collectors.counting())));
|
- |
|
| 1173 |
|
1171 |
|
| 1174 |
ChartLeadModel cm = new ChartLeadModel();
|
1172 |
ChartLeadModel cm = new ChartLeadModel();
|
| 1175 |
|
1173 |
|
| 1176 |
List<String> labels = new ArrayList<>();
|
1174 |
List<String> labels = new ArrayList<>();
|
| 1177 |
labels.add("Plan for Today");
|
1175 |
labels.add("Plan for Today");
|
| 1178 |
labels.add("Carry Forward");
|
1176 |
labels.add("Carry Forward");
|
| 1179 |
labels.add("Untouched");
|
1177 |
labels.add("Untouched");
|
| 1180 |
labels.add("Plan for Future");
|
1178 |
labels.add("Plan for Future");
|
| 1181 |
labels.add("Normal");
|
1179 |
labels.add("Normal");
|
| 1182 |
|
1180 |
|
| 1183 |
List<String> backgroundColor = new ArrayList<>();
|
1181 |
List<String> backgroundColor = new ArrayList<>();
|
| 1184 |
List<Long> values = new ArrayList<>();
|
1182 |
List<Long> values = new ArrayList<>();
|
| 1185 |
|
1183 |
|
| 1186 |
for (String label : labels) {
|
1184 |
for (String label : labels) {
|
| 1187 |
|
1185 |
|
| 1188 |
if (label.equals("Plan for Today")) {
|
1186 |
if (label.equals("Plan for Today")) {
|
| 1189 |
backgroundColor.add("#007bff");
|
1187 |
backgroundColor.add("#007bff");
|
| 1190 |
values.add(rankCount.get(1));
|
1188 |
values.add(rankCount.get(1));
|
| 1191 |
}
|
1189 |
}
|
| 1192 |
if (label.equals("Carry Forward")) {
|
1190 |
if (label.equals("Carry Forward")) {
|
| 1193 |
backgroundColor.add("#ffc107");
|
1191 |
backgroundColor.add("#ffc107");
|
| 1194 |
values.add(rankCount.get(2));
|
1192 |
values.add(rankCount.get(2));
|
| 1195 |
}
|
1193 |
}
|
| 1196 |
if (label.equals("Untouched")) {
|
1194 |
if (label.equals("Untouched")) {
|
| 1197 |
backgroundColor.add("#dc3545");
|
1195 |
backgroundColor.add("#dc3545");
|
| 1198 |
values.add(rankCount.get(3));
|
1196 |
values.add(rankCount.get(3));
|
| 1199 |
}
|
1197 |
}
|
| 1200 |
if (label.equals("Plan for Future")) {
|
1198 |
if (label.equals("Plan for Future")) {
|
| 1201 |
backgroundColor.add("#6c757d");
|
1199 |
backgroundColor.add("#6c757d");
|
| 1202 |
values.add(rankCount.get(4));
|
1200 |
values.add(rankCount.get(4));
|
| 1203 |
}
|
1201 |
}
|
| 1204 |
if (label.equals("Normal")) {
|
1202 |
if (label.equals("Normal")) {
|
| 1205 |
backgroundColor.add("White");
|
1203 |
backgroundColor.add("White");
|
| 1206 |
values.add(rankCount.get(5));
|
1204 |
values.add(rankCount.get(5));
|
| 1207 |
}
|
1205 |
}
|
| 1208 |
|
1206 |
|
| 1209 |
}
|
1207 |
}
|
| 1210 |
|
1208 |
|
| 1211 |
LOGGER.info("backgroundColor" + backgroundColor);
|
1209 |
LOGGER.info("backgroundColor" + backgroundColor);
|
| 1212 |
LOGGER.info("labelsChartLead" + labels);
|
1210 |
LOGGER.info("labelsChartLead" + labels);
|
| 1213 |
LeadStatusData data = new LeadStatusData();
|
1211 |
LeadStatusData data = new LeadStatusData();
|
| 1214 |
data.setData(values);
|
1212 |
data.setData(values);
|
| 1215 |
data.setBackgroundColor(backgroundColor);
|
1213 |
data.setBackgroundColor(backgroundColor);
|
| 1216 |
data.setLabel("DataSet 1");
|
1214 |
data.setLabel("DataSet 1");
|
| 1217 |
|
1215 |
|
| 1218 |
PieLables label = new PieLables();
|
1216 |
PieLables label = new PieLables();
|
| 1219 |
label.setFontColor("black");
|
1217 |
label.setFontColor("black");
|
| 1220 |
label.setFontSize(15);
|
1218 |
label.setFontSize(15);
|
| 1221 |
|
1219 |
|
| 1222 |
Legend legend = new Legend();
|
1220 |
Legend legend = new Legend();
|
| 1223 |
legend.setLabels(label);
|
1221 |
legend.setLabels(label);
|
| 1224 |
legend.setPosition("left");
|
1222 |
legend.setPosition("left");
|
| 1225 |
|
1223 |
|
| 1226 |
List<LeadStatusData> dataList = new ArrayList<>();
|
1224 |
List<LeadStatusData> dataList = new ArrayList<>();
|
| 1227 |
dataList.add(data);
|
1225 |
dataList.add(data);
|
| 1228 |
|
1226 |
|
| 1229 |
DataLeadModel datasets = new DataLeadModel();
|
1227 |
DataLeadModel datasets = new DataLeadModel();
|
| 1230 |
datasets.setDatasets(dataList);
|
1228 |
datasets.setDatasets(dataList);
|
| 1231 |
datasets.setLabels(labels);
|
1229 |
datasets.setLabels(labels);
|
| 1232 |
|
1230 |
|
| 1233 |
OptionModel om = new OptionModel();
|
1231 |
OptionModel om = new OptionModel();
|
| 1234 |
om.setLegend(legend);
|
1232 |
om.setLegend(legend);
|
| 1235 |
|
1233 |
|
| 1236 |
cm.setType("pie");
|
1234 |
cm.setType("pie");
|
| 1237 |
cm.setData(datasets);
|
1235 |
cm.setData(datasets);
|
| 1238 |
cm.setOptions(om);
|
1236 |
cm.setOptions(om);
|
| 1239 |
|
1237 |
|
| 1240 |
return cm;
|
1238 |
return cm;
|
| 1241 |
}
|
1239 |
}
|
| 1242 |
|
1240 |
|
| 1243 |
@RequestMapping(value = "/franchiseVisit", method = RequestMethod.GET)
|
1241 |
@RequestMapping(value = "/franchiseVisit", method = RequestMethod.GET)
|
| 1244 |
public String franchiseVisit(HttpServletRequest request,
|
- |
|
| 1245 |
@RequestParam(name = "email", required = false) String email, Model model) throws Exception {
|
1242 |
public String franchiseVisit(HttpServletRequest request, @RequestParam(name = "email", required = false) String email, Model model) throws Exception {
|
| 1246 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
1243 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 1247 |
|
1244 |
|
| 1248 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
1245 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 1249 |
|
1246 |
|
| 1250 |
List<Integer> salesPositionsAuthIds = positionRepository
|
- |
|
| 1251 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES).stream()
|
1247 |
List<Integer> salesPositionsAuthIds = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES).stream().map(x -> x.getAuthUserId()).collect(Collectors.toList());
|
| 1252 |
.map(x -> x.getAuthUserId()).collect(Collectors.toList());
|
- |
|
| 1253 |
List<Integer> rbmPositionsAuthIds = positionRepository
|
- |
|
| 1254 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM).stream()
|
1248 |
List<Integer> rbmPositionsAuthIds = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM).stream().map(x -> x.getAuthUserId()).collect(Collectors.toList());
|
| 1255 |
.map(x -> x.getAuthUserId()).collect(Collectors.toList());
|
- |
|
| 1256 |
|
1249 |
|
| 1257 |
salesPositionsAuthIds.addAll(rbmPositionsAuthIds);
|
1250 |
salesPositionsAuthIds.addAll(rbmPositionsAuthIds);
|
| 1258 |
|
1251 |
|
| 1259 |
List<Integer> allReportees = authService.getAllReportees(authUser.getId());
|
1252 |
List<Integer> allReportees = authService.getAllReportees(authUser.getId());
|
| 1260 |
|
1253 |
|
| 1261 |
Set<Integer> empHierarchy = allReportees.stream().filter(x -> salesPositionsAuthIds.contains(x))
|
1254 |
Set<Integer> empHierarchy = allReportees.stream().filter(x -> salesPositionsAuthIds.contains(x)).collect(Collectors.toSet());
|
| 1262 |
.collect(Collectors.toSet());
|
- |
|
| 1263 |
|
1255 |
|
| 1264 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(new ArrayList<>(empHierarchy));
|
1256 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(new ArrayList<>(empHierarchy));
|
| 1265 |
|
1257 |
|
| 1266 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
1258 |
Map<Integer, String> monthValueMap = new HashMap<>();
|
| 1267 |
for (int i = 0; i <= 5; i++) {
|
1259 |
for (int i = 0; i <= 5; i++) {
|
| 1268 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
1260 |
LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
|
| 1269 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
1261 |
monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
| 1270 |
}
|
1262 |
}
|
| 1271 |
|
1263 |
|
| 1272 |
model.addAttribute("authUsers", authUsers);
|
1264 |
model.addAttribute("authUsers", authUsers);
|
| 1273 |
model.addAttribute("monthValueMap", monthValueMap);
|
1265 |
model.addAttribute("monthValueMap", monthValueMap);
|
| 1274 |
|
1266 |
|
| 1275 |
return "franchise-visit";
|
1267 |
return "franchise-visit";
|
| 1276 |
|
1268 |
|
| 1277 |
}
|
1269 |
}
|
| 1278 |
|
1270 |
|
| 1279 |
@RequestMapping(value = "/getFranchiseVisit", method = RequestMethod.GET)
|
1271 |
@RequestMapping(value = "/getFranchiseVisit", method = RequestMethod.GET)
|
| 1280 |
public String getFranchiseVisit(HttpServletRequest request,
|
- |
|
| 1281 |
@RequestParam(name = "authId", required = false) int authId, int yearMonth, Model model) throws Exception {
|
1272 |
public String getFranchiseVisit(HttpServletRequest request, @RequestParam(name = "authId", required = false) int authId, int yearMonth, Model model) throws Exception {
|
| 1282 |
|
1273 |
|
| 1283 |
LocalDateTime startDate = LocalDate.now().minusMonths(8).withDayOfMonth(1).atStartOfDay();
|
1274 |
LocalDateTime startDate = LocalDate.now().minusMonths(8).withDayOfMonth(1).atStartOfDay();
|
| 1284 |
LocalDateTime endDate = startDate.plusMonths(1).withDayOfMonth(1).toLocalDate().atStartOfDay();
|
1275 |
LocalDateTime endDate = startDate.plusMonths(1).withDayOfMonth(1).toLocalDate().atStartOfDay();
|
| 1285 |
|
1276 |
|
| 1286 |
DateRangeModel drm = DateRangeModel.of(startDate, endDate);
|
1277 |
DateRangeModel drm = DateRangeModel.of(startDate, endDate);
|
| 1287 |
|
1278 |
|
| 1288 |
List<FranchiseeVisit> visits = franchiseeVisitRepository.selectByAuthUserAndDateRange(drm, authId);
|
1279 |
List<FranchiseeVisit> visits = franchiseeVisitRepository.selectByAuthUserAndDateRange(drm, authId);
|
| 1289 |
|
1280 |
|
| 1290 |
if (!visits.isEmpty()) {
|
1281 |
if (!visits.isEmpty()) {
|
| 1291 |
|
1282 |
|
| 1292 |
Map<Integer, List<FranchiseeVisit>> franchiseeVisitMap = visits.stream()
|
- |
|
| 1293 |
.collect(Collectors.groupingBy(x -> x.getScheduleTimestamp().getDayOfMonth()));
|
1283 |
Map<Integer, List<FranchiseeVisit>> franchiseeVisitMap = visits.stream().collect(Collectors.groupingBy(x -> x.getScheduleTimestamp().getDayOfMonth()));
|
| 1294 |
|
1284 |
|
| 1295 |
model.addAttribute("franchiseeVisitMap", franchiseeVisitMap);
|
1285 |
model.addAttribute("franchiseeVisitMap", franchiseeVisitMap);
|
| 1296 |
|
1286 |
|
| 1297 |
}
|
1287 |
}
|
| 1298 |
|
1288 |
|
| 1299 |
model.addAttribute("visits", visits);
|
1289 |
model.addAttribute("visits", visits);
|
| 1300 |
model.addAttribute("monthLength", startDate.toLocalDate().lengthOfMonth());
|
1290 |
model.addAttribute("monthLength", startDate.toLocalDate().lengthOfMonth());
|
| 1301 |
|
1291 |
|
| 1302 |
// Calender
|
1292 |
// Calender
|
| 1303 |
|
1293 |
|
| 1304 |
int Year = startDate.getYear(); // year
|
1294 |
int Year = startDate.getYear(); // year
|
| 1305 |
int startDayOfMonth = 5;
|
1295 |
int startDayOfMonth = 5;
|
| 1306 |
int spaces = startDayOfMonth;
|
1296 |
int spaces = startDayOfMonth;
|
| 1307 |
|
1297 |
|
| 1308 |
int month = startDate.getMonthValue();
|
1298 |
int month = startDate.getMonthValue();
|
| 1309 |
|
1299 |
|
| 1310 |
int[] days = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
1300 |
int[] days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
| 1311 |
|
1301 |
|
| 1312 |
LOGGER.info("visits {} ", visits);
|
1302 |
LOGGER.info("visits {} ", visits);
|
| 1313 |
|
1303 |
|
| 1314 |
if ((((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0)) && month == 2) {
|
1304 |
if ((((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0)) && month == 2) {
|
| 1315 |
days[month] = 29;
|
1305 |
days[month] = 29;
|
| 1316 |
}
|
1306 |
}
|
| 1317 |
|
1307 |
|
| 1318 |
spaces = (days[month - 1] + spaces) % 7;
|
1308 |
spaces = (days[month - 1] + spaces) % 7;
|
| 1319 |
|
1309 |
|
| 1320 |
model.addAttribute("month", month);
|
1310 |
model.addAttribute("month", month);
|
| 1321 |
model.addAttribute("spaces", spaces);
|
1311 |
model.addAttribute("spaces", spaces);
|
| 1322 |
model.addAttribute("days", days);
|
1312 |
model.addAttribute("days", days);
|
| 1323 |
|
1313 |
|
| 1324 |
return "franchise-visit-container";
|
1314 |
return "franchise-visit-container";
|
| 1325 |
|
1315 |
|
| 1326 |
}
|
1316 |
}
|
| 1327 |
|
1317 |
|
| 1328 |
@RequestMapping(value = "/getFranchiseeActivity", method = RequestMethod.GET)
|
1318 |
@RequestMapping(value = "/getFranchiseeActivity", method = RequestMethod.GET)
|
| 1329 |
public String getFranchiseeActivity(HttpServletRequest request, int visitId, Model model) throws Exception {
|
1319 |
public String getFranchiseeActivity(HttpServletRequest request, int visitId, Model model) throws Exception {
|
| 1330 |
|
1320 |
|
| 1331 |
List<FranchiseeActivity> franchiseeActivities = franchiseeActivityRepository.selectByFranchiseeVisitId(visitId);
|
1321 |
List<FranchiseeActivity> franchiseeActivities = franchiseeActivityRepository.selectByFranchiseeVisitId(visitId);
|
| 1332 |
|
1322 |
|
| 1333 |
FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(visitId);
|
1323 |
FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(visitId);
|
| 1334 |
|
1324 |
|
| 1335 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAll().stream()
|
1325 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 1336 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 1337 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
1326 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| 1338 |
|
1327 |
|
| 1339 |
model.addAttribute("franchiseeVisit", franchiseeVisit);
|
1328 |
model.addAttribute("franchiseeVisit", franchiseeVisit);
|
| 1340 |
model.addAttribute("franchiseeActivity", franchiseeActivities.get(0));
|
1329 |
model.addAttribute("franchiseeActivity", franchiseeActivities.get(0));
|
| 1341 |
|
1330 |
|
| 1342 |
return "franchie-visit-detail";
|
1331 |
return "franchie-visit-detail";
|
| 1343 |
|
1332 |
|
| 1344 |
}
|
1333 |
}
|
| 1345 |
|
1334 |
|
| 1346 |
@RequestMapping(value = "/indent/today_target", method = RequestMethod.GET)
|
1335 |
@RequestMapping(value = "/indent/today_target", method = RequestMethod.GET)
|
| 1347 |
public String todayTarget(HttpServletRequest request, Model model) throws Exception {
|
1336 |
public String todayTarget(HttpServletRequest request, Model model) throws Exception {
|
| 1348 |
List<RBMPerformanceSummaryModel> summaryModels = new ArrayList<>();
|
1337 |
List<RBMPerformanceSummaryModel> summaryModels = new ArrayList<>();
|
| 1349 |
List<Integer> rbmPositionsAuthIds = positionRepository
|
- |
|
| 1350 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM).stream()
|
- |
|
| 1351 |
.filter(x -> Arrays.asList(EscalationType.L1, EscalationType.L2).contains(x.getEscalationType()))
|
1338 |
List<Integer> rbmPositionsAuthIds = positionRepository.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_RBM).stream().filter(x -> Arrays.asList(EscalationType.L1, EscalationType.L2).contains(x.getEscalationType())).map(x -> x.getAuthUserId()).distinct().collect(Collectors.toList());
|
| 1352 |
.map(x -> x.getAuthUserId()).distinct().collect(Collectors.toList());
|
- |
|
| 1353 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
1339 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 1354 |
List<TeamCommitmentModel> teamCommitmentModels = partnerCollectionPlanRepository
|
1340 |
List<TeamCommitmentModel> teamCommitmentModels = partnerCollectionPlanRepository.selectTeamCommitmentByDate(LocalDate.now());
|
| 1355 |
.selectTeamCommitmentByDate(LocalDate.now());
|
- |
|
| 1356 |
Map<Integer, Double> rbmSecondaryTargetMap = teamCommitmentModels.stream()
|
- |
|
| 1357 |
.filter(x -> rbmPositionsAuthIds.contains(x.getAuthId()))
|
- |
|
| 1358 |
.collect(Collectors.groupingBy(x -> x.getAuthId(),
|
- |
|
| 1359 |
Collectors.summingDouble(x -> x.getTotalTarget() == null ? 0 : x.getTotalTarget())));
|
1341 |
Map<Integer, Double> rbmSecondaryTargetMap = teamCommitmentModels.stream().filter(x -> rbmPositionsAuthIds.contains(x.getAuthId())).collect(Collectors.groupingBy(x -> x.getAuthId(), Collectors.summingDouble(x -> x.getTotalTarget() == null ? 0 : x.getTotalTarget())));
|
| 1360 |
Map<Integer, Double> rbmSecondaryMap = teamCommitmentModels.stream()
|
- |
|
| 1361 |
.filter(x -> rbmPositionsAuthIds.contains(x.getAuthId()))
|
- |
|
| 1362 |
.collect(Collectors.groupingBy(x -> x.getAuthId(),
|
- |
|
| 1363 |
Collectors.summingDouble(x -> x.getTotalAchievement() == null ? 0 : x.getTotalAchievement())));
|
1342 |
Map<Integer, Double> rbmSecondaryMap = teamCommitmentModels.stream().filter(x -> rbmPositionsAuthIds.contains(x.getAuthId())).collect(Collectors.groupingBy(x -> x.getAuthId(), Collectors.summingDouble(x -> x.getTotalAchievement() == null ? 0 : x.getTotalAchievement())));
|
| 1364 |
LocalDateTime startDate = LocalDate.now().atStartOfDay();
|
1343 |
LocalDateTime startDate = LocalDate.now().atStartOfDay();
|
| 1365 |
for (int rbmAuthId : rbmPositionsAuthIds) {
|
1344 |
for (int rbmAuthId : rbmPositionsAuthIds) {
|
| 1366 |
RBMPerformanceSummaryModel rbmPerformanceSummaryModel = new RBMPerformanceSummaryModel();
|
1345 |
RBMPerformanceSummaryModel rbmPerformanceSummaryModel = new RBMPerformanceSummaryModel();
|
| 1367 |
rbmPerformanceSummaryModel.setAuthId(rbmAuthId);
|
1346 |
rbmPerformanceSummaryModel.setAuthId(rbmAuthId);
|
| 1368 |
AuthUser authUser = authRepository.selectById(rbmAuthId);
|
1347 |
AuthUser authUser = authRepository.selectById(rbmAuthId);
|
| 1369 |
rbmPerformanceSummaryModel.setAuthName(authUser.getFullName());
|
1348 |
rbmPerformanceSummaryModel.setAuthName(authUser.getFullName());
|
| 1370 |
List<Integer> fofoIds = new ArrayList<>(storeGuyMap.get(authUser.getEmailId()));
|
1349 |
List<Integer> fofoIds = new ArrayList<>(storeGuyMap.get(authUser.getEmailId()));
|
| 1371 |
|
1350 |
|
| 1372 |
if (fofoIds.size() > 0) {
|
1351 |
if (fofoIds.size() > 0) {
|
| 1373 |
fofoIds = fofoStoreRepository.selectByRetailerIds(fofoIds).stream().filter(x -> !x.isInternal())
|
1352 |
fofoIds = fofoStoreRepository.selectByRetailerIds(fofoIds).stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toList());
|
| 1374 |
.map(x -> x.getId()).collect(Collectors.toList());
|
- |
|
| 1375 |
|
1353 |
|
| 1376 |
/*
|
1354 |
/*
|
| 1377 |
* Map<Integer, PartnerCollectionPlanModel> foundCollectionMap =
|
1355 |
* Map<Integer, PartnerCollectionPlanModel> foundCollectionMap =
|
| 1378 |
* partnerCollectionService .getCollectionMap(fofoIds, startDate);
|
1356 |
* partnerCollectionService .getCollectionMap(fofoIds, startDate);
|
| 1379 |
*/
|
1357 |
*/
|
| 1380 |
|
1358 |
|
| 1381 |
List<Integer> remarkIds = partnerCollectionRemarkRepository.selectMaxRemarkId(fofoIds);
|
1359 |
List<Integer> remarkIds = partnerCollectionRemarkRepository.selectMaxRemarkId(fofoIds);
|
| 1382 |
|
1360 |
|
| 1383 |
LOGGER.info("remarkIds {}", remarkIds);
|
1361 |
LOGGER.info("remarkIds {}", remarkIds);
|
| 1384 |
|
1362 |
|
| 1385 |
long todayOverallCall = 0;
|
1363 |
long todayOverallCall = 0;
|
| 1386 |
if (!remarkIds.isEmpty()) {
|
1364 |
if (!remarkIds.isEmpty()) {
|
| 1387 |
todayOverallCall = partnerCollectionRemarkRepository.selectByIds(remarkIds).stream()
|
1365 |
todayOverallCall = partnerCollectionRemarkRepository.selectByIds(remarkIds).stream().filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now())).collect(Collectors.counting());
|
| 1388 |
.filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now()))
|
- |
|
| 1389 |
.collect(Collectors.counting());
|
- |
|
| 1390 |
|
1366 |
|
| 1391 |
}
|
1367 |
}
|
| 1392 |
|
1368 |
|
| 1393 |
Map<Integer, PartnerCollectionPlanModel> collectionMap = partnerCollectionService
|
1369 |
Map<Integer, PartnerCollectionPlanModel> collectionMap = partnerCollectionService.getCollectionMap(fofoIds, startDate);
|
| 1394 |
.getCollectionMap(fofoIds, startDate);
|
- |
|
| 1395 |
|
1370 |
|
| 1396 |
ChartLeadModel cm = this
|
- |
|
| 1397 |
.getCollectionCount(collectionMap.values().stream().collect(Collectors.toList()));
|
1371 |
ChartLeadModel cm = this.getCollectionCount(collectionMap.values().stream().collect(Collectors.toList()));
|
| 1398 |
|
1372 |
|
| 1399 |
long collectionTarget = collectionMap.values().stream().filter(x -> x.getTargetPlan() != null)
|
1373 |
long collectionTarget = collectionMap.values().stream().filter(x -> x.getTargetPlan() != null).collect(Collectors.summingLong(x -> x.getTargetPlan()));
|
| 1400 |
.collect(Collectors.summingLong(x -> x.getTargetPlan()));
|
- |
|
| 1401 |
long collection = collectionMap.values().stream().filter(
|
1374 |
long collection = collectionMap.values().stream().filter(
|
| 1402 |
x -> x.getTargetPlan() != null && x.getTargetPlan() != 0 && x.getAchievementPlan() != null)
|
1375 |
x -> x.getTargetPlan() != null && x.getTargetPlan() != 0 && x.getAchievementPlan() != null).collect(Collectors.summingLong(x -> x.getAchievementPlan()));
|
| 1403 |
.collect(Collectors.summingLong(x -> x.getAchievementPlan()));
|
- |
|
| 1404 |
rbmPerformanceSummaryModel.setChartLeadModel(cm);
|
1376 |
rbmPerformanceSummaryModel.setChartLeadModel(cm);
|
| 1405 |
rbmPerformanceSummaryModel.setPartnersCommunicated(todayOverallCall);
|
1377 |
rbmPerformanceSummaryModel.setPartnersCommunicated(todayOverallCall);
|
| 1406 |
rbmPerformanceSummaryModel.setCollectionTarget(collectionTarget);
|
1378 |
rbmPerformanceSummaryModel.setCollectionTarget(collectionTarget);
|
| 1407 |
rbmPerformanceSummaryModel.setCollection(collection);
|
1379 |
rbmPerformanceSummaryModel.setCollection(collection);
|
| 1408 |
rbmPerformanceSummaryModel.setSecondaryTarget(rbmSecondaryTargetMap.get(rbmAuthId) == null ? 0
|
1380 |
rbmPerformanceSummaryModel.setSecondaryTarget(rbmSecondaryTargetMap.get(rbmAuthId) == null ? 0 : rbmSecondaryTargetMap.get(rbmAuthId).floatValue());
|
| 1409 |
: rbmSecondaryTargetMap.get(rbmAuthId).floatValue());
|
- |
|
| 1410 |
rbmPerformanceSummaryModel.setSecondary(
|
1381 |
rbmPerformanceSummaryModel.setSecondary(
|
| 1411 |
rbmSecondaryMap.get(rbmAuthId) == null ? 0 : rbmSecondaryMap.get(rbmAuthId).floatValue());
|
1382 |
rbmSecondaryMap.get(rbmAuthId) == null ? 0 : rbmSecondaryMap.get(rbmAuthId).floatValue());
|
| 1412 |
summaryModels.add(rbmPerformanceSummaryModel);
|
1383 |
summaryModels.add(rbmPerformanceSummaryModel);
|
| 1413 |
// cm.getData().getDatasets().get(0).getData().;
|
1384 |
// cm.getData().getDatasets().get(0).getData().;
|
| 1414 |
// cm.getData().getDatasets().get(0).getBackgroundColor();
|
1385 |
// cm.getData().getDatasets().get(0).getBackgroundColor();
|
| 1415 |
// cm.getData().getLabels()
|
1386 |
// cm.getData().getLabels()
|
| 1416 |
|
1387 |
|
| 1417 |
}
|
1388 |
}
|
| 1418 |
}
|
1389 |
}
|
| 1419 |
model.addAttribute("summaryModels", summaryModels);
|
1390 |
model.addAttribute("summaryModels", summaryModels);
|
| 1420 |
return "today_target";
|
1391 |
return "today_target";
|
| 1421 |
}
|
1392 |
}
|
| 1422 |
|
1393 |
|
| 1423 |
@RequestMapping(value = "/visitPlan", method = RequestMethod.GET)
|
1394 |
@RequestMapping(value = "/visitPlan", method = RequestMethod.GET)
|
| 1424 |
public String visitPlan(HttpServletRequest request, Model model) throws Exception {
|
1395 |
public String visitPlan(HttpServletRequest request, Model model) throws Exception {
|
| 1425 |
|
1396 |
|
| 1426 |
return "visit-request-plan";
|
1397 |
return "visit-request-plan";
|
| 1427 |
}
|
1398 |
}
|
| 1428 |
|
1399 |
|
| 1429 |
@RequestMapping(value = "/visit/getVisitPlan", method = RequestMethod.GET)
|
1400 |
@RequestMapping(value = "/visit/getVisitPlan", method = RequestMethod.GET)
|
| 1430 |
public String getVisitPlan(HttpServletRequest request, @RequestParam LocalDate date, Model model) throws Exception {
|
1401 |
public String getVisitPlan(HttpServletRequest request, @RequestParam LocalDate date, Model model) throws Exception {
|
| 1431 |
List<VisitRequest> visitRequests = visitRequestRepository.selectByAuthIdAndDate(date);
|
1402 |
List<VisitRequest> visitRequests = visitRequestRepository.selectByAuthIdAndDate(date);
|
| 1432 |
|
1403 |
|
| 1433 |
List<Integer> leadIds = visitRequests.stream().filter(x -> x.getVisitType().equals("lead"))
|
1404 |
List<Integer> leadIds = visitRequests.stream().filter(x -> x.getVisitType().equals("lead")).map(x -> x.getVisitId()).collect(Collectors.toList());
|
| 1434 |
.map(x -> x.getVisitId()).collect(Collectors.toList());
|
- |
|
| 1435 |
Map<Integer, Lead> leadMap = new HashMap<>();
|
1405 |
Map<Integer, Lead> leadMap = new HashMap<>();
|
| 1436 |
if (!leadIds.isEmpty()) {
|
1406 |
if (!leadIds.isEmpty()) {
|
| 1437 |
List<Lead> leads = leadRepository.selectAllByIds(leadIds);
|
1407 |
List<Lead> leads = leadRepository.selectAllByIds(leadIds);
|
| 1438 |
|
1408 |
|
| 1439 |
for (Lead lead : leads) {
|
1409 |
for (Lead lead : leads) {
|
| 1440 |
List<LeadActivity> leadActivities = leadActivityRepository.selectBYLeadId(lead.getId());
|
1410 |
List<LeadActivity> leadActivities = leadActivityRepository.selectBYLeadId(lead.getId());
|
| 1441 |
lead.setScheduledTimestamp(leadActivities.get(0).getSchelduleTimestamp());
|
1411 |
lead.setScheduledTimestamp(leadActivities.get(0).getSchelduleTimestamp());
|
| 1442 |
lead.setLeadActivity(leadActivities.get(0));
|
1412 |
lead.setLeadActivity(leadActivities.get(0));
|
| 1443 |
|
1413 |
|
| 1444 |
leadMap.put(lead.getId(), lead);
|
1414 |
leadMap.put(lead.getId(), lead);
|
| 1445 |
}
|
1415 |
}
|
| 1446 |
|
1416 |
|
| 1447 |
}
|
1417 |
}
|
| 1448 |
List<Integer> franchiseeIds = visitRequests.stream().filter(x -> x.getVisitType().equals("franchiseeVisit"))
|
1418 |
List<Integer> franchiseeIds = visitRequests.stream().filter(x -> x.getVisitType().equals("franchiseeVisit")).map(x -> x.getVisitId()).collect(Collectors.toList());
|
| 1449 |
.map(x -> x.getVisitId()).collect(Collectors.toList());
|
- |
|
| 1450 |
Map<Integer, FranchiseeVisit> franchiseeVisitsMap = new HashMap<>();
|
1419 |
Map<Integer, FranchiseeVisit> franchiseeVisitsMap = new HashMap<>();
|
| 1451 |
if (!franchiseeIds.isEmpty()) {
|
1420 |
if (!franchiseeIds.isEmpty()) {
|
| 1452 |
List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository.selectAllByIds(franchiseeIds);
|
1421 |
List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository.selectAllByIds(franchiseeIds);
|
| 1453 |
LOGGER.info("franchiseeVisits {}", franchiseeVisits);
|
1422 |
LOGGER.info("franchiseeVisits {}", franchiseeVisits);
|
| 1454 |
|
1423 |
|
| 1455 |
for (FranchiseeVisit franchiseeVisit : franchiseeVisits) {
|
1424 |
for (FranchiseeVisit franchiseeVisit : franchiseeVisits) {
|
| 1456 |
List<FranchiseeActivity> franchiseeActivities = franchiseeActivityRepository
|
1425 |
List<FranchiseeActivity> franchiseeActivities = franchiseeActivityRepository.selectByFranchiseeVisitId(franchiseeVisit.getId());
|
| 1457 |
.selectByFranchiseeVisitId(franchiseeVisit.getId());
|
- |
|
| 1458 |
LOGGER.info("franchiseeActivities {}", franchiseeActivities);
|
1426 |
LOGGER.info("franchiseeActivities {}", franchiseeActivities);
|
| 1459 |
|
1427 |
|
| 1460 |
franchiseeVisit.setScheduleTimestamp(franchiseeActivities.get(0).getSchelduleTimestamp());
|
1428 |
franchiseeVisit.setScheduleTimestamp(franchiseeActivities.get(0).getSchelduleTimestamp());
|
| 1461 |
franchiseeVisit.setFranchiseeActivity(franchiseeActivities.get(0));
|
1429 |
franchiseeVisit.setFranchiseeActivity(franchiseeActivities.get(0));
|
| 1462 |
|
1430 |
|
| 1463 |
franchiseeVisitsMap.put(franchiseeVisit.getId(), franchiseeVisit);
|
1431 |
franchiseeVisitsMap.put(franchiseeVisit.getId(), franchiseeVisit);
|
| 1464 |
}
|
1432 |
}
|
| 1465 |
|
1433 |
|
| 1466 |
}
|
1434 |
}
|
| 1467 |
|
1435 |
|
| 1468 |
Map<Integer, List<VisitRequest>> visitRequestMap = visitRequests.stream()
|
1436 |
Map<Integer, List<VisitRequest>> visitRequestMap = visitRequests.stream().collect(Collectors.groupingBy(x -> x.getCreatedBy()));
|
| 1469 |
.collect(Collectors.groupingBy(x -> x.getCreatedBy()));
|
- |
|
| 1470 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
1437 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| 1471 |
List<UserVisitModel> userVisits = new ArrayList<>();
|
1438 |
List<UserVisitModel> userVisits = new ArrayList<>();
|
| 1472 |
|
1439 |
|
| 1473 |
for (AuthUser authUser : authUsers) {
|
1440 |
for (AuthUser authUser : authUsers) {
|
| 1474 |
|
1441 |
|
| 1475 |
List<VisitRequest> authVisitRequests = visitRequestMap.get(authUser.getId());
|
1442 |
List<VisitRequest> authVisitRequests = visitRequestMap.get(authUser.getId());
|
| 1476 |
|
1443 |
|
| 1477 |
if (authVisitRequests != null) {
|
1444 |
if (authVisitRequests != null) {
|
| 1478 |
UserVisitModel userVisitModel = new UserVisitModel();
|
1445 |
UserVisitModel userVisitModel = new UserVisitModel();
|
| 1479 |
userVisitModel.setAuthUser(authUser.getFullName());
|
1446 |
userVisitModel.setAuthUser(authUser.getFullName());
|
| 1480 |
List<VisitDescriptionModel> visitDescriptions = new ArrayList<>();
|
1447 |
List<VisitDescriptionModel> visitDescriptions = new ArrayList<>();
|
| 1481 |
|
1448 |
|
| 1482 |
for (VisitRequest authVisitRequest : authVisitRequests) {
|
1449 |
for (VisitRequest authVisitRequest : authVisitRequests) {
|
| 1483 |
VisitDescriptionModel visitDescriptionModel = new VisitDescriptionModel();
|
1450 |
VisitDescriptionModel visitDescriptionModel = new VisitDescriptionModel();
|
| 1484 |
visitDescriptionModel.setVisitId(authVisitRequest.getVisitId());
|
1451 |
visitDescriptionModel.setVisitId(authVisitRequest.getVisitId());
|
| 1485 |
|
1452 |
|
| 1486 |
if (authVisitRequest.getVisitType().equals("lead")) {
|
1453 |
if (authVisitRequest.getVisitType().equals("lead")) {
|
| 1487 |
Lead lead = leadMap.get(authVisitRequest.getVisitId());
|
1454 |
Lead lead = leadMap.get(authVisitRequest.getVisitId());
|
| 1488 |
|
1455 |
|
| 1489 |
visitDescriptionModel.setVisitName(lead.getFirstName());
|
1456 |
visitDescriptionModel.setVisitName(lead.getFirstName());
|
| 1490 |
visitDescriptionModel.setCity(lead.getCity());
|
1457 |
visitDescriptionModel.setCity(lead.getCity());
|
| 1491 |
visitDescriptionModel.setState(lead.getState());
|
1458 |
visitDescriptionModel.setState(lead.getState());
|
| 1492 |
visitDescriptionModel.setScheduleTime(lead.getScheduledTimestamp());
|
1459 |
visitDescriptionModel.setScheduleTime(lead.getScheduledTimestamp());
|
| 1493 |
visitDescriptionModel.setRemarks(lead.getLeadActivity().getRemark());
|
1460 |
visitDescriptionModel.setRemarks(lead.getLeadActivity().getRemark());
|
| 1494 |
|
1461 |
|
| 1495 |
} else {
|
1462 |
} else {
|
| 1496 |
FranchiseeVisit franchiseeVisit = franchiseeVisitsMap.get(authVisitRequest.getVisitId());
|
1463 |
FranchiseeVisit franchiseeVisit = franchiseeVisitsMap.get(authVisitRequest.getVisitId());
|
| 1497 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(franchiseeVisit.getFofoId());
|
1464 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(franchiseeVisit.getFofoId());
|
| 1498 |
|
1465 |
|
| 1499 |
visitDescriptionModel.setVisitName(franchiseeVisit.getPartnerName());
|
1466 |
visitDescriptionModel.setVisitName(franchiseeVisit.getPartnerName());
|
| 1500 |
visitDescriptionModel.setCity(customRetailer.getAddress().getCity());
|
1467 |
visitDescriptionModel.setCity(customRetailer.getAddress().getCity());
|
| 1501 |
visitDescriptionModel.setState(customRetailer.getAddress().getState());
|
1468 |
visitDescriptionModel.setState(customRetailer.getAddress().getState());
|
| 1502 |
visitDescriptionModel
|
- |
|
| 1503 |
.setScheduleTime(franchiseeVisit.getFranchiseeActivity().getSchelduleTimestamp());
|
1469 |
visitDescriptionModel.setScheduleTime(franchiseeVisit.getFranchiseeActivity().getSchelduleTimestamp());
|
| 1504 |
visitDescriptionModel.setRemarks(franchiseeVisit.getAgenda());
|
1470 |
visitDescriptionModel.setRemarks(franchiseeVisit.getAgenda());
|
| 1505 |
|
1471 |
|
| 1506 |
}
|
1472 |
}
|
| 1507 |
|
1473 |
|
| 1508 |
if (authVisitRequest.getActionedBy() != 0) {
|
1474 |
if (authVisitRequest.getActionedBy() != 0) {
|
| 1509 |
AuthUser au = authRepository.selectById(authVisitRequest.getActionedBy());
|
1475 |
AuthUser au = authRepository.selectById(authVisitRequest.getActionedBy());
|
| 1510 |
|
1476 |
|
| 1511 |
visitDescriptionModel.setActionBy(au.getFullName());
|
1477 |
visitDescriptionModel.setActionBy(au.getFullName());
|
| 1512 |
}
|
1478 |
}
|
| 1513 |
visitDescriptionModel.setStatus(authVisitRequest.getStatus());
|
1479 |
visitDescriptionModel.setStatus(authVisitRequest.getStatus());
|
| 1514 |
visitDescriptionModel.setVisitType(authVisitRequest.getVisitType());
|
1480 |
visitDescriptionModel.setVisitType(authVisitRequest.getVisitType());
|
| 1515 |
visitDescriptions.add(visitDescriptionModel);
|
1481 |
visitDescriptions.add(visitDescriptionModel);
|
| 1516 |
}
|
1482 |
}
|
| 1517 |
|
1483 |
|
| 1518 |
userVisitModel.setVisitDescriptions(visitDescriptions);
|
1484 |
userVisitModel.setVisitDescriptions(visitDescriptions);
|
| 1519 |
userVisits.add(userVisitModel);
|
1485 |
userVisits.add(userVisitModel);
|
| 1520 |
}
|
1486 |
}
|
| 1521 |
|
1487 |
|
| 1522 |
}
|
1488 |
}
|
| 1523 |
|
1489 |
|
| 1524 |
model.addAttribute("userVisits", userVisits);
|
1490 |
model.addAttribute("userVisits", userVisits);
|
| 1525 |
|
1491 |
|
| 1526 |
return "visit-request-plan";
|
1492 |
return "visit-request-plan";
|
| 1527 |
}
|
1493 |
}
|
| 1528 |
}
|
1494 |
}
|