| Line 44... |
Line 44... |
| 44 |
import org.springframework.http.HttpHeaders;
|
44 |
import org.springframework.http.HttpHeaders;
|
| 45 |
import org.springframework.http.HttpStatus;
|
45 |
import org.springframework.http.HttpStatus;
|
| 46 |
import org.springframework.http.MediaType;
|
46 |
import org.springframework.http.MediaType;
|
| 47 |
import org.springframework.http.ResponseEntity;
|
47 |
import org.springframework.http.ResponseEntity;
|
| 48 |
import org.springframework.stereotype.Controller;
|
48 |
import org.springframework.stereotype.Controller;
|
| - |
|
49 |
import org.springframework.transaction.annotation.Transactional;
|
| 49 |
import org.springframework.ui.Model;
|
50 |
import org.springframework.ui.Model;
|
| 50 |
import org.springframework.util.StringUtils;
|
51 |
import org.springframework.util.StringUtils;
|
| 51 |
import org.springframework.web.bind.annotation.*;
|
52 |
import org.springframework.web.bind.annotation.*;
|
| 52 |
import org.springframework.web.multipart.MultipartFile;
|
53 |
import org.springframework.web.multipart.MultipartFile;
|
| 53 |
|
54 |
|
| 54 |
import javax.servlet.http.HttpServletRequest;
|
55 |
import javax.servlet.http.HttpServletRequest;
|
| 55 |
import javax.servlet.http.HttpServletResponse;
|
56 |
import javax.servlet.http.HttpServletResponse;
|
| 56 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 57 |
import java.io.ByteArrayInputStream;
|
57 |
import java.io.ByteArrayInputStream;
|
| 58 |
import java.io.InputStream;
|
58 |
import java.io.InputStream;
|
| 59 |
import java.text.DecimalFormat;
|
59 |
import java.text.DecimalFormat;
|
| 60 |
import java.time.LocalDate;
|
60 |
import java.time.LocalDate;
|
| 61 |
import java.time.LocalDateTime;
|
61 |
import java.time.LocalDateTime;
|
| Line 153... |
Line 153... |
| 153 |
List<LeadStatus> status = Arrays.asList(LeadStatus.notInterested, LeadStatus.finalized);
|
153 |
List<LeadStatus> status = Arrays.asList(LeadStatus.notInterested, LeadStatus.finalized);
|
| 154 |
|
154 |
|
| 155 |
@RequestMapping(value = "/getOpenLead", method = RequestMethod.GET)
|
155 |
@RequestMapping(value = "/getOpenLead", method = RequestMethod.GET)
|
| 156 |
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 {
|
156 |
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 {
|
| 157 |
|
157 |
|
| 158 |
LocalDateTime localDateTime = null;
|
158 |
LocalDateTime leadCreatedDateTime = null;
|
| 159 |
if (leadDate != null) {
|
159 |
if (leadDate != null) {
|
| 160 |
localDateTime = leadDate.atStartOfDay();
|
160 |
leadCreatedDateTime = leadDate.atStartOfDay();
|
| 161 |
}
|
161 |
}
|
| 162 |
LOGGER.info("localDateTime" + localDateTime);
|
162 |
LOGGER.info("localDateTime" + leadCreatedDateTime);
|
| 163 |
|
163 |
|
| 164 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
164 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 165 |
String emailId = loginDetails.getEmailId();
|
165 |
String emailId = loginDetails.getEmailId();
|
| 166 |
AuthUser authUser = authRepository.selectByEmailOrMobile(emailId);
|
166 |
AuthUser authUser = authRepository.selectByEmailOrMobile(emailId);
|
| 167 |
|
167 |
|
| Line 194... |
Line 194... |
| 194 |
authUserIds.add(authUser.getId());
|
194 |
authUserIds.add(authUser.getId());
|
| 195 |
LOGGER.info("authIds" + authUserIds);
|
195 |
LOGGER.info("authIds" + authUserIds);
|
| 196 |
|
196 |
|
| 197 |
LOGGER.info("leadStatus" + leadStatus);
|
197 |
LOGGER.info("leadStatus" + leadStatus);
|
| 198 |
|
198 |
|
| 199 |
if (localDateTime == null) {
|
199 |
if (leadCreatedDateTime == null) {
|
| 200 |
|
200 |
|
| 201 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
201 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| 202 |
|
202 |
|
| 203 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds, color, LocalDateTime.now().minusMonths(1));
|
203 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds, color, LocalDateTime.now().minusMonths(1));
|
| 204 |
}
|
204 |
}
|
| Line 210... |
Line 210... |
| 210 |
|
210 |
|
| 211 |
} else {
|
211 |
} else {
|
| 212 |
|
212 |
|
| 213 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
213 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| 214 |
|
214 |
|
| 215 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds, color, localDateTime);
|
215 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestampAndAuthIds(leadStatus, authUserIds, color, leadCreatedDateTime);
|
| 216 |
}
|
216 |
}
|
| 217 |
|
217 |
|
| 218 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
218 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
| 219 |
|
219 |
|
| 220 |
leadFollowUp = leadRepository.selectByAssignAuthIdsAndStatus(authUserIds, LeadStatus.followUp);
|
220 |
leadFollowUp = leadRepository.selectByAssignAuthIdsAndStatus(authUserIds, LeadStatus.followUp);
|
| Line 225... |
Line 225... |
| 225 |
|
225 |
|
| 226 |
}
|
226 |
}
|
| 227 |
|
227 |
|
| 228 |
} else {
|
228 |
} else {
|
| 229 |
|
229 |
|
| 230 |
if (localDateTime == null) {
|
230 |
if (leadCreatedDateTime == null) {
|
| 231 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
231 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| 232 |
|
232 |
|
| 233 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestamp(leadStatus, color, LocalDateTime.now().minusMonths(1));
|
233 |
leads = leadRepository.selectAllByColorStatusAndUpdatedTimestamp(leadStatus, color, LocalDateTime.now().minusMonths(1));
|
| 234 |
}
|
234 |
}
|
| 235 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
235 |
if (leadStatus.contains(LeadStatus.followUp) || leadStatus.contains(LeadStatus.All)) {
|
| Line 241... |
Line 241... |
| 241 |
LOGGER.info("leadlocalDateTime1" + leads);
|
241 |
LOGGER.info("leadlocalDateTime1" + leads);
|
| 242 |
|
242 |
|
| 243 |
} else {
|
243 |
} else {
|
| 244 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
244 |
if (!leadStatus.contains(LeadStatus.followUp)) {
|
| 245 |
|
245 |
|
| - |
|
246 |
LocalDateTime today = LocalDate.now().atStartOfDay();
|
| - |
|
247 |
|
| - |
|
248 |
int twoYearsAgoYear = today.minusYears(2).getYear();
|
| - |
|
249 |
|
| - |
|
250 |
LocalDateTime endLocalDate;
|
| - |
|
251 |
|
| - |
|
252 |
if (leadCreatedDateTime.getYear() < twoYearsAgoYear) {
|
| - |
|
253 |
// End date = last day of created year (31 Dec 23:59:59)
|
| - |
|
254 |
endLocalDate = leadCreatedDateTime
|
| - |
|
255 |
.withMonth(12)
|
| - |
|
256 |
.withDayOfMonth(31)
|
| - |
|
257 |
.withHour(23)
|
| - |
|
258 |
.withMinute(59)
|
| - |
|
259 |
.withSecond(59);
|
| - |
|
260 |
} else {
|
| - |
|
261 |
// End date = today end of day
|
| - |
|
262 |
endLocalDate = today
|
| - |
|
263 |
.withHour(23)
|
| - |
|
264 |
.withMinute(59)
|
| - |
|
265 |
.withSecond(59);
|
| - |
|
266 |
}
|
| - |
|
267 |
|
| 246 |
leads = leadRepository.selectAllByColorStatusAndCreatedTimestamp(leadStatus, color, localDateTime);
|
268 |
// leads = leadRepository.selectAllByColorStatusAndCreatedTimestamp(leadStatus, color, leadCreatedDateTime);
|
| - |
|
269 |
leads = leadRepository.selectAllByColorStatusAndBetweenDate(leadStatus, color, leadCreatedDateTime, endLocalDate);
|
| 247 |
}
|
270 |
}
|
| 248 |
|
271 |
|
| 249 |
if (leadStatus.contains(LeadStatus.followUp)) {
|
272 |
if (leadStatus.contains(LeadStatus.followUp)) {
|
| 250 |
|
273 |
|
| 251 |
leadFollowUp = leadRepository.selectAllByStatus(LeadStatus.followUp);
|
274 |
leadFollowUp = leadRepository.selectAllByStatus(LeadStatus.followUp);
|