| 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;
|
| 3 |
import java.time.LocalDate;
|
5 |
import java.time.LocalDate;
|
| 4 |
import java.time.LocalDateTime;
|
6 |
import java.time.LocalDateTime;
|
| 5 |
import java.time.format.DateTimeFormatter;
|
7 |
import java.time.format.DateTimeFormatter;
|
| 6 |
import java.util.ArrayList;
|
8 |
import java.util.ArrayList;
|
| 7 |
import java.util.Arrays;
|
9 |
import java.util.Arrays;
|
| Line 10... |
Line 12... |
| 10 |
import java.util.List;
|
12 |
import java.util.List;
|
| 11 |
import java.util.Map;
|
13 |
import java.util.Map;
|
| 12 |
import java.util.stream.Collectors;
|
14 |
import java.util.stream.Collectors;
|
| 13 |
|
15 |
|
| 14 |
import javax.servlet.http.HttpServletRequest;
|
16 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
17 |
import javax.servlet.http.HttpServletResponse;
|
| 15 |
import javax.transaction.Transactional;
|
18 |
import javax.transaction.Transactional;
|
| 16 |
|
19 |
|
| 17 |
import org.apache.logging.log4j.LogManager;
|
20 |
import org.apache.logging.log4j.LogManager;
|
| 18 |
import org.apache.logging.log4j.Logger;
|
21 |
import org.apache.logging.log4j.Logger;
|
| 19 |
import org.springframework.beans.factory.annotation.Autowired;
|
22 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
23 |
import org.springframework.core.io.InputStreamResource;
|
| - |
|
24 |
import org.springframework.http.HttpHeaders;
|
| - |
|
25 |
import org.springframework.http.HttpStatus;
|
| - |
|
26 |
import org.springframework.http.ResponseEntity;
|
| 20 |
import org.springframework.stereotype.Controller;
|
27 |
import org.springframework.stereotype.Controller;
|
| 21 |
import org.springframework.ui.Model;
|
28 |
import org.springframework.ui.Model;
|
| 22 |
import org.springframework.web.bind.annotation.RequestBody;
|
29 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 23 |
import org.springframework.web.bind.annotation.RequestMapping;
|
30 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 24 |
import org.springframework.web.bind.annotation.RequestMethod;
|
31 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 25 |
import org.springframework.web.bind.annotation.RequestParam;
|
32 |
import org.springframework.web.bind.annotation.RequestParam;
|
| - |
|
33 |
import org.springframework.web.bind.annotation.RequestPart;
|
| - |
|
34 |
import org.springframework.web.multipart.MultipartFile;
|
| 26 |
|
35 |
|
| 27 |
import com.google.gson.Gson;
|
36 |
import com.google.gson.Gson;
|
| 28 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
37 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 29 |
import com.spice.profitmandi.common.model.ChartInvestmentModel;
|
38 |
import com.spice.profitmandi.common.model.ChartInvestmentModel;
|
| 30 |
import com.spice.profitmandi.common.model.Data;
|
39 |
import com.spice.profitmandi.common.model.Data;
|
| 31 |
import com.spice.profitmandi.common.model.DataInvestmentModel;
|
40 |
import com.spice.profitmandi.common.model.DataInvestmentModel;
|
| 32 |
import com.spice.profitmandi.common.model.Legend;
|
41 |
import com.spice.profitmandi.common.model.Legend;
|
| 33 |
import com.spice.profitmandi.common.model.OptionModel;
|
42 |
import com.spice.profitmandi.common.model.OptionModel;
|
| 34 |
import com.spice.profitmandi.common.model.PieLables;
|
43 |
import com.spice.profitmandi.common.model.PieLables;
|
| 35 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
44 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
45 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 36 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
46 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 37 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
47 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 38 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
48 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 39 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
49 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
| 40 |
import com.spice.profitmandi.dao.entity.user.LeadActivity;
|
50 |
import com.spice.profitmandi.dao.entity.user.LeadActivity;
|
| 41 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
51 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
| 42 |
import com.spice.profitmandi.dao.model.ChartLeadModel;
|
52 |
import com.spice.profitmandi.dao.model.ChartLeadModel;
|
| 43 |
import com.spice.profitmandi.dao.model.CreateLeacdActivityRequest;
|
53 |
import com.spice.profitmandi.dao.model.CreateLeacdActivityRequest;
|
| 44 |
import com.spice.profitmandi.dao.model.CreateRefferalRequest;
|
54 |
import com.spice.profitmandi.dao.model.CreateRefferalRequest;
|
| 45 |
import com.spice.profitmandi.dao.model.DataLeadModel;
|
55 |
import com.spice.profitmandi.dao.model.DataLeadModel;
|
| - |
|
56 |
import com.spice.profitmandi.dao.model.LeadIvoryModel;
|
| 46 |
import com.spice.profitmandi.dao.model.LeadStatusData;
|
57 |
import com.spice.profitmandi.dao.model.LeadStatusData;
|
| - |
|
58 |
import com.spice.profitmandi.dao.model.StateGstRateModel;
|
| 47 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
59 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 48 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
60 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 49 |
import com.spice.profitmandi.dao.repository.dtr.LeadActivityRepository;
|
61 |
import com.spice.profitmandi.dao.repository.dtr.LeadActivityRepository;
|
| 50 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
62 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 51 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
63 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| Line 77... |
Line 89... |
| 77 |
@Autowired
|
89 |
@Autowired
|
| 78 |
private Gson gson;
|
90 |
private Gson gson;
|
| 79 |
|
91 |
|
| 80 |
@Autowired
|
92 |
@Autowired
|
| 81 |
private CookiesProcessor cookiesProcessor;
|
93 |
private CookiesProcessor cookiesProcessor;
|
| 82 |
|
94 |
|
| 83 |
@Autowired
|
95 |
@Autowired
|
| 84 |
PositionRepository positionRepository;
|
96 |
PositionRepository positionRepository;
|
| 85 |
|
97 |
|
| 86 |
@Autowired
|
98 |
@Autowired
|
| 87 |
private MVCResponseSender mvcResponseSender;
|
99 |
private MVCResponseSender mvcResponseSender;
|
| 88 |
|
100 |
|
| 89 |
List<LeadStatus> status = Arrays.asList(LeadStatus.notInterested, LeadStatus.finalized);
|
101 |
List<LeadStatus> status = Arrays.asList(LeadStatus.notInterested, LeadStatus.finalized);
|
| 90 |
|
102 |
|
| 91 |
@RequestMapping(value = "/getOpenLead", method = RequestMethod.GET)
|
103 |
@RequestMapping(value = "/getOpenLead", method = RequestMethod.GET)
|
| 92 |
public String getOpenLead(HttpServletRequest request,
|
104 |
public String getOpenLead(HttpServletRequest request,
|
| 93 |
@RequestParam(name = "leadStatus", required = false, defaultValue = "followUp") List<LeadStatus> leadStatus,
|
105 |
@RequestParam(name = "leadStatus", required = false, defaultValue = "All") List<LeadStatus> leadStatus,
|
| 94 |
@RequestParam(name = "color", required = false, defaultValue = "") List<String> color, Model model)
|
106 |
@RequestParam(name = "color", required = false, defaultValue = "") List<String> color, Model model)
|
| 95 |
throws Exception {
|
107 |
throws Exception {
|
| 96 |
|
108 |
|
| 97 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
109 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 98 |
String emailId = loginDetails.getEmailId();
|
110 |
String emailId = loginDetails.getEmailId();
|
| 99 |
AuthUser authUser = authRepository.selectByEmailOrMobile(emailId);
|
111 |
AuthUser authUser = authRepository.selectByEmailOrMobile(emailId);
|
| 100 |
|
- |
|
| 101 |
|
112 |
|
| 102 |
boolean authPositon = positionRepository.hasCategory(authUser.getId(),ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
113 |
boolean authPositon = positionRepository.hasCategory(authUser.getId(),
|
| - |
|
114 |
ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
| 103 |
|
115 |
|
| 104 |
if (leadStatus.contains(LeadStatus.All)) {
|
116 |
if (leadStatus.contains(LeadStatus.All)) {
|
| 105 |
|
117 |
|
| 106 |
leadStatus.addAll(Arrays.asList(LeadStatus.values()));
|
118 |
leadStatus.addAll(Arrays.asList(LeadStatus.values()));
|
| 107 |
}
|
119 |
}
|
| 108 |
|
120 |
|
| Line 112... |
Line 124... |
| 112 |
if (!color.isEmpty()) {
|
124 |
if (!color.isEmpty()) {
|
| 113 |
if (color.contains("All")) {
|
125 |
if (color.contains("All")) {
|
| 114 |
color.add("yellow");
|
126 |
color.add("yellow");
|
| 115 |
color.add("green");
|
127 |
color.add("green");
|
| 116 |
}
|
128 |
}
|
| 117 |
if(authPositon)
|
129 |
if (authPositon) {
|
| 118 |
{
|
- |
|
| 119 |
authUserIds = authService.getAllReportees(authUser.getId());
|
130 |
authUserIds = authService.getAllReportees(authUser.getId());
|
| 120 |
authUserIds.add(authUser.getId());
|
131 |
authUserIds.add(authUser.getId());
|
| 121 |
LOGGER.info("authIds" + authUserIds);
|
132 |
LOGGER.info("authIds" + authUserIds);
|
| 122 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds, color,
|
133 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds,
|
| 123 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(3));
|
134 |
color, LocalDateTime.now().withDayOfMonth(1).minusMonths(3));
|
| 124 |
|
135 |
|
| 125 |
}
|
- |
|
| 126 |
else {
|
136 |
} else {
|
| 127 |
|
137 |
|
| 128 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestamp(leadStatus, color,
|
138 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestamp(leadStatus, color,
|
| 129 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(3));
|
139 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(3));
|
| 130 |
}
|
140 |
}
|
| 131 |
|
141 |
|
| 132 |
} else {
|
142 |
} else {
|
| 133 |
|
143 |
|
| 134 |
if(authPositon) {
|
144 |
if (authPositon) {
|
| 135 |
authUserIds = authService.getAllReportees(authUser.getId());
|
145 |
authUserIds = authService.getAllReportees(authUser.getId());
|
| 136 |
authUserIds.add(authUser.getId());
|
146 |
authUserIds.add(authUser.getId());
|
| 137 |
LOGGER.info("authIds" + authUserIds);
|
147 |
LOGGER.info("authIds" + authUserIds);
|
| 138 |
leads = leadRepository.selectAllByStatusAndUpdatedTimestampAndAuthId(leadStatus,
|
148 |
leads = leadRepository.selectAllByStatusAndUpdatedTimestampAndAuthId(leadStatus,
|
| 139 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(3),authUserIds);
|
149 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(3), authUserIds);
|
| 140 |
|
150 |
|
| 141 |
}
|
- |
|
| 142 |
else {
|
151 |
} else {
|
| 143 |
leads = leadRepository.selectAllByStatusAndUpdatedTimestamp(leadStatus,
|
152 |
leads = leadRepository.selectAllByStatusAndUpdatedTimestamp(leadStatus,
|
| 144 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(3));
|
153 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(3));
|
| 145 |
}
|
154 |
}
|
| 146 |
// List<Lead> leads = leadRepository.selectAllBylistStatus(leadStatus);
|
155 |
// List<Lead> leads = leadRepository.selectAllBylistStatus(leadStatus);
|
| 147 |
if (!leads.isEmpty()) {
|
156 |
if (!leads.isEmpty()) {
|
| 148 |
leads.addAll(leadRepository.selectAllByStatus(LeadStatus.pending));
|
157 |
leads.addAll(leadRepository.selectAllByStatus(LeadStatus.pending));
|
| 149 |
}
|
158 |
}
|
| 150 |
}
|
159 |
}
|
| 151 |
if(authPositon && authUserIds.size() > 0) {
|
160 |
if (authPositon && authUserIds.size() > 0) {
|
| 152 |
List<String> leadCreators = new ArrayList<>();
|
161 |
List<String> leadCreators = new ArrayList<>();
|
| 153 |
leadCreators.add("daily-sync");
|
162 |
leadCreators.add("daily-sync");
|
| 154 |
leadCreators.addAll(authRepository.selectAllAuthUserByIds(authUserIds).stream().map(x->x.getFullName()).collect(Collectors.toList()));
|
163 |
leadCreators.addAll(authRepository.selectAllAuthUserByIds(authUserIds).stream().map(x -> x.getFullName())
|
| - |
|
164 |
.collect(Collectors.toList()));
|
| 155 |
model.addAttribute("leadCreators", leadCreators);
|
165 |
model.addAttribute("leadCreators", leadCreators);
|
| 156 |
}
|
166 |
}
|
| 157 |
List<Lead> weekLast = new ArrayList<>();
|
167 |
List<Lead> weekLast = new ArrayList<>();
|
| 158 |
List<Lead> weekThird = new ArrayList<>();
|
168 |
List<Lead> weekThird = new ArrayList<>();
|
| 159 |
List<Lead> weekSecond = new ArrayList<>();
|
169 |
List<Lead> weekSecond = new ArrayList<>();
|
| 160 |
List<Lead> weekFirst = new ArrayList<>();
|
170 |
List<Lead> weekFirst = new ArrayList<>();
|
| 161 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
171 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 162 |
List<LeadWeakWiseModel> lwDays = new ArrayList<>();
|
172 |
List<LeadWeakWiseModel> lwDays = new ArrayList<>();
|
| 163 |
|
- |
|
| 164 |
|
173 |
|
| 165 |
for (int i = 7; i >= 1; i--) {
|
174 |
for (int i = 7; i >= 1; i--) {
|
| 166 |
LocalDateTime startOfDay = curDate.minusDays(i);
|
175 |
LocalDateTime startOfDay = curDate.minusDays(i);
|
| 167 |
|
176 |
|
| 168 |
LeadWeakWiseModel lm = new LeadWeakWiseModel();
|
177 |
LeadWeakWiseModel lm = new LeadWeakWiseModel();
|
| 169 |
lm.setMonth(startOfDay.toLocalDate());
|
178 |
lm.setMonth(startOfDay.toLocalDate());
|
| 170 |
lwDays.add(lm);
|
179 |
lwDays.add(lm);
|
| 171 |
}
|
180 |
}
|
| 172 |
if(!leads.isEmpty())
|
181 |
if (!leads.isEmpty()) {
|
| 173 |
{
|
- |
|
| 174 |
for (Lead lead : leads) {
|
182 |
for (Lead lead : leads) {
|
| 175 |
|
183 |
|
| 176 |
if (lead.getCreatedTimestamp().isAfter(curDate.minusDays(28))
|
184 |
if (lead.getCreatedTimestamp().isAfter(curDate.minusDays(28))
|
| 177 |
&& lead.getCreatedTimestamp().isBefore(curDate.minusDays(21))) {
|
185 |
&& lead.getCreatedTimestamp().isBefore(curDate.minusDays(21))) {
|
| 178 |
weekLast.add(lead);
|
186 |
weekLast.add(lead);
|
| 179 |
|
187 |
|
| 180 |
} else if(lead.getCreatedTimestamp().isAfter(curDate.minusDays(21))
|
188 |
} else if (lead.getCreatedTimestamp().isAfter(curDate.minusDays(21))
|
| 181 |
&& lead.getCreatedTimestamp().isBefore(curDate.minusDays(14))) {
|
189 |
&& lead.getCreatedTimestamp().isBefore(curDate.minusDays(14))) {
|
| 182 |
weekThird.add(lead);
|
190 |
weekThird.add(lead);
|
| 183 |
} else if (lead.getCreatedTimestamp().isAfter(curDate.minusDays(14))
|
191 |
} else if (lead.getCreatedTimestamp().isAfter(curDate.minusDays(14))
|
| 184 |
&& lead.getCreatedTimestamp().isBefore(curDate.minusDays(7))) {
|
192 |
&& lead.getCreatedTimestamp().isBefore(curDate.minusDays(7))) {
|
| 185 |
|
193 |
|
| 186 |
weekSecond.add(lead);
|
194 |
weekSecond.add(lead);
|
| 187 |
} else if (lead.getCreatedTimestamp().isAfter(curDate.minusDays(7))) {
|
195 |
} else if (lead.getCreatedTimestamp().isAfter(curDate.minusDays(7))) {
|
| 188 |
weekFirst.add(lead);
|
196 |
weekFirst.add(lead);
|
| 189 |
}
|
197 |
}
|
| 190 |
|
198 |
|
| - |
|
199 |
}
|
| 191 |
}
|
200 |
}
|
| 192 |
}
|
- |
|
| 193 |
LOGGER.info("weekLast" + weekLast);
|
201 |
LOGGER.info("weekLast" + weekLast);
|
| 194 |
LOGGER.info("weekThird" + weekThird);
|
202 |
LOGGER.info("weekThird" + weekThird);
|
| 195 |
LOGGER.info("weekSecond" + weekSecond);
|
203 |
LOGGER.info("weekSecond" + weekSecond);
|
| - |
|
204 |
Map<String, Long> leadLasts = weekLast.stream()
|
| 196 |
Map<String, Long> leadLasts = weekLast.stream().collect(Collectors.groupingBy(x -> x.getCreatedBy(), Collectors.counting()));
|
205 |
.collect(Collectors.groupingBy(x -> x.getCreatedBy(), Collectors.counting()));
|
| - |
|
206 |
Map<String, Long> leadThirds = weekThird.stream()
|
| 197 |
Map<String, Long> leadThirds = weekThird.stream().collect(Collectors.groupingBy(x -> x.getCreatedBy(), Collectors.counting()));
|
207 |
.collect(Collectors.groupingBy(x -> x.getCreatedBy(), Collectors.counting()));
|
| 198 |
Map<String, Long> leadSeconds = weekSecond.stream().collect(Collectors.groupingBy(x -> x.getCreatedBy(),
|
208 |
Map<String, Long> leadSeconds = weekSecond.stream().collect(Collectors.groupingBy(x -> x.getCreatedBy(),
|
| 199 |
Collectors.mapping(Lead::getCreatedBy, Collectors.counting())));
|
209 |
Collectors.mapping(Lead::getCreatedBy, Collectors.counting())));
|
| 200 |
|
210 |
|
| 201 |
Map<String, Map<LocalDate, Long>> leadFirsts = weekFirst.stream()
|
211 |
Map<String, Map<LocalDate, Long>> leadFirsts = weekFirst.stream()
|
| 202 |
.collect(Collectors.groupingBy(x -> x.getCreatedBy(),
|
212 |
.collect(Collectors.groupingBy(x -> x.getCreatedBy(),
|
| Line 230... |
Line 240... |
| 230 |
LOGGER.info("leads" + leads);
|
240 |
LOGGER.info("leads" + leads);
|
| 231 |
List<String> stateNames = stateRepository.selectAll().stream().map(x -> x.getName())
|
241 |
List<String> stateNames = stateRepository.selectAll().stream().map(x -> x.getName())
|
| 232 |
.collect(Collectors.toList());
|
242 |
.collect(Collectors.toList());
|
| 233 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
243 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| 234 |
LocalDate lastDate = curDate.minusDays(1).toLocalDate();
|
244 |
LocalDate lastDate = curDate.minusDays(1).toLocalDate();
|
| 235 |
|
245 |
|
| 236 |
List<LocalDate> weekDates = new ArrayList<>();
|
246 |
List<LocalDate> weekDates = new ArrayList<>();
|
| 237 |
|
247 |
|
| 238 |
weekDates.add(curDate.minusDays(28).toLocalDate());
|
248 |
weekDates.add(curDate.minusDays(28).toLocalDate());
|
| 239 |
weekDates.add(curDate.minusDays(22).toLocalDate());
|
249 |
weekDates.add(curDate.minusDays(22).toLocalDate());
|
| 240 |
weekDates.add(curDate.minusDays(21).toLocalDate());
|
250 |
weekDates.add(curDate.minusDays(21).toLocalDate());
|
| 241 |
weekDates.add(curDate.minusDays(15).toLocalDate());
|
251 |
weekDates.add(curDate.minusDays(15).toLocalDate());
|
| 242 |
weekDates.add(curDate.minusDays(14).toLocalDate());
|
252 |
weekDates.add(curDate.minusDays(14).toLocalDate());
|
| 243 |
weekDates.add(curDate.minusDays(8).toLocalDate());
|
253 |
weekDates.add(curDate.minusDays(8).toLocalDate());
|
| 244 |
weekDates.add(curDate.minusDays(7).toLocalDate());
|
254 |
weekDates.add(curDate.minusDays(7).toLocalDate());
|
| 245 |
LOGGER.info("lastDate" + lastDate);
|
255 |
LOGGER.info("lastDate" + lastDate);
|
| 246 |
|
- |
|
| 247 |
|
256 |
|
| 248 |
model.addAttribute("weekDates", weekDates);
|
257 |
model.addAttribute("weekDates", weekDates);
|
| 249 |
|
258 |
|
| 250 |
model.addAttribute("lastDate", lastDate);
|
259 |
model.addAttribute("lastDate", lastDate);
|
| 251 |
model.addAttribute("stateNames", stateNames);
|
260 |
model.addAttribute("stateNames", stateNames);
|
| 252 |
model.addAttribute("authUsers", authUsers);
|
261 |
model.addAttribute("authUsers", authUsers);
|
| 253 |
model.addAttribute("lead", leads);
|
262 |
model.addAttribute("lead", leads);
|
| 254 |
model.addAttribute("leadStatus", LeadStatus.values());
|
263 |
model.addAttribute("leadStatus", LeadStatus.values());
|
| 255 |
model.addAttribute("leadLasts", leadLasts);
|
264 |
model.addAttribute("leadLasts", leadLasts);
|
| 256 |
model.addAttribute("leadThirds", leadThirds);
|
265 |
model.addAttribute("leadThirds", leadThirds);
|
| 257 |
model.addAttribute("leadSeconds", leadSeconds);
|
266 |
model.addAttribute("leadSeconds", leadSeconds);
|
| 258 |
model.addAttribute("leadFirsts", leadFirsts);
|
267 |
model.addAttribute("leadFirsts", leadFirsts);
|
| 259 |
model.addAttribute("lwDays", lwDays);
|
268 |
model.addAttribute("lwDays", lwDays);
|
| - |
|
269 |
model.addAttribute("colors", color);
|
| 260 |
|
270 |
|
| 261 |
model.addAttribute("selectedLeadStatus", leadStatus.get(0));
|
271 |
model.addAttribute("selectedLeadStatus", leadStatus.get(0));
|
| 262 |
return "lead";
|
272 |
return "lead";
|
| 263 |
|
273 |
|
| 264 |
}
|
274 |
}
|
| Line 266... |
Line 276... |
| 266 |
public ChartLeadModel getLeadChart(List<Lead> leads) throws ProfitMandiBusinessException {
|
276 |
public ChartLeadModel getLeadChart(List<Lead> leads) throws ProfitMandiBusinessException {
|
| 267 |
|
277 |
|
| 268 |
Map<LeadStatus, Long> leadStatusMap = leads.stream().collect(
|
278 |
Map<LeadStatus, Long> leadStatusMap = leads.stream().collect(
|
| 269 |
Collectors.groupingBy(x -> x.getStatus(), Collectors.mapping(Lead::getStatus, Collectors.counting())));
|
279 |
Collectors.groupingBy(x -> x.getStatus(), Collectors.mapping(Lead::getStatus, Collectors.counting())));
|
| 270 |
|
280 |
|
| - |
|
281 |
Map<String, Long> hotLeadsMap = leads.stream().collect(
|
| - |
|
282 |
Collectors.groupingBy(x -> x.getColor(), Collectors.mapping(Lead::getColor, Collectors.counting())));
|
| - |
|
283 |
|
| - |
|
284 |
LOGGER.info("hotLeadsMap" + hotLeadsMap);
|
| 271 |
ChartLeadModel cm = new ChartLeadModel();
|
285 |
ChartLeadModel cm = new ChartLeadModel();
|
| 272 |
|
286 |
|
| 273 |
HashSet<LeadStatus> labels = new HashSet<LeadStatus>();
|
287 |
HashSet<LeadStatus> labels = new HashSet<LeadStatus>();
|
| 274 |
labels.addAll(leadStatusMap.keySet());
|
288 |
labels.addAll(leadStatusMap.keySet());
|
| - |
|
289 |
|
| - |
|
290 |
|
| - |
|
291 |
HashSet<String> hotLeads = new HashSet<String>();
|
| - |
|
292 |
hotLeads.addAll(leadStatusMap.keySet().stream().map(x -> x.toString()).collect(Collectors.toSet()));
|
| - |
|
293 |
hotLeads.add("HotLead");
|
| - |
|
294 |
|
| 275 |
|
295 |
|
| - |
|
296 |
HashSet<String> hotLeadKeys = new HashSet<String>();
|
| - |
|
297 |
|
| - |
|
298 |
hotLeadKeys.add("HotLead");
|
| - |
|
299 |
List<String> hotLeadGreen = new ArrayList<>(hotLeadKeys);
|
| - |
|
300 |
|
| 276 |
List<LeadStatus> labelList = new ArrayList<>(labels);
|
301 |
List<LeadStatus> labelList = new ArrayList<>(labels);
|
| 277 |
List<String> backgroundColor = new ArrayList<>();
|
302 |
List<String> backgroundColor = new ArrayList<>();
|
| 278 |
|
- |
|
| - |
|
303 |
LOGGER.info("hotLeadKeys" + hotLeadKeys);
|
| 279 |
List<Long> values = new ArrayList<>();
|
304 |
List<Long> values = new ArrayList<>();
|
| 280 |
|
305 |
|
| 281 |
for (LeadStatus label : labelList) {
|
306 |
for (LeadStatus label : labelList) {
|
| 282 |
values.add(leadStatusMap.get(label));
|
307 |
values.add(leadStatusMap.get(label));
|
| 283 |
|
308 |
|
| Line 290... |
Line 315... |
| 290 |
if (label.equals(LeadStatus.followUp)) {
|
315 |
if (label.equals(LeadStatus.followUp)) {
|
| 291 |
backgroundColor.add("#9ACD32");
|
316 |
backgroundColor.add("#9ACD32");
|
| 292 |
}
|
317 |
}
|
| 293 |
if (label.equals(LeadStatus.finalized)) {
|
318 |
if (label.equals(LeadStatus.finalized)) {
|
| 294 |
backgroundColor.add("blue");
|
319 |
backgroundColor.add("blue");
|
| - |
|
320 |
}
|
| - |
|
321 |
}
|
| - |
|
322 |
|
| - |
|
323 |
for ( String hotLeadList : hotLeadGreen){
|
| - |
|
324 |
|
| - |
|
325 |
if(hotLeadList.equals("HotLead"))
|
| - |
|
326 |
{
|
| - |
|
327 |
backgroundColor.add("green");
|
| - |
|
328 |
values.add(hotLeadsMap.get("Green"));
|
| - |
|
329 |
|
| 295 |
}
|
330 |
}
|
| - |
|
331 |
|
| 296 |
}
|
332 |
}
|
| 297 |
LOGGER.info("labelList" + labelList);
|
333 |
LOGGER.info("labelList" + labelList);
|
| 298 |
|
334 |
|
| 299 |
LOGGER.info("backgroundColor" + backgroundColor);
|
335 |
LOGGER.info("backgroundColor" + backgroundColor);
|
| 300 |
LOGGER.info("labelsChartLead" + labels);
|
336 |
LOGGER.info("labelsChartLead" + labels);
|
| Line 314... |
Line 350... |
| 314 |
List<LeadStatusData> dataList = new ArrayList<>();
|
350 |
List<LeadStatusData> dataList = new ArrayList<>();
|
| 315 |
dataList.add(data);
|
351 |
dataList.add(data);
|
| 316 |
|
352 |
|
| 317 |
DataLeadModel datasets = new DataLeadModel();
|
353 |
DataLeadModel datasets = new DataLeadModel();
|
| 318 |
datasets.setDatasets(dataList);
|
354 |
datasets.setDatasets(dataList);
|
| 319 |
datasets.setLabels(labels);
|
355 |
datasets.setLabels(hotLeads);
|
| 320 |
|
356 |
|
| 321 |
OptionModel om = new OptionModel();
|
357 |
OptionModel om = new OptionModel();
|
| 322 |
om.setLegend(legend);
|
358 |
om.setLegend(legend);
|
| 323 |
|
359 |
|
| 324 |
cm.setType("pie");
|
360 |
cm.setType("pie");
|
| Line 559... |
Line 595... |
| 559 |
|
595 |
|
| 560 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
596 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 561 |
return "response";
|
597 |
return "response";
|
| 562 |
|
598 |
|
| 563 |
}
|
599 |
}
|
| - |
|
600 |
@RequestMapping(value = "/downloadIvoryLead", method = RequestMethod.GET)
|
| - |
|
601 |
public ResponseEntity<?> downloadDelayDayTemplate(HttpServletRequest request) throws Exception {
|
| - |
|
602 |
List<List<?>> rows = new ArrayList<>();
|
| - |
|
603 |
|
| - |
|
604 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
|
| - |
|
605 |
.getCSVByteStream(Arrays.asList("created_time", "Name", "email","Mobile","state","city"), rows);
|
| - |
|
606 |
|
| - |
|
607 |
final HttpHeaders headers = new HttpHeaders();
|
| - |
|
608 |
headers.set("Content-Type", "text/csv");
|
| - |
|
609 |
headers.set("Content-disposition", "inline; filename=Ivory.format.csv");
|
| - |
|
610 |
headers.setContentLength(baos.toByteArray().length);
|
| - |
|
611 |
|
| - |
|
612 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
| - |
|
613 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| - |
|
614 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| - |
|
615 |
|
| - |
|
616 |
}
|
| - |
|
617 |
@RequestMapping(value = "/csvFileAndSetLead", method = RequestMethod.POST)
|
| - |
|
618 |
public String readCsvFileAndSetLead(HttpServletRequest request, Model model, HttpServletResponse response,
|
| - |
|
619 |
@RequestPart MultipartFile file) throws Throwable {
|
| - |
|
620 |
|
| - |
|
621 |
LOGGER.info("file" + file.toString());
|
| - |
|
622 |
|
| - |
|
623 |
String fileName = file.getName();
|
| - |
|
624 |
|
| - |
|
625 |
String fileNames = file.getOriginalFilename();
|
| - |
|
626 |
|
| - |
|
627 |
LOGGER.info("fileName" + fileName);
|
| - |
|
628 |
LOGGER.info("fileNames" + fileNames);
|
| - |
|
629 |
|
| - |
|
630 |
List<LeadIvoryModel> leadIvoryModels = leadActivityRepository.readFile(file);
|
| - |
|
631 |
|
| - |
|
632 |
LOGGER.info("sgtFileName" + leadIvoryModels);
|
| - |
|
633 |
if (leadIvoryModels.isEmpty()) {
|
| - |
|
634 |
return "";
|
| - |
|
635 |
}
|
| - |
|
636 |
|
| - |
|
637 |
for (LeadIvoryModel leadIvoryModel : leadIvoryModels) {
|
| - |
|
638 |
|
| - |
|
639 |
Lead lead = new Lead();
|
| - |
|
640 |
lead.setFirstName(leadIvoryModel.getFirstName());
|
| - |
|
641 |
lead.setLastName("");
|
| - |
|
642 |
lead.setLeadMobile(leadIvoryModel.getMobile());
|
| - |
|
643 |
|
| - |
|
644 |
lead.setState(leadIvoryModel.getState());
|
| - |
|
645 |
lead.setCity(leadIvoryModel.getCity());
|
| - |
|
646 |
lead.setAddress("NOT AVAILABLE");
|
| - |
|
647 |
|
| - |
|
648 |
AuthUser authUser = authRepository.selectById(4);
|
| - |
|
649 |
|
| - |
|
650 |
if(leadIvoryModel.getCreatedTime() != null) {
|
| - |
|
651 |
lead.setCreatedTimestamp(leadIvoryModel.getCreatedTime());
|
| - |
|
652 |
}
|
| - |
|
653 |
else
|
| - |
|
654 |
{
|
| - |
|
655 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
656 |
}
|
| - |
|
657 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
658 |
lead.setStatus(LeadStatus.pending);
|
| - |
|
659 |
lead.setAssignTo(authUser.getId());
|
| - |
|
660 |
lead.setSource("IVORY");
|
| - |
|
661 |
lead.setColor("yellow");
|
| - |
|
662 |
// change
|
| - |
|
663 |
|
| - |
|
664 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
| - |
|
665 |
lead.setCreatedBy(authUserName);
|
| - |
|
666 |
lead.setAuthId(authUser.getId());
|
| - |
|
667 |
|
| - |
|
668 |
leadRepository.persist(lead);
|
| - |
|
669 |
|
| - |
|
670 |
LeadActivity leadActivity = new LeadActivity();
|
| - |
|
671 |
leadActivity.setLeadId(lead.getId());
|
| - |
|
672 |
leadActivity.setRemark("Internet");
|
| - |
|
673 |
leadActivity.setSchelduleTimestamp(null);
|
| - |
|
674 |
|
| - |
|
675 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
676 |
leadActivityRepository.persist(leadActivity);
|
| - |
|
677 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
678 |
|
| - |
|
679 |
}
|
| - |
|
680 |
|
| - |
|
681 |
model.addAttribute("responseSTG", mvcResponseSender.createResponseString(true));
|
| - |
|
682 |
|
| - |
|
683 |
return "response";
|
| - |
|
684 |
|
| - |
|
685 |
}
|
| - |
|
686 |
|
| 564 |
}
|
687 |
}
|