| Line 14... |
Line 14... |
| 14 |
import java.util.Set;
|
14 |
import java.util.Set;
|
| 15 |
import java.util.stream.Collectors;
|
15 |
import java.util.stream.Collectors;
|
| 16 |
|
16 |
|
| 17 |
import javax.servlet.http.HttpServletRequest;
|
17 |
import javax.servlet.http.HttpServletRequest;
|
| 18 |
|
18 |
|
| - |
|
19 |
import com.spice.profitmandi.common.enumuration.ActivationType;
|
| 19 |
import org.apache.commons.csv.CSVRecord;
|
20 |
import org.apache.commons.csv.CSVRecord;
|
| 20 |
import org.apache.logging.log4j.LogManager;
|
21 |
import org.apache.logging.log4j.LogManager;
|
| 21 |
import org.apache.logging.log4j.Logger;
|
22 |
import org.apache.logging.log4j.Logger;
|
| 22 |
import org.springframework.beans.factory.annotation.Autowired;
|
23 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23 |
import org.springframework.format.annotation.DateTimeFormat;
|
24 |
import org.springframework.format.annotation.DateTimeFormat;
|
| Line 113... |
Line 114... |
| 113 |
import io.swagger.annotations.ApiImplicitParams;
|
114 |
import io.swagger.annotations.ApiImplicitParams;
|
| 114 |
|
115 |
|
| 115 |
@Controller
|
116 |
@Controller
|
| 116 |
@Transactional(rollbackFor = Throwable.class)
|
117 |
@Transactional(rollbackFor = Throwable.class)
|
| 117 |
public class LeadController {
|
118 |
public class LeadController {
|
| 118 |
private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
|
119 |
private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
|
| 119 |
@Autowired
|
120 |
@Autowired
|
| 120 |
private ResponseSender<?> responseSender;
|
121 |
private ResponseSender<?> responseSender;
|
| 121 |
|
122 |
|
| 122 |
@Autowired
|
123 |
@Autowired
|
| 123 |
private AuthRepository authRepository;
|
124 |
private AuthRepository authRepository;
|
| 124 |
|
125 |
|
| 125 |
@Autowired
|
126 |
@Autowired
|
| 126 |
private LeadRepository leadRepository;
|
127 |
private LeadRepository leadRepository;
|
| 127 |
|
128 |
|
| 128 |
@Autowired
|
129 |
@Autowired
|
| 129 |
private CsService csService;
|
130 |
private CsService csService;
|
| 130 |
|
131 |
|
| 131 |
@Autowired
|
132 |
@Autowired
|
| 132 |
private UserRepository userRepository;
|
133 |
private UserRepository userRepository;
|
| 133 |
|
134 |
|
| 134 |
@Autowired
|
135 |
@Autowired
|
| 135 |
private UserAccountRepository userAccountRepository;
|
136 |
private UserAccountRepository userAccountRepository;
|
| 136 |
|
137 |
|
| 137 |
@Autowired
|
138 |
@Autowired
|
| 138 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
139 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
| 139 |
|
140 |
|
| 140 |
@Autowired
|
141 |
@Autowired
|
| 141 |
private RetailerService retailerService;
|
142 |
private RetailerService retailerService;
|
| 142 |
|
143 |
|
| 143 |
@Autowired
|
144 |
@Autowired
|
| 144 |
private LeadActivityRepository leadActivityRepository;
|
145 |
private LeadActivityRepository leadActivityRepository;
|
| 145 |
|
146 |
|
| 146 |
@Autowired
|
147 |
@Autowired
|
| 147 |
private FranchiseeVisitRepository franchiseeVisitRepository;
|
148 |
private FranchiseeVisitRepository franchiseeVisitRepository;
|
| 148 |
|
149 |
|
| 149 |
@Autowired
|
150 |
@Autowired
|
| 150 |
private FranchiseeActivityRepository franchiseeActivityRepository;
|
151 |
private FranchiseeActivityRepository franchiseeActivityRepository;
|
| 151 |
|
152 |
|
| 152 |
@Autowired
|
153 |
@Autowired
|
| 153 |
private PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
154 |
private PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
| 154 |
|
155 |
|
| 155 |
@Autowired
|
156 |
@Autowired
|
| 156 |
private FofoStoreRepository fofoStoreRepository;
|
157 |
private FofoStoreRepository fofoStoreRepository;
|
| 157 |
|
158 |
|
| 158 |
@Autowired
|
159 |
@Autowired
|
| 159 |
private StoreTimelineTatService storeTimelineTatService;
|
160 |
private StoreTimelineTatService storeTimelineTatService;
|
| 160 |
|
161 |
|
| 161 |
@Autowired
|
162 |
@Autowired
|
| 162 |
private PartnerCollectionService partnerCollectionService;
|
163 |
private PartnerCollectionService partnerCollectionService;
|
| 163 |
|
164 |
|
| 164 |
@Autowired
|
165 |
@Autowired
|
| 165 |
private TicketRepository ticketRepository;
|
166 |
private TicketRepository ticketRepository;
|
| 166 |
|
167 |
|
| 167 |
@Autowired
|
168 |
@Autowired
|
| 168 |
private TicketCategoryRepository ticketCategoryRepository;
|
169 |
private TicketCategoryRepository ticketCategoryRepository;
|
| 169 |
|
170 |
|
| 170 |
@Autowired
|
171 |
@Autowired
|
| 171 |
private TicketSubCategoryRepository ticketSubCategoryRepository;
|
172 |
private TicketSubCategoryRepository ticketSubCategoryRepository;
|
| 172 |
|
173 |
|
| 173 |
@Autowired
|
174 |
@Autowired
|
| 174 |
private PartnerCollectionRemarkRepository partnerCollectionRemarkRepository;
|
175 |
private PartnerCollectionRemarkRepository partnerCollectionRemarkRepository;
|
| 175 |
|
176 |
|
| 176 |
@Autowired
|
177 |
@Autowired
|
| 177 |
private Mongo mongoClient;
|
178 |
private Mongo mongoClient;
|
| 178 |
|
179 |
|
| 179 |
@Autowired
|
180 |
@Autowired
|
| 180 |
private OrderRepository orderRepository;
|
181 |
private OrderRepository orderRepository;
|
| 181 |
|
182 |
|
| 182 |
@Autowired
|
183 |
@Autowired
|
| 183 |
private PartnerCollectionPlanRepository partnerCollectionPlanRepository;
|
184 |
private PartnerCollectionPlanRepository partnerCollectionPlanRepository;
|
| 184 |
|
185 |
|
| 185 |
@Autowired
|
186 |
@Autowired
|
| 186 |
private PartnerSecondaryPlanRepository partnerSecondaryPlanRepository;
|
187 |
private PartnerSecondaryPlanRepository partnerSecondaryPlanRepository;
|
| 187 |
|
188 |
|
| 188 |
@Autowired
|
189 |
@Autowired
|
| 189 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
190 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 190 |
|
191 |
|
| 191 |
@Autowired
|
192 |
@Autowired
|
| 192 |
private AuthUserPartnerMappingRepository authUserPartnerMappingRepository;
|
193 |
private AuthUserPartnerMappingRepository authUserPartnerMappingRepository;
|
| 193 |
|
194 |
|
| 194 |
@Autowired
|
195 |
@Autowired
|
| 195 |
private VisitRequestRepository visitRequestRepository;
|
196 |
private VisitRequestRepository visitRequestRepository;
|
| 196 |
|
197 |
|
| 197 |
@Autowired
|
198 |
@Autowired
|
| 198 |
private AuthService authService;
|
199 |
private AuthService authService;
|
| 199 |
|
200 |
|
| 200 |
@Autowired
|
201 |
@Autowired
|
| 201 |
private NotificationService notificationService;
|
202 |
private NotificationService notificationService;
|
| 202 |
|
203 |
|
| 203 |
@RequestMapping(value = "/lead", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
204 |
@RequestMapping(value = "/lead", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 204 |
@ApiImplicitParams({
|
205 |
@ApiImplicitParams({
|
| 205 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
206 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 206 |
public ResponseEntity<?> LeadUser(HttpServletRequest request,
|
207 |
public ResponseEntity<?> LeadUser(HttpServletRequest request,
|
| 207 |
@RequestBody CreateRefferalRequest createRefferalRequest) throws Exception {
|
208 |
@RequestBody CreateRefferalRequest createRefferalRequest) throws Exception {
|
| 208 |
Lead lead = new Lead();
|
209 |
Lead lead = new Lead();
|
| 209 |
lead.setFirstName(createRefferalRequest.getFirstName());
|
210 |
lead.setFirstName(createRefferalRequest.getFirstName());
|
| 210 |
lead.setLastName(createRefferalRequest.getLastName());
|
211 |
lead.setLastName(createRefferalRequest.getLastName());
|
| 211 |
lead.setLeadMobile(createRefferalRequest.getMobile());
|
212 |
lead.setLeadMobile(createRefferalRequest.getMobile());
|
| 212 |
lead.setState(createRefferalRequest.getState());
|
213 |
lead.setState(createRefferalRequest.getState());
|
| 213 |
lead.setCity(createRefferalRequest.getCity());
|
214 |
lead.setCity(createRefferalRequest.getCity());
|
| 214 |
lead.setAddress(createRefferalRequest.getAddress());
|
215 |
lead.setAddress(createRefferalRequest.getAddress());
|
| 215 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
216 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
| 216 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
217 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
| 217 |
lead.setStatus(createRefferalRequest.getStatus());
|
218 |
lead.setStatus(createRefferalRequest.getStatus());
|
| 218 |
lead.setSource(createRefferalRequest.getSource());
|
219 |
lead.setSource(createRefferalRequest.getSource());
|
| 219 |
lead.setNotinterestedReason(createRefferalRequest.getReason());
|
220 |
lead.setNotinterestedReason(createRefferalRequest.getReason());
|
| 220 |
if (createRefferalRequest.getColorCheck() == true) {
|
221 |
if (createRefferalRequest.getColorCheck() == true) {
|
| 221 |
lead.setColor("Green");
|
222 |
lead.setColor("Green");
|
| 222 |
} else {
|
223 |
} else {
|
| 223 |
lead.setColor("Yellow");
|
224 |
lead.setColor("Yellow");
|
| 224 |
}
|
225 |
}
|
| 225 |
AuthUser authUser = authRepository.selectByGmailId(createRefferalRequest.getReffereeEmail());
|
226 |
AuthUser authUser = authRepository.selectByGmailId(createRefferalRequest.getReffereeEmail());
|
| 226 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
227 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
| 227 |
lead.setCreatedBy(authUserName);
|
228 |
lead.setCreatedBy(authUserName);
|
| 228 |
lead.setAuthId(authUser.getId());
|
229 |
lead.setAuthId(authUser.getId());
|
| 229 |
lead.setAssignTo(authUser.getId());
|
230 |
lead.setAssignTo(authUser.getId());
|
| 230 |
|
231 |
|
| 231 |
leadRepository.persist(lead);
|
232 |
leadRepository.persist(lead);
|
| 232 |
LeadActivity leadActivity = new LeadActivity();
|
233 |
LeadActivity leadActivity = new LeadActivity();
|
| 233 |
leadActivity.setLeadId(lead.getId());
|
234 |
leadActivity.setLeadId(lead.getId());
|
| 234 |
leadActivity.setRemark(createRefferalRequest.getRemark());
|
235 |
leadActivity.setRemark(createRefferalRequest.getRemark());
|
| 235 |
|
236 |
|
| 236 |
leadActivity.setAuthId(authUser.getId());
|
237 |
leadActivity.setAuthId(authUser.getId());
|
| 237 |
|
238 |
|
| 238 |
if (createRefferalRequest.getStatus().equals(LeadStatus.followUp)) {
|
239 |
if (createRefferalRequest.getStatus().equals(LeadStatus.followUp)) {
|
| 239 |
leadActivity.setSchelduleTimestamp(createRefferalRequest.getSchelduleTimestamp());
|
240 |
leadActivity.setSchelduleTimestamp(createRefferalRequest.getSchelduleTimestamp());
|
| 240 |
leadActivity.setCommunicationType(createRefferalRequest.getCommunicationType());
|
241 |
leadActivity.setCommunicationType(createRefferalRequest.getCommunicationType());
|
| 241 |
|
242 |
|
| 242 |
if (leadActivity.getCommunicationType().equals(CommunicationType.VISIT)) {
|
243 |
if (leadActivity.getCommunicationType().equals(CommunicationType.VISIT)) {
|
| 243 |
|
244 |
|
| 244 |
visitRequestRepository.createVisitRequest(lead.getId(), "lead", lead.getAssignTo(),
|
245 |
visitRequestRepository.createVisitRequest(lead.getId(), "lead", lead.getAssignTo(),
|
| 245 |
createRefferalRequest.getSchelduleTimestamp());
|
246 |
createRefferalRequest.getSchelduleTimestamp());
|
| 246 |
}
|
247 |
}
|
| 247 |
//
|
248 |
//
|
| 248 |
leadActivity.setClosureTimestamp(createRefferalRequest.getClosureTimestamp());
|
249 |
leadActivity.setClosureTimestamp(createRefferalRequest.getClosureTimestamp());
|
| 249 |
lead.setClosureTimestamp(createRefferalRequest.getClosureTimestamp());
|
250 |
lead.setClosureTimestamp(createRefferalRequest.getClosureTimestamp());
|
| 250 |
} else {
|
251 |
} else {
|
| 251 |
leadActivity.setSchelduleTimestamp(null);
|
252 |
leadActivity.setSchelduleTimestamp(null);
|
| 252 |
leadActivity.setClosureTimestamp(null);
|
253 |
leadActivity.setClosureTimestamp(null);
|
| 253 |
lead.setClosureTimestamp(null);
|
254 |
lead.setClosureTimestamp(null);
|
| 254 |
}
|
255 |
}
|
| 255 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
256 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
| 256 |
leadActivityRepository.persist(leadActivity);
|
257 |
leadActivityRepository.persist(leadActivity);
|
| 257 |
|
258 |
|
| 258 |
return responseSender.ok(true);
|
259 |
return responseSender.ok(true);
|
| 259 |
}
|
260 |
}
|
| 260 |
|
261 |
|
| 261 |
@RequestMapping(value = "/lead-description", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
262 |
@RequestMapping(value = "/lead-description", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 262 |
@ApiImplicitParams({
|
263 |
@ApiImplicitParams({
|
| 263 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
264 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 264 |
public ResponseEntity<?> leadDescription(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId,
|
265 |
public ResponseEntity<?> leadDescription(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId,
|
| 265 |
@RequestParam(name = "status") LeadStatus status) throws ProfitMandiBusinessException {
|
266 |
@RequestParam(name = "status") LeadStatus status) throws ProfitMandiBusinessException {
|
| 266 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
267 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
| 267 |
List<Lead> leads = null;
|
268 |
List<Lead> leads = null;
|
| 268 |
LOGGER.info("emails" + status);
|
269 |
LOGGER.info("emails" + status);
|
| 269 |
|
270 |
|
| 270 |
List<VisitRequest> visitRequests = visitRequestRepository.selectByAuthIdAndDate(authUser.getId(),
|
271 |
List<VisitRequest> visitRequests = visitRequestRepository.selectByAuthIdAndDate(authUser.getId(),
|
| 271 |
LocalDate.now());
|
272 |
LocalDate.now());
|
| 272 |
Map<Integer, List<VisitRequest>> visitRequestMap = null;
|
273 |
Map<Integer, List<VisitRequest>> visitRequestMap = null;
|
| 273 |
if (!visitRequests.isEmpty()) {
|
274 |
if (!visitRequests.isEmpty()) {
|
| 274 |
visitRequestMap = visitRequests.stream().collect(Collectors.groupingBy(x -> x.getVisitId()));
|
275 |
visitRequestMap = visitRequests.stream().collect(Collectors.groupingBy(x -> x.getVisitId()));
|
| 275 |
}
|
276 |
}
|
| 276 |
if (status.equals(LeadStatus.followUp)) {
|
277 |
if (status.equals(LeadStatus.followUp)) {
|
| 277 |
|
278 |
|
| 278 |
leads = leadRepository.selectLeadsScheduledBetweenDate(Arrays.asList(authUser.getId()), null, null);
|
279 |
leads = leadRepository.selectLeadsScheduledBetweenDate(Arrays.asList(authUser.getId()), null, null);
|
| 279 |
|
280 |
|
| 280 |
if (visitRequestMap != null) {
|
281 |
if (visitRequestMap != null) {
|
| 281 |
for (Lead lead : leads) {
|
282 |
for (Lead lead : leads) {
|
| 282 |
List<VisitRequest> visitRequest = visitRequestMap.get(lead.getId());
|
283 |
List<VisitRequest> visitRequest = visitRequestMap.get(lead.getId());
|
| 283 |
|
284 |
|
| 284 |
if (visitRequest != null) {
|
285 |
if (visitRequest != null) {
|
| 285 |
if (visitRequest.size() > 1) {
|
286 |
if (visitRequest.size() > 1) {
|
| 286 |
|
287 |
|
| 287 |
Comparator<VisitRequest> visitComparato = Comparator
|
288 |
Comparator<VisitRequest> visitComparato = Comparator
|
| 288 |
.comparing(VisitRequest::getCreatedTimestamp);
|
289 |
.comparing(VisitRequest::getCreatedTimestamp);
|
| 289 |
|
290 |
|
| 290 |
VisitRequest youngestVisit = visitRequest.stream().max(visitComparato).get();
|
291 |
VisitRequest youngestVisit = visitRequest.stream().max(visitComparato).get();
|
| 291 |
lead.setVisitStatus(youngestVisit.getStatus());
|
292 |
lead.setVisitStatus(youngestVisit.getStatus());
|
| 292 |
|
293 |
|
| 293 |
} else {
|
294 |
} else {
|
| 294 |
lead.setVisitStatus(visitRequest.get(0).getStatus());
|
295 |
lead.setVisitStatus(visitRequest.get(0).getStatus());
|
| 295 |
|
296 |
|
| 296 |
}
|
297 |
}
|
| 297 |
}
|
298 |
}
|
| 298 |
|
299 |
|
| 299 |
}
|
300 |
}
|
| 300 |
}
|
301 |
}
|
| 301 |
|
302 |
|
| 302 |
leads = leads.stream()
|
303 |
leads = leads.stream()
|
| 303 |
.sorted(Comparator.comparing(Lead::getScheduledTimestamp,
|
304 |
.sorted(Comparator.comparing(Lead::getScheduledTimestamp,
|
| 304 |
Comparator.nullsFirst(Comparator.reverseOrder())))
|
305 |
Comparator.nullsFirst(Comparator.reverseOrder())))
|
| 305 |
.collect(Collectors
|
306 |
.collect(Collectors
|
| 306 |
.toList());/*
|
307 |
.toList());/*
|
| 307 |
* Collections.sort(leads, (o1, o2) -> { if (o1.getScheduledTimestamp() != null
|
308 |
* Collections.sort(leads, (o1, o2) -> { if (o1.getScheduledTimestamp() != null
|
| 308 |
* && o2.getScheduledTimestamp() != null) { return
|
309 |
* && o2.getScheduledTimestamp() != null) { return
|
| 309 |
* o1.getScheduledTimestamp().isBefore(o2.getScheduledTimestamp()) ? -1 : 1; }
|
310 |
* o1.getScheduledTimestamp().isBefore(o2.getScheduledTimestamp()) ? -1 : 1; }
|
| 310 |
* else if (o1.getScheduledTimestamp() != null) { return 1; } else { return -1;
|
311 |
* else if (o1.getScheduledTimestamp() != null) { return 1; } else { return -1;
|
| 311 |
* } });
|
312 |
* } });
|
| 312 |
*/
|
313 |
*/
|
| 313 |
|
314 |
|
| 314 |
} else {
|
315 |
} else {
|
| 315 |
leads = leadRepository.selectByAssignAuthIdAndStatus(authUser.getId(), status);
|
316 |
leads = leadRepository.selectByAssignAuthIdAndStatus(authUser.getId(), status);
|
| 316 |
|
317 |
|
| 317 |
}
|
318 |
}
|
| 318 |
|
319 |
|
| 319 |
return responseSender.ok(leads);
|
320 |
return responseSender.ok(leads);
|
| 320 |
|
321 |
|
| 321 |
}
|
322 |
}
|
| 322 |
|
323 |
|
| 323 |
@RequestMapping(value = "/getlead", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
324 |
@RequestMapping(value = "/getlead", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 324 |
@ApiImplicitParams({
|
325 |
@ApiImplicitParams({
|
| 325 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
326 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 326 |
public ResponseEntity<?> getLead(HttpServletRequest request, @RequestParam(name = "id") int id)
|
327 |
public ResponseEntity<?> getLead(HttpServletRequest request, @RequestParam(name = "id") int id)
|
| 327 |
throws ProfitMandiBusinessException {
|
328 |
throws ProfitMandiBusinessException {
|
| 328 |
|
329 |
|
| 329 |
List<LeadActivity> leadActivities = leadActivityRepository.selectBYLeadId(id);
|
330 |
List<LeadActivity> leadActivities = leadActivityRepository.selectBYLeadId(id);
|
| 330 |
Lead lead = leadRepository.selectById(id);
|
331 |
Lead lead = leadRepository.selectById(id);
|
| 331 |
lead.setLeadActivities(leadActivities);
|
332 |
lead.setLeadActivities(leadActivities);
|
| 332 |
return responseSender.ok(lead);
|
333 |
return responseSender.ok(lead);
|
| 333 |
|
334 |
|
| 334 |
}
|
335 |
}
|
| 335 |
|
336 |
|
| 336 |
@RequestMapping(value = "/leadUpdate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
337 |
@RequestMapping(value = "/leadUpdate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 337 |
@ApiImplicitParams({
|
338 |
@ApiImplicitParams({
|
| 338 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
339 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 339 |
public ResponseEntity<?> leadUpdate(HttpServletRequest request, @RequestParam(name = "id") int id,
|
340 |
public ResponseEntity<?> leadUpdate(HttpServletRequest request, @RequestParam(name = "id") int id,
|
| 340 |
@RequestParam(name = "status") LeadStatus status, @RequestParam(name = "colorCheck") Boolean colorCheck,
|
341 |
@RequestParam(name = "status") LeadStatus status, @RequestParam(name = "colorCheck") Boolean colorCheck,
|
| 341 |
@RequestParam(name = "remark") String remark, @RequestParam(name = "reason") String reason,
|
342 |
@RequestParam(name = "remark") String remark, @RequestParam(name = "reason") String reason,
|
| 342 |
@RequestParam(name = "schelduleTimestamp") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime schelduleTimestamp,
|
343 |
@RequestParam(name = "schelduleTimestamp") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime schelduleTimestamp,
|
| 343 |
@RequestParam(name = "closureTimestamp") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime closureTimestamp,
|
344 |
@RequestParam(name = "closureTimestamp") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime closureTimestamp,
|
| 344 |
@RequestParam(name = "communicationType") CommunicationType communicationType)
|
345 |
@RequestParam(name = "communicationType") CommunicationType communicationType)
|
| 345 |
throws ProfitMandiBusinessException {
|
346 |
throws ProfitMandiBusinessException {
|
| 346 |
|
347 |
|
| 347 |
Lead lead = leadRepository.selectById(id);
|
348 |
Lead lead = leadRepository.selectById(id);
|
| 348 |
|
349 |
|
| 349 |
LeadActivity leadActivity = new LeadActivity();
|
350 |
LeadActivity leadActivity = new LeadActivity();
|
| 350 |
lead.setStatus(status);
|
351 |
lead.setStatus(status);
|
| 351 |
lead.setNotinterestedReason(reason);
|
352 |
lead.setNotinterestedReason(reason);
|
| 352 |
leadActivity.setRemark(remark);
|
353 |
leadActivity.setRemark(remark);
|
| 353 |
leadActivity.setLeadId(id);
|
354 |
leadActivity.setLeadId(id);
|
| 354 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
355 |
leadActivity.setCreatedTimestamp(LocalDateTime.now());
|
| 355 |
leadActivity.setSchelduleTimestamp(null);
|
356 |
leadActivity.setSchelduleTimestamp(null);
|
| 356 |
leadActivity.setClosureTimestamp(null);
|
357 |
leadActivity.setClosureTimestamp(null);
|
| 357 |
leadActivity.setAuthId(lead.getAssignTo());
|
358 |
leadActivity.setAuthId(lead.getAssignTo());
|
| 358 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
359 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
| 359 |
if (colorCheck == true) {
|
360 |
if (colorCheck == true) {
|
| 360 |
lead.setColor("Green");
|
361 |
lead.setColor("Green");
|
| 361 |
} else {
|
362 |
} else {
|
| 362 |
lead.setColor("Yellow");
|
363 |
lead.setColor("Yellow");
|
| 363 |
}
|
364 |
}
|
| 364 |
if (status == LeadStatus.followUp) {
|
365 |
if (status == LeadStatus.followUp) {
|
| 365 |
|
366 |
|
| 366 |
if (schelduleTimestamp != null) {
|
367 |
if (schelduleTimestamp != null) {
|
| 367 |
|
368 |
|
| 368 |
leadActivity.setCommunicationType(communicationType);
|
369 |
leadActivity.setCommunicationType(communicationType);
|
| 369 |
|
370 |
|
| 370 |
if (leadActivity.getCommunicationType().equals(CommunicationType.VISIT)) {
|
371 |
if (leadActivity.getCommunicationType().equals(CommunicationType.VISIT)) {
|
| 371 |
|
372 |
|
| 372 |
visitRequestRepository.createVisitRequest(lead.getId(), "lead", lead.getAssignTo(),
|
373 |
visitRequestRepository.createVisitRequest(lead.getId(), "lead", lead.getAssignTo(),
|
| 373 |
schelduleTimestamp);
|
374 |
schelduleTimestamp);
|
| 374 |
}
|
375 |
}
|
| 375 |
|
376 |
|
| 376 |
}
|
377 |
}
|
| 377 |
leadActivity.setSchelduleTimestamp(schelduleTimestamp);
|
378 |
leadActivity.setSchelduleTimestamp(schelduleTimestamp);
|
| 378 |
leadActivity.setClosureTimestamp(closureTimestamp);
|
379 |
leadActivity.setClosureTimestamp(closureTimestamp);
|
| 379 |
lead.setClosureTimestamp(closureTimestamp);
|
380 |
lead.setClosureTimestamp(closureTimestamp);
|
| 380 |
|
381 |
|
| 381 |
} else {
|
382 |
} else {
|
| 382 |
|
383 |
|
| 383 |
leadActivity.setSchelduleTimestamp(null);
|
384 |
leadActivity.setSchelduleTimestamp(null);
|
| 384 |
leadActivity.setClosureTimestamp(null);
|
385 |
leadActivity.setClosureTimestamp(null);
|
| 385 |
lead.setClosureTimestamp(null);
|
386 |
lead.setClosureTimestamp(null);
|
| 386 |
|
387 |
|
| 387 |
}
|
388 |
}
|
| 388 |
leadActivityRepository.persist(leadActivity);
|
389 |
leadActivityRepository.persist(leadActivity);
|
| 389 |
return responseSender.ok(true);
|
390 |
return responseSender.ok(true);
|
| 390 |
|
391 |
|
| 391 |
}
|
392 |
}
|
| 392 |
|
393 |
|
| 393 |
@RequestMapping(value = ProfitMandiConstants.URL_NEW_LEAD, method = RequestMethod.POST)
|
394 |
@RequestMapping(value = ProfitMandiConstants.URL_NEW_LEAD, method = RequestMethod.POST)
|
| 394 |
public ResponseEntity<?> newLead(HttpServletRequest request,
|
395 |
public ResponseEntity<?> newLead(HttpServletRequest request,
|
| 395 |
@RequestBody CreateRefferalRequest createRefferalRequest) throws ProfitMandiBusinessException {
|
396 |
@RequestBody CreateRefferalRequest createRefferalRequest) throws ProfitMandiBusinessException {
|
| 396 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
397 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 397 |
Lead lead = new Lead();
|
398 |
Lead lead = new Lead();
|
| 398 |
lead.setAddress(createRefferalRequest.getCity());
|
399 |
lead.setAddress(createRefferalRequest.getCity());
|
| 399 |
Long.parseLong(createRefferalRequest.getMobile());
|
400 |
Long.parseLong(createRefferalRequest.getMobile());
|
| 400 |
if (createRefferalRequest.getMobile().length() != 10) {
|
401 |
if (createRefferalRequest.getMobile().length() != 10) {
|
| 401 |
throw new ProfitMandiBusinessException("Mobile Number", createRefferalRequest.getMobile(),
|
402 |
throw new ProfitMandiBusinessException("Mobile Number", createRefferalRequest.getMobile(),
|
| 402 |
"Number should be of 10 digits");
|
403 |
"Number should be of 10 digits");
|
| 403 |
}
|
404 |
}
|
| 404 |
lead.setLeadMobile(createRefferalRequest.getMobile());
|
405 |
lead.setLeadMobile(createRefferalRequest.getMobile());
|
| 405 |
lead.setCity(createRefferalRequest.getCity());
|
406 |
lead.setCity(createRefferalRequest.getCity());
|
| 406 |
lead.setState(createRefferalRequest.getState());
|
407 |
lead.setState(createRefferalRequest.getState());
|
| 407 |
lead.setLastName(createRefferalRequest.getLastName());
|
408 |
lead.setLastName(createRefferalRequest.getLastName());
|
| 408 |
if (lead.getState().equals("Uttar Pradesh")) {
|
409 |
if (lead.getState().equals("Uttar Pradesh")) {
|
| 409 |
lead.setAssignTo(53);
|
410 |
lead.setAssignTo(53);
|
| 410 |
} else if (lead.getState().equals("Haryana")) {
|
411 |
} else if (lead.getState().equals("Haryana")) {
|
| 411 |
lead.setAssignTo(53);
|
412 |
lead.setAssignTo(53);
|
| 412 |
} else if (lead.getState().equals("Delhi")) {
|
413 |
} else if (lead.getState().equals("Delhi")) {
|
| 413 |
lead.setAssignTo(53);
|
414 |
lead.setAssignTo(53);
|
| 414 |
} else {
|
415 |
} else {
|
| 415 |
// Assign to sm
|
416 |
// Assign to sm
|
| 416 |
lead.setAssignTo(53);
|
417 |
lead.setAssignTo(53);
|
| 417 |
// Assign to neha
|
418 |
// Assign to neha
|
| 418 |
// lead.setAssignTo(1);
|
419 |
// lead.setAssignTo(1);
|
| 419 |
}
|
420 |
}
|
| 420 |
lead.setAuthId(lead.getAssignTo());
|
421 |
lead.setAuthId(lead.getAssignTo());
|
| 421 |
lead.setCreatedBy("daily-sync");
|
422 |
lead.setCreatedBy("daily-sync");
|
| 422 |
lead.setSource("SD-WEB");
|
423 |
lead.setSource("SD-WEB");
|
| 423 |
lead.setFirstName(createRefferalRequest.getFirstName());
|
424 |
lead.setFirstName(createRefferalRequest.getFirstName());
|
| 424 |
lead.setStatus(LeadStatus.followUp);
|
425 |
lead.setStatus(LeadStatus.followUp);
|
| 425 |
lead.setColor("yellow");
|
426 |
lead.setColor("yellow");
|
| 426 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
427 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
| 427 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
428 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
| 428 |
leadRepository.persist(lead);
|
429 |
leadRepository.persist(lead);
|
| 429 |
|
430 |
|
| 430 |
return responseSender.ok(true);
|
431 |
return responseSender.ok(true);
|
| 431 |
|
432 |
|
| 432 |
}
|
433 |
}
|
| 433 |
|
434 |
|
| 434 |
@RequestMapping(value = "/getPartnersList", method = RequestMethod.GET)
|
435 |
@RequestMapping(value = "/getPartnersList", method = RequestMethod.GET)
|
| 435 |
@ApiImplicitParams({
|
436 |
@ApiImplicitParams({
|
| 436 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
437 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 437 |
public ResponseEntity<?> getPartners(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId)
|
438 |
public ResponseEntity<?> getPartners(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId)
|
| 438 |
throws ProfitMandiBusinessException {
|
439 |
throws ProfitMandiBusinessException {
|
| 439 |
|
440 |
|
| 440 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
441 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
| 441 |
|
442 |
|
| 442 |
Map<String, Set<String>> storeGuyMap = csService.getAuthUserPartnerEmailMapping();
|
443 |
Map<String, Set<String>> storeGuyMap = csService.getAuthUserPartnerEmailMapping();
|
| 443 |
|
444 |
|
| 444 |
Set<String> emails = storeGuyMap.get(authUser.getEmailId());
|
445 |
Set<String> emails = storeGuyMap.get(authUser.getEmailId());
|
| 445 |
LOGGER.info("emails" + emails);
|
446 |
LOGGER.info("emails" + emails);
|
| 446 |
List<User> users = userRepository.selectAllByEmailIds(new ArrayList<>(emails));
|
447 |
List<User> users = userRepository.selectAllByEmailIds(new ArrayList<>(emails));
|
| 447 |
List<Partner> partners = new ArrayList<>();
|
448 |
List<Partner> partners = new ArrayList<>();
|
| 448 |
for (User user : users) {
|
449 |
for (User user : users) {
|
| 449 |
|
450 |
|
| 450 |
UserAccount uc = userAccountRepository.selectSaholicByUserId(user.getId());
|
451 |
UserAccount uc = userAccountRepository.selectSaholicByUserId(user.getId());
|
| 451 |
com.spice.profitmandi.dao.entity.user.User userInfo = userUserRepository.selectById(uc.getAccountKey());
|
452 |
com.spice.profitmandi.dao.entity.user.User userInfo = userUserRepository.selectById(uc.getAccountKey());
|
| 452 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(userInfo.getId());
|
453 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(userInfo.getId());
|
| 453 |
|
454 |
|
| 454 |
Partner partner = new Partner();
|
455 |
Partner partner = new Partner();
|
| 455 |
partner.setBusinessName(customRetailer.getBusinessName());
|
456 |
partner.setBusinessName(customRetailer.getBusinessName());
|
| 456 |
partner.setPartnerId(customRetailer.getPartnerId());
|
457 |
partner.setPartnerId(customRetailer.getPartnerId());
|
| 457 |
partner.setCartId(customRetailer.getCartId());
|
458 |
partner.setCartId(customRetailer.getCartId());
|
| 458 |
partner.setEmail(customRetailer.getEmail());
|
459 |
partner.setEmail(customRetailer.getEmail());
|
| 459 |
partner.setGstNumber(customRetailer.getGstNumber());
|
460 |
partner.setGstNumber(customRetailer.getGstNumber());
|
| 460 |
partner.setDisplayName(customRetailer.getDisplayName());
|
461 |
partner.setDisplayName(customRetailer.getDisplayName());
|
| 461 |
partner.setCity(customRetailer.getAddress().getCity());
|
462 |
partner.setCity(customRetailer.getAddress().getCity());
|
| 462 |
partner.setUserId(user.getId());
|
463 |
partner.setUserId(user.getId());
|
| 463 |
partners.add(partner);
|
464 |
partners.add(partner);
|
| 464 |
}
|
465 |
}
|
| 465 |
LOGGER.info("partners" + partners);
|
466 |
LOGGER.info("partners" + partners);
|
| 466 |
return responseSender.ok(partners);
|
467 |
return responseSender.ok(partners);
|
| 467 |
}
|
468 |
}
|
| 468 |
|
469 |
|
| 469 |
@RequestMapping(value = "/franchise-first-visit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
470 |
@RequestMapping(value = "/franchise-first-visit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 470 |
@ApiImplicitParams({
|
471 |
@ApiImplicitParams({
|
| 471 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
472 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 472 |
public ResponseEntity<?> FranchiseFirstVisit(HttpServletRequest request,
|
473 |
public ResponseEntity<?> FranchiseFirstVisit(HttpServletRequest request,
|
| 473 |
@RequestBody CreateFranchiseeRequest createFranchiseeRequest) throws Exception {
|
474 |
@RequestBody CreateFranchiseeRequest createFranchiseeRequest) throws Exception {
|
| 474 |
|
475 |
|
| 475 |
FranchiseeVisit franchiseeVisit = new FranchiseeVisit();
|
476 |
FranchiseeVisit franchiseeVisit = new FranchiseeVisit();
|
| 476 |
franchiseeVisit.setFofoId(createFranchiseeRequest.getFofoId());
|
477 |
franchiseeVisit.setFofoId(createFranchiseeRequest.getFofoId());
|
| 477 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(createFranchiseeRequest.getFofoId());
|
478 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(createFranchiseeRequest.getFofoId());
|
| 478 |
|
479 |
|
| 479 |
franchiseeVisit.setPartnerName(customRetailer.getBusinessName());
|
480 |
franchiseeVisit.setPartnerName(customRetailer.getBusinessName());
|
| 480 |
franchiseeVisit.setAgenda(createFranchiseeRequest.getAgenda());
|
481 |
franchiseeVisit.setAgenda(createFranchiseeRequest.getAgenda());
|
| 481 |
franchiseeVisit.setCreatedTimestamp(LocalDateTime.now());
|
482 |
franchiseeVisit.setCreatedTimestamp(LocalDateTime.now());
|
| 482 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
483 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
| 483 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.OPEN);
|
484 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.OPEN);
|
| 484 |
franchiseeVisit.setScheduleTimestamp(createFranchiseeRequest.getFirstSchelduleTimestamp());
|
485 |
franchiseeVisit.setScheduleTimestamp(createFranchiseeRequest.getFirstSchelduleTimestamp());
|
| 485 |
// change
|
486 |
// change
|
| 486 |
AuthUser authUser = authRepository.selectByGmailId(createFranchiseeRequest.getCreatedBy());
|
487 |
AuthUser authUser = authRepository.selectByGmailId(createFranchiseeRequest.getCreatedBy());
|
| 487 |
|
488 |
|
| 488 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
489 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
| 489 |
franchiseeVisit.setCreatedBy(authUserName);
|
490 |
franchiseeVisit.setCreatedBy(authUserName);
|
| 490 |
franchiseeVisit.setAuthId(authUser.getId());
|
491 |
franchiseeVisit.setAuthId(authUser.getId());
|
| 491 |
|
492 |
|
| 492 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
493 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
| 493 |
|
494 |
|
| 494 |
FranchiseeActivity franchiseeActivity = new FranchiseeActivity();
|
495 |
FranchiseeActivity franchiseeActivity = new FranchiseeActivity();
|
| 495 |
franchiseeActivity.setAction(FranchiseeActivityStatus.FOLLOWUP);
|
496 |
franchiseeActivity.setAction(FranchiseeActivityStatus.FOLLOWUP);
|
| 496 |
franchiseeActivity.setFranchiseeVisitd(franchiseeVisit.getId());
|
497 |
franchiseeActivity.setFranchiseeVisitd(franchiseeVisit.getId());
|
| 497 |
franchiseeActivity.setResolution(createFranchiseeRequest.getResolution());
|
498 |
franchiseeActivity.setResolution(createFranchiseeRequest.getResolution());
|
| 498 |
franchiseeActivity.setSchelduleTimestamp(createFranchiseeRequest.getFirstSchelduleTimestamp());
|
499 |
franchiseeActivity.setSchelduleTimestamp(createFranchiseeRequest.getFirstSchelduleTimestamp());
|
| 499 |
|
500 |
|
| 500 |
franchiseeActivity.setCreatedTimestamp(LocalDateTime.now());
|
501 |
franchiseeActivity.setCreatedTimestamp(LocalDateTime.now());
|
| 501 |
franchiseeActivityRepository.persist(franchiseeActivity);
|
502 |
franchiseeActivityRepository.persist(franchiseeActivity);
|
| 502 |
|
503 |
|
| 503 |
franchiseeVisit.setFranchiseActivityId(franchiseeActivity.getId());
|
504 |
franchiseeVisit.setFranchiseActivityId(franchiseeActivity.getId());
|
| 504 |
|
505 |
|
| 505 |
visitRequestRepository.createVisitRequest(franchiseeVisit.getId(), "franchiseeVisit", authUser.getId(),
|
506 |
visitRequestRepository.createVisitRequest(franchiseeVisit.getId(), "franchiseeVisit", authUser.getId(),
|
| 506 |
createFranchiseeRequest.getFirstSchelduleTimestamp());
|
507 |
createFranchiseeRequest.getFirstSchelduleTimestamp());
|
| 507 |
|
508 |
|
| 508 |
return responseSender.ok(true);
|
509 |
return responseSender.ok(true);
|
| 509 |
}
|
510 |
}
|
| 510 |
|
511 |
|
| 511 |
@RequestMapping(value = "/franchise-visit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
512 |
@RequestMapping(value = "/franchise-visit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 512 |
@ApiImplicitParams({
|
513 |
@ApiImplicitParams({
|
| 513 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
514 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 514 |
public ResponseEntity<?> FranchiseVisit(HttpServletRequest request,
|
515 |
public ResponseEntity<?> FranchiseVisit(HttpServletRequest request,
|
| 515 |
@RequestBody CreateFranchiseeRequest createFranchiseeRequest) throws Exception {
|
516 |
@RequestBody CreateFranchiseeRequest createFranchiseeRequest) throws Exception {
|
| 516 |
|
517 |
|
| 517 |
FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(createFranchiseeRequest.getId());
|
518 |
FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(createFranchiseeRequest.getId());
|
| 518 |
franchiseeVisit.setFofoId(createFranchiseeRequest.getFofoId());
|
519 |
franchiseeVisit.setFofoId(createFranchiseeRequest.getFofoId());
|
| 519 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(createFranchiseeRequest.getFofoId());
|
520 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(createFranchiseeRequest.getFofoId());
|
| 520 |
|
521 |
|
| 521 |
franchiseeVisit.setPartnerName(customRetailer.getBusinessName());
|
522 |
franchiseeVisit.setPartnerName(customRetailer.getBusinessName());
|
| 522 |
franchiseeVisit.setAgenda(createFranchiseeRequest.getAgenda());
|
523 |
franchiseeVisit.setAgenda(createFranchiseeRequest.getAgenda());
|
| 523 |
franchiseeVisit.setPartnerRemark(createFranchiseeRequest.getPartnerRemark());
|
524 |
franchiseeVisit.setPartnerRemark(createFranchiseeRequest.getPartnerRemark());
|
| 524 |
franchiseeVisit.setOutsideVisibity(createFranchiseeRequest.getOutsideVisibity());
|
525 |
franchiseeVisit.setOutsideVisibity(createFranchiseeRequest.getOutsideVisibity());
|
| 525 |
franchiseeVisit.setInstoreVisibility(createFranchiseeRequest.getInstoreVisibility());
|
526 |
franchiseeVisit.setInstoreVisibility(createFranchiseeRequest.getInstoreVisibility());
|
| 526 |
franchiseeVisit.setOutsideStock(createFranchiseeRequest.getOutsideStock());
|
527 |
franchiseeVisit.setOutsideStock(createFranchiseeRequest.getOutsideStock());
|
| 527 |
franchiseeVisit.setSystemKnowledge(createFranchiseeRequest.getSystemKnowledge());
|
528 |
franchiseeVisit.setSystemKnowledge(createFranchiseeRequest.getSystemKnowledge());
|
| 528 |
franchiseeVisit.setWorkingDevice(createFranchiseeRequest.getWorkingDevice());
|
529 |
franchiseeVisit.setWorkingDevice(createFranchiseeRequest.getWorkingDevice());
|
| 529 |
franchiseeVisit.setWorkingPrinter(createFranchiseeRequest.getWorkingPrinter());
|
530 |
franchiseeVisit.setWorkingPrinter(createFranchiseeRequest.getWorkingPrinter());
|
| 530 |
franchiseeVisit.setCarryBags(createFranchiseeRequest.getCarryBags());
|
531 |
franchiseeVisit.setCarryBags(createFranchiseeRequest.getCarryBags());
|
| 531 |
franchiseeVisit.setSmartdukaanTshirt(createFranchiseeRequest.getSmartdukaanTshirt());
|
532 |
franchiseeVisit.setSmartdukaanTshirt(createFranchiseeRequest.getSmartdukaanTshirt());
|
| 532 |
franchiseeVisit.setLatestDummies(createFranchiseeRequest.getLatestDummies());
|
533 |
franchiseeVisit.setLatestDummies(createFranchiseeRequest.getLatestDummies());
|
| 533 |
franchiseeVisit.setInvestment(createFranchiseeRequest.getInvestment());
|
534 |
franchiseeVisit.setInvestment(createFranchiseeRequest.getInvestment());
|
| 534 |
franchiseeVisit.setMtd(createFranchiseeRequest.getMtd());
|
535 |
franchiseeVisit.setMtd(createFranchiseeRequest.getMtd());
|
| 535 |
franchiseeVisit.setHygiene(createFranchiseeRequest.getHygiene());
|
536 |
franchiseeVisit.setHygiene(createFranchiseeRequest.getHygiene());
|
| 536 |
franchiseeVisit.setCreatedTimestamp(LocalDateTime.now());
|
537 |
franchiseeVisit.setCreatedTimestamp(LocalDateTime.now());
|
| 537 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
538 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
| 538 |
franchiseeVisit.setInformedAboutOnline(createFranchiseeRequest.getOnline());
|
539 |
franchiseeVisit.setInformedAboutOnline(createFranchiseeRequest.getOnline());
|
| 539 |
franchiseeVisit.setPendingBilling(createFranchiseeRequest.getPendingBilling());
|
540 |
franchiseeVisit.setPendingBilling(createFranchiseeRequest.getPendingBilling());
|
| 540 |
if (createFranchiseeRequest.getAction().equals(FranchiseeActivityStatus.FOLLOWUP)) {
|
541 |
if (createFranchiseeRequest.getAction().equals(FranchiseeActivityStatus.FOLLOWUP)) {
|
| 541 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.OPEN);
|
542 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.OPEN);
|
| 542 |
} else {
|
543 |
} else {
|
| 543 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.CLOSE);
|
544 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.CLOSE);
|
| 544 |
}
|
545 |
}
|
| 545 |
|
546 |
|
| 546 |
// AuthUser authUser =
|
547 |
// AuthUser authUser =
|
| 547 |
// authRepository.selectByGmailId(createFranchiseeRequest.getCreatedBy());
|
548 |
// authRepository.selectByGmailId(createFranchiseeRequest.getCreatedBy());
|
| 548 |
// change
|
549 |
// change
|
| 549 |
AuthUser authUser = authRepository.selectByGmailId(createFranchiseeRequest.getCreatedBy());
|
550 |
AuthUser authUser = authRepository.selectByGmailId(createFranchiseeRequest.getCreatedBy());
|
| 550 |
|
551 |
|
| 551 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
552 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
| 552 |
franchiseeVisit.setCreatedBy(authUserName);
|
553 |
franchiseeVisit.setCreatedBy(authUserName);
|
| 553 |
franchiseeVisit.setAuthId(authUser.getId());
|
554 |
franchiseeVisit.setAuthId(authUser.getId());
|
| 554 |
|
555 |
|
| 555 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
556 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
| 556 |
|
557 |
|
| 557 |
FranchiseeActivity franchiseeActivity = new FranchiseeActivity();
|
558 |
FranchiseeActivity franchiseeActivity = new FranchiseeActivity();
|
| 558 |
franchiseeActivity.setAction(createFranchiseeRequest.getAction());
|
559 |
franchiseeActivity.setAction(createFranchiseeRequest.getAction());
|
| 559 |
franchiseeActivity.setFranchiseeVisitd(franchiseeVisit.getId());
|
560 |
franchiseeActivity.setFranchiseeVisitd(franchiseeVisit.getId());
|
| 560 |
franchiseeActivity.setResolution(createFranchiseeRequest.getResolution());
|
561 |
franchiseeActivity.setResolution(createFranchiseeRequest.getResolution());
|
| 561 |
if (createFranchiseeRequest.getAction().equals(FranchiseeActivityStatus.FOLLOWUP)) {
|
562 |
if (createFranchiseeRequest.getAction().equals(FranchiseeActivityStatus.FOLLOWUP)) {
|
| 562 |
franchiseeActivity.setSchelduleTimestamp(createFranchiseeRequest.getSchelduleTimestamp());
|
563 |
franchiseeActivity.setSchelduleTimestamp(createFranchiseeRequest.getSchelduleTimestamp());
|
| 563 |
|
564 |
|
| 564 |
visitRequestRepository.createVisitRequest(franchiseeVisit.getId(), "franchiseeVisit",
|
565 |
visitRequestRepository.createVisitRequest(franchiseeVisit.getId(), "franchiseeVisit",
|
| 565 |
franchiseeVisit.getAuthId(), createFranchiseeRequest.getSchelduleTimestamp());
|
566 |
franchiseeVisit.getAuthId(), createFranchiseeRequest.getSchelduleTimestamp());
|
| 566 |
} else {
|
567 |
} else {
|
| 567 |
franchiseeActivity.setSchelduleTimestamp(null);
|
568 |
franchiseeActivity.setSchelduleTimestamp(null);
|
| 568 |
}
|
569 |
}
|
| 569 |
franchiseeActivity.setCreatedTimestamp(LocalDateTime.now());
|
570 |
franchiseeActivity.setCreatedTimestamp(LocalDateTime.now());
|
| 570 |
franchiseeActivityRepository.persist(franchiseeActivity);
|
571 |
franchiseeActivityRepository.persist(franchiseeActivity);
|
| 571 |
|
572 |
|
| 572 |
franchiseeVisit.setFranchiseActivityId(franchiseeActivity.getId());
|
573 |
franchiseeVisit.setFranchiseActivityId(franchiseeActivity.getId());
|
| 573 |
return responseSender.ok(true);
|
574 |
return responseSender.ok(true);
|
| 574 |
}
|
575 |
}
|
| 575 |
|
576 |
|
| 576 |
@RequestMapping(value = "/getFranchiseVisit", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
577 |
@RequestMapping(value = "/getFranchiseVisit", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 577 |
@ApiImplicitParams({
|
578 |
@ApiImplicitParams({
|
| 578 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
579 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 579 |
public ResponseEntity<?> getFranchiseVisit(HttpServletRequest request,
|
580 |
public ResponseEntity<?> getFranchiseVisit(HttpServletRequest request,
|
| 580 |
@RequestParam(name = "gmailId") String gmailId, @RequestParam(name = "status") FranchiseeVisitStatus status,
|
581 |
@RequestParam(name = "gmailId") String gmailId, @RequestParam(name = "status") FranchiseeVisitStatus status,
|
| 581 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
582 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 582 |
@RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
|
583 |
@RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
|
| 583 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
584 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
| 584 |
List<VisitRequest> visitRequests = visitRequestRepository.selectByAuthIdAndDate(authUser.getId(),
|
585 |
List<VisitRequest> visitRequests = visitRequestRepository.selectByAuthIdAndDate(authUser.getId(),
|
| 585 |
LocalDate.now());
|
586 |
LocalDate.now());
|
| 586 |
Map<Integer, List<VisitRequest>> visitRequestMap = null;
|
587 |
Map<Integer, List<VisitRequest>> visitRequestMap = null;
|
| 587 |
if (!visitRequests.isEmpty()) {
|
588 |
if (!visitRequests.isEmpty()) {
|
| 588 |
visitRequestMap = visitRequests.stream().collect(Collectors.groupingBy(x -> x.getVisitId()));
|
589 |
visitRequestMap = visitRequests.stream().collect(Collectors.groupingBy(x -> x.getVisitId()));
|
| 589 |
}
|
590 |
}
|
| 590 |
List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository.selectByAuthIdAndStatus(authUser.getId(),
|
591 |
List<FranchiseeVisit> franchiseeVisits = franchiseeVisitRepository.selectByAuthIdAndStatus(authUser.getId(),
|
| 591 |
status, offset, limit);
|
592 |
status, offset, limit);
|
| 592 |
|
593 |
|
| 593 |
for (FranchiseeVisit fv : franchiseeVisits) {
|
594 |
for (FranchiseeVisit fv : franchiseeVisits) {
|
| 594 |
if (visitRequestMap != null) {
|
595 |
if (visitRequestMap != null) {
|
| 595 |
|
596 |
|
| 596 |
List<VisitRequest> visitRequest = visitRequestMap.get(fv.getId());
|
597 |
List<VisitRequest> visitRequest = visitRequestMap.get(fv.getId());
|
| 597 |
if (visitRequest != null) {
|
598 |
if (visitRequest != null) {
|
| 598 |
if (visitRequest.size() > 1) {
|
599 |
if (visitRequest.size() > 1) {
|
| 599 |
|
600 |
|
| 600 |
Comparator<VisitRequest> visitComparato = Comparator
|
601 |
Comparator<VisitRequest> visitComparato = Comparator
|
| 601 |
.comparing(VisitRequest::getCreatedTimestamp);
|
602 |
.comparing(VisitRequest::getCreatedTimestamp);
|
| 602 |
|
603 |
|
| 603 |
VisitRequest youngestVisit = visitRequest.stream().max(visitComparato).get();
|
604 |
VisitRequest youngestVisit = visitRequest.stream().max(visitComparato).get();
|
| 604 |
fv.setVisitStatus(youngestVisit.getStatus());
|
605 |
fv.setVisitStatus(youngestVisit.getStatus());
|
| 605 |
|
606 |
|
| 606 |
} else {
|
607 |
} else {
|
| 607 |
fv.setVisitStatus(visitRequest.get(0).getStatus());
|
608 |
fv.setVisitStatus(visitRequest.get(0).getStatus());
|
| 608 |
|
609 |
|
| 609 |
}
|
610 |
}
|
| 610 |
}
|
611 |
}
|
| 611 |
}
|
612 |
}
|
| 612 |
if (fv.getFranchiseActivityId() != 0) {
|
613 |
if (fv.getFranchiseActivityId() != 0) {
|
| 613 |
FranchiseeActivity fA = franchiseeActivityRepository.selectById(fv.getFranchiseActivityId());
|
614 |
FranchiseeActivity fA = franchiseeActivityRepository.selectById(fv.getFranchiseActivityId());
|
| 614 |
fv.setFranchiseeActivity(fA);
|
615 |
fv.setFranchiseeActivity(fA);
|
| 615 |
}
|
616 |
}
|
| 616 |
|
617 |
|
| 617 |
}
|
618 |
}
|
| 618 |
|
619 |
|
| 619 |
return responseSender.ok(franchiseeVisits);
|
620 |
return responseSender.ok(franchiseeVisits);
|
| 620 |
|
621 |
|
| 621 |
}
|
622 |
}
|
| 622 |
|
623 |
|
| 623 |
@RequestMapping(value = "/getFranchiseActivity", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
624 |
@RequestMapping(value = "/getFranchiseActivity", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 624 |
@ApiImplicitParams({
|
625 |
@ApiImplicitParams({
|
| 625 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
626 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 626 |
public ResponseEntity<?> getFranchiseActivity(HttpServletRequest request, @RequestParam(name = "id") int id)
|
627 |
public ResponseEntity<?> getFranchiseActivity(HttpServletRequest request, @RequestParam(name = "id") int id)
|
| 627 |
throws ProfitMandiBusinessException {
|
628 |
throws ProfitMandiBusinessException {
|
| 628 |
|
629 |
|
| 629 |
List<FranchiseeActivity> franchiseeActivities = franchiseeActivityRepository.selectByFranchiseeVisitId(id);
|
630 |
List<FranchiseeActivity> franchiseeActivities = franchiseeActivityRepository.selectByFranchiseeVisitId(id);
|
| 630 |
return responseSender.ok(franchiseeActivities);
|
631 |
return responseSender.ok(franchiseeActivities);
|
| 631 |
|
632 |
|
| 632 |
}
|
633 |
}
|
| 633 |
|
634 |
|
| 634 |
@RequestMapping(value = "/getFranchiseeInfo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
635 |
@RequestMapping(value = "/getFranchiseeInfo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 635 |
@ApiImplicitParams({
|
636 |
@ApiImplicitParams({
|
| 636 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
637 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 637 |
public ResponseEntity<?> getFranchiseeInfo(HttpServletRequest request, @RequestParam(name = "id") int id)
|
638 |
public ResponseEntity<?> getFranchiseeInfo(HttpServletRequest request, @RequestParam(name = "id") int id)
|
| 638 |
throws ProfitMandiBusinessException {
|
639 |
throws ProfitMandiBusinessException {
|
| 639 |
FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(id);
|
640 |
FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(id);
|
| 640 |
|
641 |
|
| 641 |
List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
|
642 |
List<DBObject> mobileBrands = mongoClient.getAllBrandsToDisplay(3);
|
| 642 |
|
643 |
|
| 643 |
List<String> brands = mobileBrands.stream().filter(x -> (boolean) x.get("active"))
|
644 |
List<String> brands = mobileBrands.stream().filter(x -> (boolean) x.get("active"))
|
| 644 |
.map(x -> (String) x.get("name")).collect(Collectors.toList());
|
645 |
.map(x -> (String) x.get("name")).collect(Collectors.toList());
|
| 645 |
|
646 |
|
| 646 |
franchiseeVisit.setBrands(brands);
|
647 |
franchiseeVisit.setBrands(brands);
|
| 647 |
|
648 |
|
| 648 |
return responseSender.ok(franchiseeVisit);
|
649 |
return responseSender.ok(franchiseeVisit);
|
| 649 |
|
650 |
|
| 650 |
}
|
651 |
}
|
| 651 |
|
652 |
|
| 652 |
@RequestMapping(value = "/franchise-visit-update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
653 |
@RequestMapping(value = "/franchise-visit-update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 653 |
@ApiImplicitParams({
|
654 |
@ApiImplicitParams({
|
| 654 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
655 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 655 |
public ResponseEntity<?> franchiseVisitUpdate(HttpServletRequest request, @RequestParam(name = "id") int id,
|
656 |
public ResponseEntity<?> franchiseVisitUpdate(HttpServletRequest request, @RequestParam(name = "id") int id,
|
| 656 |
@RequestParam(name = "action") FranchiseeActivityStatus action,
|
657 |
@RequestParam(name = "action") FranchiseeActivityStatus action,
|
| 657 |
@RequestParam(name = "resolution") String resolution,
|
658 |
@RequestParam(name = "resolution") String resolution,
|
| 658 |
@RequestParam(name = "schelduleTimestamp") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime schelduleTimestamp)
|
659 |
@RequestParam(name = "schelduleTimestamp") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime schelduleTimestamp)
|
| 659 |
throws ProfitMandiBusinessException {
|
660 |
throws ProfitMandiBusinessException {
|
| 660 |
FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(id);
|
661 |
FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(id);
|
| 661 |
|
662 |
|
| 662 |
FranchiseeActivity franchiseeActivity = new FranchiseeActivity();
|
663 |
FranchiseeActivity franchiseeActivity = new FranchiseeActivity();
|
| 663 |
|
664 |
|
| 664 |
if (action == FranchiseeActivityStatus.FOLLOWUP) {
|
665 |
if (action == FranchiseeActivityStatus.FOLLOWUP) {
|
| 665 |
|
666 |
|
| 666 |
if (schelduleTimestamp != null) {
|
667 |
if (schelduleTimestamp != null) {
|
| 667 |
|
668 |
|
| 668 |
visitRequestRepository.createVisitRequest(franchiseeVisit.getId(), "franchiseeVisit",
|
669 |
visitRequestRepository.createVisitRequest(franchiseeVisit.getId(), "franchiseeVisit",
|
| 669 |
franchiseeVisit.getAuthId(), schelduleTimestamp);
|
670 |
franchiseeVisit.getAuthId(), schelduleTimestamp);
|
| 670 |
}
|
671 |
}
|
| 671 |
|
672 |
|
| 672 |
franchiseeActivity.setSchelduleTimestamp(schelduleTimestamp);
|
673 |
franchiseeActivity.setSchelduleTimestamp(schelduleTimestamp);
|
| 673 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.OPEN);
|
674 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.OPEN);
|
| 674 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
675 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
| 675 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
676 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
| 676 |
|
677 |
|
| 677 |
} else {
|
678 |
} else {
|
| 678 |
|
679 |
|
| 679 |
franchiseeActivity.setSchelduleTimestamp(null);
|
680 |
franchiseeActivity.setSchelduleTimestamp(null);
|
| 680 |
franchiseeVisit.setFranchiseActivityId(franchiseeActivity.getId());
|
681 |
franchiseeVisit.setFranchiseActivityId(franchiseeActivity.getId());
|
| 681 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.CLOSE);
|
682 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.CLOSE);
|
| 682 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
683 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
| 683 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
684 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
| 684 |
|
685 |
|
| 685 |
}
|
686 |
}
|
| 686 |
|
687 |
|
| 687 |
franchiseeActivity.setResolution(resolution);
|
688 |
franchiseeActivity.setResolution(resolution);
|
| 688 |
franchiseeActivity.setFranchiseeVisitd(franchiseeVisit.getId());
|
689 |
franchiseeActivity.setFranchiseeVisitd(franchiseeVisit.getId());
|
| 689 |
franchiseeActivity.setAction(action);
|
690 |
franchiseeActivity.setAction(action);
|
| 690 |
|
691 |
|
| 691 |
franchiseeActivity.setCreatedTimestamp(LocalDateTime.now());
|
692 |
franchiseeActivity.setCreatedTimestamp(LocalDateTime.now());
|
| 692 |
franchiseeActivityRepository.persist(franchiseeActivity);
|
693 |
franchiseeActivityRepository.persist(franchiseeActivity);
|
| 693 |
|
694 |
|
| 694 |
franchiseeVisit.setFranchiseActivityId(franchiseeActivity.getId());
|
695 |
franchiseeVisit.setFranchiseActivityId(franchiseeActivity.getId());
|
| 695 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.OPEN);
|
696 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.OPEN);
|
| 696 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
697 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
| 697 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
698 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
| 698 |
|
699 |
|
| 699 |
return responseSender.ok(true);
|
700 |
return responseSender.ok(true);
|
| 700 |
|
701 |
|
| 701 |
}
|
702 |
}
|
| 702 |
|
703 |
|
| 703 |
@RequestMapping(value = "/onBoardingTimelineStatus", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
704 |
@RequestMapping(value = "/onBoardingTimelineStatus", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 704 |
@ApiImplicitParams({
|
705 |
@ApiImplicitParams({
|
| 705 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
706 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 706 |
public ResponseEntity<?> onBoardingTimelineStatus(HttpServletRequest request, Model model)
|
707 |
public ResponseEntity<?> onBoardingTimelineStatus(HttpServletRequest request, Model model)
|
| 707 |
throws ProfitMandiBusinessException {
|
708 |
throws ProfitMandiBusinessException {
|
| 708 |
int userId = (int) request.getAttribute("userId");
|
709 |
int userId = (int) request.getAttribute("userId");
|
| 709 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
710 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
| 710 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(uc.getUserId());
|
711 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(uc.getUserId());
|
| 711 |
PartnerOnBoardingPanel partnerOnBoardingPanel = partnerOnBoardingPanelRepository.selectByCode(fs.getCode());
|
712 |
PartnerOnBoardingPanel partnerOnBoardingPanel = partnerOnBoardingPanelRepository.selectByCode(fs.getCode());
|
| 712 |
Map<StoreTimeline, OnBoardingTimelineModel> timelineStatus = null;
|
713 |
Map<StoreTimeline, OnBoardingTimelineModel> timelineStatus = null;
|
| 713 |
LOGGER.info("partnerOnBoardingPanel" + partnerOnBoardingPanel);
|
714 |
LOGGER.info("partnerOnBoardingPanel" + partnerOnBoardingPanel);
|
| 714 |
if (partnerOnBoardingPanel != null) {
|
715 |
if (partnerOnBoardingPanel != null) {
|
| 715 |
|
716 |
|
| 716 |
timelineStatus = storeTimelineTatService.getTimeline(partnerOnBoardingPanel.getId());
|
717 |
timelineStatus = storeTimelineTatService.getTimeline(partnerOnBoardingPanel.getId());
|
| 717 |
}
|
718 |
}
|
| 718 |
List<OnBoardingTimelineModel> onBoardingModel = new ArrayList<>();
|
719 |
List<OnBoardingTimelineModel> onBoardingModel = new ArrayList<>();
|
| 719 |
if (timelineStatus != null) {
|
720 |
if (timelineStatus != null) {
|
| 720 |
onBoardingModel = timelineStatus.values().stream().skip(2).map(x -> x).collect(Collectors.toList());
|
721 |
onBoardingModel = timelineStatus.values().stream().skip(2).map(x -> x).collect(Collectors.toList());
|
| 721 |
}
|
722 |
}
|
| 722 |
return responseSender.ok(onBoardingModel);
|
723 |
return responseSender.ok(onBoardingModel);
|
| 723 |
|
724 |
|
| 724 |
}
|
725 |
}
|
| 725 |
|
726 |
|
| 726 |
@RequestMapping(value = "/onBoardingTimelineVisibility", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
727 |
@RequestMapping(value = "/onBoardingTimelineVisibility", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 727 |
@ApiImplicitParams({
|
728 |
@ApiImplicitParams({
|
| 728 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
729 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 729 |
public ResponseEntity<?> onBoardingTimelineVisibility(HttpServletRequest request, Model model)
|
730 |
public ResponseEntity<?> onBoardingTimelineVisibility(HttpServletRequest request, Model model)
|
| 730 |
throws ProfitMandiBusinessException {
|
731 |
throws ProfitMandiBusinessException {
|
| 731 |
int userId = (int) request.getAttribute("userId");
|
732 |
int userId = (int) request.getAttribute("userId");
|
| 732 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
733 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
| 733 |
|
734 |
|
| 734 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(uc.getUserId());
|
735 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(uc.getUserId());
|
| 735 |
PartnerOnBoardingPanel partnerOnBoardingPanel = partnerOnBoardingPanelRepository.selectByCode(fs.getCode());
|
736 |
PartnerOnBoardingPanel partnerOnBoardingPanel = partnerOnBoardingPanelRepository.selectByCode(fs.getCode());
|
| 736 |
boolean status = true;
|
737 |
boolean status = true;
|
| 737 |
if (partnerOnBoardingPanel != null) {
|
738 |
if (partnerOnBoardingPanel != null) {
|
| 738 |
|
739 |
|
| 739 |
status = storeTimelineTatService.getTimelineCompleted(partnerOnBoardingPanel.getId());
|
740 |
status = storeTimelineTatService.getTimelineCompleted(partnerOnBoardingPanel.getId());
|
| 740 |
}
|
741 |
}
|
| 741 |
|
742 |
|
| 742 |
LOGGER.info("status" + status);
|
743 |
LOGGER.info("status" + status);
|
| 743 |
|
744 |
|
| 744 |
return responseSender.ok(status);
|
745 |
return responseSender.ok(status);
|
| 745 |
|
746 |
|
| 746 |
}
|
747 |
}
|
| 747 |
|
748 |
|
| 748 |
@RequestMapping(value = "/getPartnerTarget", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
749 |
@RequestMapping(value = "/getPartnerTarget", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 749 |
@ApiImplicitParams({
|
750 |
@ApiImplicitParams({
|
| 750 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
751 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 751 |
public ResponseEntity<?> getPartnerTarget(HttpServletRequest request,
|
752 |
public ResponseEntity<?> getPartnerTarget(HttpServletRequest request,
|
| 752 |
@RequestParam(name = "gmailId") String gmailId, @RequestParam String dayValue)
|
753 |
@RequestParam String gmailId, @RequestParam String dayValue, @RequestParam ActivationType activationType)
|
| 753 |
throws ProfitMandiBusinessException {
|
754 |
throws ProfitMandiBusinessException {
|
| 754 |
|
755 |
|
| 755 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
756 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
| 756 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
757 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 757 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
758 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
| 758 |
List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Itel", "Almost New", "Others");
|
759 |
List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Itel", "Almost New", "Others");
|
| 759 |
|
760 |
|
| 760 |
float totalPartnerTargetSecondary = 0;
|
761 |
float totalPartnerTargetSecondary = 0;
|
| 761 |
float totalPartnerTargetCollection = 0;
|
762 |
float totalPartnerTargetCollection = 0;
|
| 762 |
float totalPartnerAchievementSecondary = 0;
|
763 |
float totalPartnerAchievementSecondary = 0;
|
| 763 |
float totalPartnerAchievementCollection = 0;
|
764 |
float totalPartnerAchievementCollection = 0;
|
| 764 |
TargetModel tm = new TargetModel();
|
765 |
TargetModel tm = new TargetModel();
|
| 765 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
766 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
| 766 |
Map<Integer, Long> partnerTicketCount = ticketRepository.selectAllOpenTicketsGroupByRetailer();
|
767 |
Map<Integer, Long> partnerTicketCount = ticketRepository.selectAllOpenTicketsGroupByRetailer();
|
| 767 |
|
768 |
|
| 768 |
LOGGER.info("partnerTicketCount {}", partnerTicketCount);
|
769 |
LOGGER.info("partnerTicketCount {}", partnerTicketCount);
|
| 769 |
|
770 |
|
| 770 |
List<PartnerTargetAchievementModel> ptams = new ArrayList<>();
|
771 |
List<PartnerTargetAchievementModel> ptams = new ArrayList<>();
|
| 771 |
|
772 |
|
| 772 |
if (fofoIds != null && fofoIds.size() > 0) {
|
773 |
if (fofoIds != null && fofoIds.size() > 0) {
|
| 773 |
List<Integer> fofoIdl = new ArrayList<>(fofoIds);
|
774 |
List<Integer> fofoIdl = new ArrayList<>(fofoIds);
|
| 774 |
List<Integer> fofoIdList = fofoStoreRepository.selectByRetailerIds(fofoIdl).stream()
|
775 |
List<Integer> fofoIdList = fofoStoreRepository.selectByRetailerIds(fofoIdl).stream()
|
| 775 |
.filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toList());
|
776 |
.filter(x -> (!x.isInternal() && (activationType == null || x.getActivationType().equals(activationType))))
|
| 776 |
|
777 |
.map(x -> x.getId()).collect(Collectors.toList());
|
| 777 |
LocalDateTime startDate = LocalDate.now().atStartOfDay();
|
778 |
|
| 778 |
|
779 |
LocalDateTime startDate = LocalDate.now().atStartOfDay();
|
| 779 |
if (dayValue.equals("previous")) {
|
780 |
|
| 780 |
startDate = LocalDate.now().minusDays(1).atStartOfDay();
|
781 |
if (dayValue.equals("previous")) {
|
| 781 |
|
782 |
startDate = LocalDate.now().minusDays(1).atStartOfDay();
|
| 782 |
}
|
783 |
|
| 783 |
|
784 |
}
|
| 784 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
785 |
|
| 785 |
.selectAll(fofoIdList, startDate.toLocalDate().minusDays(1));
|
786 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
| 786 |
|
787 |
.selectAll(fofoIdList, startDate.toLocalDate().minusDays(1));
|
| 787 |
if (!partnerDailyInvestments.isEmpty()) {
|
788 |
|
| 788 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream()
|
789 |
if (!partnerDailyInvestments.isEmpty()) {
|
| 789 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
790 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream()
|
| 790 |
}
|
791 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 791 |
|
792 |
}
|
| 792 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
793 |
|
| 793 |
|
794 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 794 |
Map<Integer, CustomRetailer> customRetailers = fofoIdList.stream().map(x -> customRetailerMap.get(x))
|
795 |
|
| 795 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
796 |
Map<Integer, CustomRetailer> customRetailers = fofoIdList.stream().map(x -> customRetailerMap.get(x))
|
| 796 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
797 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
| 797 |
|
798 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 798 |
List<Integer> remarkIds = partnerCollectionRemarkRepository.selectMaxRemarkId(fofoIdList);
|
799 |
|
| 799 |
|
800 |
List<Integer> remarkIds = partnerCollectionRemarkRepository.selectMaxRemarkId(fofoIdList);
|
| 800 |
LOGGER.info("remarkIds {}", remarkIds);
|
801 |
|
| 801 |
|
802 |
LOGGER.info("remarkIds {}", remarkIds);
|
| 802 |
long todayCollectionCount = 0;
|
803 |
|
| 803 |
if (!remarkIds.isEmpty()) {
|
804 |
long todayCollectionCount = 0;
|
| 804 |
todayCollectionCount = partnerCollectionRemarkRepository
|
805 |
if (!remarkIds.isEmpty()) {
|
| 805 |
.selectByAuthIdAndIds(authUser.getId(), remarkIds).stream()
|
806 |
todayCollectionCount = partnerCollectionRemarkRepository
|
| 806 |
.filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now()))
|
807 |
.selectByAuthIdAndIds(authUser.getId(), remarkIds).stream()
|
| 807 |
.collect(Collectors.counting());
|
808 |
.filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now()))
|
| 808 |
|
809 |
.collect(Collectors.counting());
|
| 809 |
}
|
810 |
|
| 810 |
|
811 |
}
|
| 811 |
Map<Integer, PartnerCollectionPlanModel> CollectionMap = partnerCollectionService
|
812 |
|
| 812 |
.getCollectionMap(fofoIdList, startDate);
|
813 |
Map<Integer, PartnerCollectionPlanModel> CollectionMap = partnerCollectionService
|
| 813 |
|
814 |
.getCollectionMap(fofoIdList, startDate);
|
| 814 |
Map<Integer, List<PartnerSecondaryPlanModel>> partnerSecondayPlans = orderRepository
|
815 |
|
| 815 |
.selectPartnerSecondaryGroupByBrand(fofoIdList, startDate.toLocalDate()).stream()
|
816 |
Map<Integer, List<PartnerSecondaryPlanModel>> partnerSecondayPlans = orderRepository
|
| 816 |
.collect(Collectors.groupingBy(x -> x.getFofoId()));
|
817 |
.selectPartnerSecondaryGroupByBrand(fofoIdList, startDate.toLocalDate()).stream()
|
| 817 |
|
818 |
.collect(Collectors.groupingBy(x -> x.getFofoId()));
|
| 818 |
LOGGER.info("partnerSecondayPlans {}", partnerSecondayPlans);
|
819 |
|
| 819 |
for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailers.entrySet()) {
|
820 |
LOGGER.info("partnerSecondayPlans {}", partnerSecondayPlans);
|
| 820 |
int fofoId = customRetailerEntry.getKey();
|
821 |
for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailers.entrySet()) {
|
| 821 |
CustomRetailer customRetailer = customRetailerEntry.getValue();
|
822 |
int fofoId = customRetailerEntry.getKey();
|
| 822 |
float totalSecondaryPlan = 0;
|
823 |
CustomRetailer customRetailer = customRetailerEntry.getValue();
|
| 823 |
float totalSecondaryAchivement = 0;
|
824 |
float totalSecondaryPlan = 0;
|
| 824 |
|
825 |
float totalSecondaryAchivement = 0;
|
| 825 |
PartnerTargetAchievementModel ptam = new PartnerTargetAchievementModel();
|
826 |
|
| 826 |
ptam.setFofoId(fofoId);
|
827 |
PartnerTargetAchievementModel ptam = new PartnerTargetAchievementModel();
|
| 827 |
ptam.setBusinessName(customRetailer.getBusinessName());
|
828 |
ptam.setFofoId(fofoId);
|
| 828 |
ptam.setMobile(customRetailer.getMobileNumber());
|
829 |
ptam.setBusinessName(customRetailer.getBusinessName());
|
| 829 |
|
830 |
ptam.setMobile(customRetailer.getMobileNumber());
|
| 830 |
if (partnerDailyInvestmentMap.get(fofoId) != null) {
|
831 |
|
| 831 |
ptam.setWalletAmount(partnerDailyInvestmentMap.get(fofoId).getWalletAmount());
|
832 |
if (partnerDailyInvestmentMap.get(fofoId) != null) {
|
| 832 |
ptam.setShortInvestment(partnerDailyInvestmentMap.get(fofoId).getShortInvestment());
|
833 |
ptam.setWalletAmount(partnerDailyInvestmentMap.get(fofoId).getWalletAmount());
|
| 833 |
}
|
834 |
ptam.setShortInvestment(partnerDailyInvestmentMap.get(fofoId).getShortInvestment());
|
| 834 |
|
835 |
}
|
| 835 |
if (CollectionMap.get(fofoId) != null) {
|
836 |
|
| 836 |
PartnerCollectionPlanModel collectionPlan = CollectionMap.get(fofoId);
|
837 |
if (CollectionMap.get(fofoId) != null) {
|
| 837 |
|
838 |
PartnerCollectionPlanModel collectionPlan = CollectionMap.get(fofoId);
|
| 838 |
ptam.setRemark(collectionPlan.getRemark());
|
839 |
|
| 839 |
ptam.setMessage(collectionPlan.getMessage());
|
840 |
ptam.setRemark(collectionPlan.getRemark());
|
| 840 |
ptam.setRemarkTimestamp(collectionPlan.getRemarkTimestamp());
|
841 |
ptam.setMessage(collectionPlan.getMessage());
|
| 841 |
ptam.setRank(collectionPlan.getRank());
|
842 |
ptam.setRemarkTimestamp(collectionPlan.getRemarkTimestamp());
|
| 842 |
Integer authId = collectionPlan.getAuthId();
|
843 |
ptam.setRank(collectionPlan.getRank());
|
| 843 |
|
844 |
Integer authId = collectionPlan.getAuthId();
|
| 844 |
Map<Integer, String> rankColorMap = ProfitMandiConstants.Rank_Color_Map;
|
845 |
|
| 845 |
|
846 |
Map<Integer, String> rankColorMap = ProfitMandiConstants.Rank_Color_Map;
|
| 846 |
ptam.setCollectionColor(rankColorMap.get(collectionPlan.getRank()));
|
847 |
|
| 847 |
|
848 |
ptam.setCollectionColor(rankColorMap.get(collectionPlan.getRank()));
|
| 848 |
LOGGER.info("authId" + authId);
|
849 |
|
| 849 |
|
850 |
LOGGER.info("authId" + authId);
|
| 850 |
if (collectionPlan.getTargetPlan() != null && collectionPlan.getCommittedDate() != null) {
|
851 |
|
| 851 |
float targetCollection = 0;
|
852 |
if (collectionPlan.getTargetPlan() != null && collectionPlan.getCommittedDate() != null) {
|
| 852 |
|
853 |
float targetCollection = 0;
|
| 853 |
if (collectionPlan.getRank() == 2 && collectionPlan.getAchievementPlan() != null) {
|
854 |
|
| 854 |
targetCollection = collectionPlan.getTargetPlan() - collectionPlan.getAchievementPlan();
|
855 |
if (collectionPlan.getRank() == 2 && collectionPlan.getAchievementPlan() != null) {
|
| 855 |
} else {
|
856 |
targetCollection = collectionPlan.getTargetPlan() - collectionPlan.getAchievementPlan();
|
| 856 |
targetCollection = collectionPlan.getTargetPlan();
|
857 |
} else {
|
| 857 |
}
|
858 |
targetCollection = collectionPlan.getTargetPlan();
|
| 858 |
|
859 |
}
|
| 859 |
if (authId != null && authId == authUser.getId()) {
|
860 |
|
| 860 |
|
861 |
if (authId != null && authId == authUser.getId()) {
|
| 861 |
if (!collectionPlan.getCommittedDate().isAfter(startDate)) {
|
862 |
|
| 862 |
totalPartnerTargetCollection += targetCollection;
|
863 |
if (!collectionPlan.getCommittedDate().isAfter(startDate)) {
|
| 863 |
}
|
864 |
totalPartnerTargetCollection += targetCollection;
|
| 864 |
}
|
865 |
}
|
| 865 |
|
866 |
}
|
| 866 |
ptam.setCollectionTarget(targetCollection);
|
867 |
|
| 867 |
|
868 |
ptam.setCollectionTarget(targetCollection);
|
| 868 |
if (collectionPlan.getRank() == 2 && collectionPlan.getAchievementPlan() != null
|
869 |
|
| 869 |
&& collectionPlan.getWalletTimestamp() != null
|
870 |
if (collectionPlan.getRank() == 2 && collectionPlan.getAchievementPlan() != null
|
| 870 |
&& collectionPlan.getWalletTimestamp().toLocalDate().equals(startDate.toLocalDate())) {
|
871 |
&& collectionPlan.getWalletTimestamp() != null
|
| 871 |
if (authId != null && authId == authUser.getId()) {
|
872 |
&& collectionPlan.getWalletTimestamp().toLocalDate().equals(startDate.toLocalDate())) {
|
| 872 |
|
873 |
if (authId != null && authId == authUser.getId()) {
|
| 873 |
totalPartnerAchievementCollection += collectionPlan.getAchievementPlan();
|
874 |
|
| 874 |
}
|
875 |
totalPartnerAchievementCollection += collectionPlan.getAchievementPlan();
|
| 875 |
ptam.setCollectionAchievement(collectionPlan.getAchievementPlan());
|
876 |
}
|
| 876 |
} else if (collectionPlan.getCommittedDate().toLocalDate().isEqual(startDate.toLocalDate())
|
877 |
ptam.setCollectionAchievement(collectionPlan.getAchievementPlan());
|
| 877 |
&& collectionPlan.getAchievementPlan() != null) {
|
878 |
} else if (collectionPlan.getCommittedDate().toLocalDate().isEqual(startDate.toLocalDate())
|
| 878 |
if (authId != null && authId == authUser.getId()) {
|
879 |
&& collectionPlan.getAchievementPlan() != null) {
|
| 879 |
|
880 |
if (authId != null && authId == authUser.getId()) {
|
| 880 |
totalPartnerAchievementCollection += collectionPlan.getAchievementPlan();
|
881 |
|
| 881 |
}
|
882 |
totalPartnerAchievementCollection += collectionPlan.getAchievementPlan();
|
| 882 |
ptam.setCollectionAchievement(collectionPlan.getAchievementPlan());
|
883 |
}
|
| 883 |
|
884 |
ptam.setCollectionAchievement(collectionPlan.getAchievementPlan());
|
| 884 |
}
|
885 |
|
| 885 |
}
|
886 |
}
|
| 886 |
|
887 |
}
|
| 887 |
if (authId != null && authId != authUser.getId()) {
|
888 |
|
| 888 |
ptam.setAuthUser(authRepository.selectById(authId));
|
889 |
if (authId != null && authId != authUser.getId()) {
|
| 889 |
|
890 |
ptam.setAuthUser(authRepository.selectById(authId));
|
| 890 |
}
|
891 |
|
| 891 |
|
892 |
}
|
| 892 |
if (collectionPlan.getCommittedDate() != null) {
|
893 |
|
| 893 |
|
894 |
if (collectionPlan.getCommittedDate() != null) {
|
| 894 |
ptam.setCollectionCommitmentDate(collectionPlan.getCommittedDate().toLocalDate());
|
895 |
|
| 895 |
}
|
896 |
ptam.setCollectionCommitmentDate(collectionPlan.getCommittedDate().toLocalDate());
|
| 896 |
|
897 |
}
|
| 897 |
}
|
898 |
|
| 898 |
|
899 |
}
|
| 899 |
// Secondary
|
900 |
|
| 900 |
|
901 |
// Secondary
|
| 901 |
PartnerSecondaryPlanModel otherPartnerSecondaryPlanModel = null;
|
902 |
|
| 902 |
Map<String, PartnerSecondaryPlanModel> secondaryModelMap = new HashMap<>();
|
903 |
PartnerSecondaryPlanModel otherPartnerSecondaryPlanModel = null;
|
| 903 |
if (partnerSecondayPlans.get(fofoId) != null) {
|
904 |
Map<String, PartnerSecondaryPlanModel> secondaryModelMap = new HashMap<>();
|
| 904 |
long otherBrandSecondary = 0;
|
905 |
if (partnerSecondayPlans.get(fofoId) != null) {
|
| 905 |
for (PartnerSecondaryPlanModel pspm : partnerSecondayPlans.get(fofoId)) {
|
906 |
long otherBrandSecondary = 0;
|
| 906 |
Integer authId = pspm.getAuthId();
|
907 |
for (PartnerSecondaryPlanModel pspm : partnerSecondayPlans.get(fofoId)) {
|
| 907 |
if (!brands.contains(pspm.getBrand())) {
|
908 |
Integer authId = pspm.getAuthId();
|
| 908 |
if (pspm.getAchievementPlan() != null) {
|
909 |
if (!brands.contains(pspm.getBrand())) {
|
| 909 |
otherBrandSecondary += pspm.getAchievementPlan();
|
910 |
if (pspm.getAchievementPlan() != null) {
|
| 910 |
}
|
911 |
otherBrandSecondary += pspm.getAchievementPlan();
|
| 911 |
} else {
|
912 |
}
|
| 912 |
otherPartnerSecondaryPlanModel = pspm;
|
913 |
} else {
|
| 913 |
}
|
914 |
otherPartnerSecondaryPlanModel = pspm;
|
| 914 |
if (pspm.getTargetPlan() != null) {
|
915 |
}
|
| 915 |
totalSecondaryPlan += pspm.getTargetPlan();
|
916 |
if (pspm.getTargetPlan() != null) {
|
| 916 |
}
|
917 |
totalSecondaryPlan += pspm.getTargetPlan();
|
| 917 |
|
918 |
}
|
| 918 |
if (pspm.getAchievementPlan() != null) {
|
919 |
|
| 919 |
totalSecondaryAchivement += pspm.getAchievementPlan();
|
920 |
if (pspm.getAchievementPlan() != null) {
|
| 920 |
}
|
921 |
totalSecondaryAchivement += pspm.getAchievementPlan();
|
| 921 |
|
922 |
}
|
| 922 |
if (pspm.getCommittedDate() != null) {
|
923 |
|
| 923 |
|
924 |
if (pspm.getCommittedDate() != null) {
|
| 924 |
ptam.setSecondaryCommitmentDate(pspm.getCommittedDate().toLocalDate());
|
925 |
|
| 925 |
}
|
926 |
ptam.setSecondaryCommitmentDate(pspm.getCommittedDate().toLocalDate());
|
| 926 |
if (authId != null && authId == authUser.getId()) {
|
927 |
}
|
| 927 |
|
928 |
if (authId != null && authId == authUser.getId()) {
|
| 928 |
if (pspm.getTargetPlan() != null && pspm.getCommittedDate() != null) {
|
929 |
|
| 929 |
|
930 |
if (pspm.getTargetPlan() != null && pspm.getCommittedDate() != null) {
|
| 930 |
if (pspm.getCommittedDate().isEqual(startDate)) {
|
931 |
|
| 931 |
totalPartnerTargetSecondary += pspm.getTargetPlan();
|
932 |
if (pspm.getCommittedDate().isEqual(startDate)) {
|
| 932 |
}
|
933 |
totalPartnerTargetSecondary += pspm.getTargetPlan();
|
| 933 |
}
|
934 |
}
|
| 934 |
|
935 |
}
|
| 935 |
if (pspm.getAchievementPlan() != null) {
|
936 |
|
| 936 |
totalPartnerAchievementSecondary += pspm.getAchievementPlan();
|
937 |
if (pspm.getAchievementPlan() != null) {
|
| 937 |
}
|
938 |
totalPartnerAchievementSecondary += pspm.getAchievementPlan();
|
| 938 |
|
939 |
}
|
| 939 |
}
|
940 |
|
| 940 |
}
|
941 |
}
|
| 941 |
if (otherPartnerSecondaryPlanModel != null) {
|
942 |
}
|
| 942 |
otherPartnerSecondaryPlanModel.setAchievementPlan(otherBrandSecondary);
|
943 |
if (otherPartnerSecondaryPlanModel != null) {
|
| 943 |
}
|
944 |
otherPartnerSecondaryPlanModel.setAchievementPlan(otherBrandSecondary);
|
| 944 |
secondaryModelMap = partnerSecondayPlans.get(fofoId).stream()
|
945 |
}
|
| 945 |
.filter(x -> brands.contains(x.getBrand()))
|
946 |
secondaryModelMap = partnerSecondayPlans.get(fofoId).stream()
|
| 946 |
.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
|
947 |
.filter(x -> brands.contains(x.getBrand()))
|
| 947 |
|
948 |
.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
|
| 948 |
if (secondaryModelMap.containsKey("Others")) {
|
949 |
|
| 949 |
PartnerSecondaryPlanModel psp = secondaryModelMap.get("Others");
|
950 |
if (secondaryModelMap.containsKey("Others")) {
|
| 950 |
psp.setAchievementPlan(otherBrandSecondary);
|
951 |
PartnerSecondaryPlanModel psp = secondaryModelMap.get("Others");
|
| 951 |
} else {
|
952 |
psp.setAchievementPlan(otherBrandSecondary);
|
| 952 |
secondaryModelMap.put("Others", new PartnerSecondaryPlanModel(fofoId, "Others", (long) 0,
|
953 |
} else {
|
| 953 |
otherBrandSecondary, authUser.getId(), null));
|
954 |
secondaryModelMap.put("Others", new PartnerSecondaryPlanModel(fofoId, "Others", (long) 0,
|
| 954 |
}
|
955 |
otherBrandSecondary, authUser.getId(), null));
|
| 955 |
for (String brand : brands) {
|
956 |
}
|
| 956 |
if (!secondaryModelMap.containsKey(brand)) {
|
957 |
for (String brand : brands) {
|
| 957 |
secondaryModelMap.put(brand, new PartnerSecondaryPlanModel(fofoId, brand, (long) 0,
|
958 |
if (!secondaryModelMap.containsKey(brand)) {
|
| 958 |
(long) 0, authUser.getId(), null));
|
959 |
secondaryModelMap.put(brand, new PartnerSecondaryPlanModel(fofoId, brand, (long) 0,
|
| 959 |
}
|
960 |
(long) 0, authUser.getId(), null));
|
| 960 |
}
|
961 |
}
|
| 961 |
|
962 |
}
|
| 962 |
for (Entry<String, PartnerSecondaryPlanModel> secondaryModelEntry : secondaryModelMap.entrySet()) {
|
963 |
|
| 963 |
Integer authId = secondaryModelEntry.getValue().getAuthId();
|
964 |
for (Entry<String, PartnerSecondaryPlanModel> secondaryModelEntry : secondaryModelMap.entrySet()) {
|
| 964 |
if (authId != null && authId != authUser.getId()) {
|
965 |
Integer authId = secondaryModelEntry.getValue().getAuthId();
|
| 965 |
secondaryModelEntry.getValue().setAuthUser(authRepository.selectById(authId));
|
966 |
if (authId != null && authId != authUser.getId()) {
|
| 966 |
ptam.setSecondaryColor("red");
|
967 |
secondaryModelEntry.getValue().setAuthUser(authRepository.selectById(authId));
|
| 967 |
}
|
968 |
ptam.setSecondaryColor("red");
|
| 968 |
|
969 |
}
|
| 969 |
}
|
970 |
|
| 970 |
|
971 |
}
|
| 971 |
ptam.setPartnerSecondaryModel(secondaryModelMap);
|
972 |
|
| 972 |
ptam.setTotalSecondaryPlan(totalSecondaryPlan);
|
973 |
ptam.setPartnerSecondaryModel(secondaryModelMap);
|
| 973 |
ptam.setTotalSecondaryAchievement(totalSecondaryAchivement);
|
974 |
ptam.setTotalSecondaryPlan(totalSecondaryPlan);
|
| 974 |
// Secondary
|
975 |
ptam.setTotalSecondaryAchievement(totalSecondaryAchivement);
|
| 975 |
|
976 |
// Secondary
|
| 976 |
} else {
|
977 |
|
| 977 |
for (String brand : brands) {
|
978 |
} else {
|
| 978 |
PartnerSecondaryPlanModel pspm = new PartnerSecondaryPlanModel();
|
979 |
for (String brand : brands) {
|
| 979 |
pspm.setAchievementPlan((long) 0);
|
980 |
PartnerSecondaryPlanModel pspm = new PartnerSecondaryPlanModel();
|
| 980 |
pspm.setTargetPlan((long) 0);
|
981 |
pspm.setAchievementPlan((long) 0);
|
| 981 |
pspm.setBrand(brand);
|
982 |
pspm.setTargetPlan((long) 0);
|
| 982 |
pspm.setFofoId(fofoId);
|
983 |
pspm.setBrand(brand);
|
| 983 |
secondaryModelMap.put(brand, pspm);
|
984 |
pspm.setFofoId(fofoId);
|
| 984 |
}
|
985 |
secondaryModelMap.put(brand, pspm);
|
| 985 |
ptam.setPartnerSecondaryModel(secondaryModelMap);
|
986 |
}
|
| 986 |
}
|
987 |
ptam.setPartnerSecondaryModel(secondaryModelMap);
|
| 987 |
|
988 |
}
|
| 988 |
if (!partnerTicketCount.isEmpty()) {
|
989 |
|
| 989 |
if (partnerTicketCount.get(fofoId) != null) {
|
990 |
if (!partnerTicketCount.isEmpty()) {
|
| 990 |
ptam.setTicketCount(partnerTicketCount.get(fofoId));
|
991 |
if (partnerTicketCount.get(fofoId) != null) {
|
| 991 |
} else {
|
992 |
ptam.setTicketCount(partnerTicketCount.get(fofoId));
|
| 992 |
ptam.setTicketCount(0);
|
993 |
} else {
|
| 993 |
|
994 |
ptam.setTicketCount(0);
|
| 994 |
}
|
995 |
|
| 995 |
}
|
996 |
}
|
| 996 |
|
997 |
}
|
| 997 |
ptams.add(ptam);
|
998 |
|
| 998 |
|
999 |
ptams.add(ptam);
|
| 999 |
}
|
1000 |
|
| 1000 |
|
1001 |
}
|
| 1001 |
tm.setTotalPartnerTargetCollection(totalPartnerTargetCollection);
|
1002 |
|
| 1002 |
tm.setTotalPartnerTargetSecondary(totalPartnerTargetSecondary);
|
1003 |
tm.setTotalPartnerTargetCollection(totalPartnerTargetCollection);
|
| 1003 |
tm.setTotalPartnerSecondary(totalPartnerAchievementSecondary);
|
1004 |
tm.setTotalPartnerTargetSecondary(totalPartnerTargetSecondary);
|
| 1004 |
tm.setTotalPartnerCollection(totalPartnerAchievementCollection);
|
1005 |
tm.setTotalPartnerSecondary(totalPartnerAchievementSecondary);
|
| 1005 |
tm.setTodayCollectionCount((int) todayCollectionCount);
|
1006 |
tm.setTotalPartnerCollection(totalPartnerAchievementCollection);
|
| 1006 |
|
1007 |
tm.setTodayCollectionCount((int) todayCollectionCount);
|
| 1007 |
tm.setTargetAchievement(ptams.stream().sorted(Comparator.comparing(PartnerTargetAchievementModel::getRank))
|
1008 |
|
| 1008 |
.collect(Collectors.toList()));
|
1009 |
tm.setTargetAchievement(ptams.stream().sorted(Comparator.comparing(PartnerTargetAchievementModel::getRank))
|
| 1009 |
|
1010 |
.collect(Collectors.toList()));
|
| 1010 |
}
|
1011 |
|
| 1011 |
|
1012 |
}
|
| 1012 |
return responseSender.ok(tm);
|
1013 |
|
| 1013 |
|
1014 |
return responseSender.ok(tm);
|
| 1014 |
}
|
1015 |
|
| 1015 |
|
1016 |
}
|
| 1016 |
@RequestMapping(value = "/target", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
1017 |
|
| 1017 |
@ApiImplicitParams({
|
1018 |
@RequestMapping(value = "/target", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1018 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
1019 |
@ApiImplicitParams({
|
| 1019 |
public ResponseEntity<?> createPartnerTarget(HttpServletRequest request,
|
1020 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 1020 |
@RequestBody PartnerTargetAchievementModel ptam) throws ProfitMandiBusinessException {
|
1021 |
public ResponseEntity<?> createPartnerTarget(HttpServletRequest request,
|
| 1021 |
|
1022 |
@RequestBody PartnerTargetAchievementModel ptam) throws ProfitMandiBusinessException {
|
| 1022 |
LOGGER.info("ptam" + ptam);
|
1023 |
|
| 1023 |
|
1024 |
LOGGER.info("ptam" + ptam);
|
| 1024 |
AuthUser authUser = authRepository.selectByGmailId(ptam.getCreatedBy());
|
1025 |
|
| 1025 |
|
1026 |
AuthUser authUser = authRepository.selectByGmailId(ptam.getCreatedBy());
|
| 1026 |
if (ptam.getCollectionCommitmentDate().isAfter(LocalDate.now())
|
1027 |
|
| 1027 |
|| ptam.getCollectionCommitmentDate().isEqual(LocalDate.now())) {
|
1028 |
if (ptam.getCollectionCommitmentDate().isAfter(LocalDate.now())
|
| 1028 |
PartnerCollectionPlan partnerCollectionPlan = partnerCollectionPlanRepository
|
1029 |
|| ptam.getCollectionCommitmentDate().isEqual(LocalDate.now())) {
|
| 1029 |
.selectByLocalDate(LocalDate.now(), ptam.getFofoId(), true);
|
1030 |
PartnerCollectionPlan partnerCollectionPlan = partnerCollectionPlanRepository
|
| 1030 |
LOGGER.info("pcp" + partnerCollectionPlan);
|
1031 |
.selectByLocalDate(LocalDate.now(), ptam.getFofoId(), true);
|
| 1031 |
|
1032 |
LOGGER.info("pcp" + partnerCollectionPlan);
|
| 1032 |
if (partnerCollectionPlan == null) {
|
1033 |
|
| 1033 |
if (ptam.getCollectionTarget() > 0) {
|
1034 |
if (partnerCollectionPlan == null) {
|
| 1034 |
|
1035 |
if (ptam.getCollectionTarget() > 0) {
|
| 1035 |
partnerCollectionPlan = new PartnerCollectionPlan();
|
1036 |
|
| 1036 |
partnerCollectionPlan.setCreateTimestamp(LocalDateTime.now());
|
1037 |
partnerCollectionPlan = new PartnerCollectionPlan();
|
| 1037 |
partnerCollectionPlan.setAuthId(authUser.getId());
|
1038 |
partnerCollectionPlan.setCreateTimestamp(LocalDateTime.now());
|
| 1038 |
partnerCollectionPlan.setFofoId(ptam.getFofoId());
|
1039 |
partnerCollectionPlan.setAuthId(authUser.getId());
|
| 1039 |
partnerCollectionPlan.setActive(true);
|
1040 |
partnerCollectionPlan.setFofoId(ptam.getFofoId());
|
| 1040 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
1041 |
partnerCollectionPlan.setActive(true);
|
| 1041 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
1042 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
| 1042 |
partnerCollectionPlan.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
|
1043 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
| 1043 |
partnerCollectionPlanRepository.persist(partnerCollectionPlan);
|
1044 |
partnerCollectionPlan.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
|
| 1044 |
|
1045 |
partnerCollectionPlanRepository.persist(partnerCollectionPlan);
|
| 1045 |
}
|
1046 |
|
| 1046 |
|
1047 |
}
|
| 1047 |
} else {
|
1048 |
|
| 1048 |
|
1049 |
} else {
|
| 1049 |
if (partnerCollectionPlan.getCollectionPlan() != ptam.getCollectionTarget()) {
|
1050 |
|
| 1050 |
float totalCollectionPlan = partnerCollectionPlan.getCollectionPlan() + 10000;
|
1051 |
if (partnerCollectionPlan.getCollectionPlan() != ptam.getCollectionTarget()) {
|
| 1051 |
if (authUser.getId() == partnerCollectionPlan.getAuthId()) {
|
1052 |
float totalCollectionPlan = partnerCollectionPlan.getCollectionPlan() + 10000;
|
| 1052 |
|
1053 |
if (authUser.getId() == partnerCollectionPlan.getAuthId()) {
|
| 1053 |
if (authUser.getEmailId().equals("tarun.verma@smartdukaan.com")
|
1054 |
|
| 1054 |
|| authUser.getEmailId().equals("rakesh.sonawane@smartdukaan.com")
|
1055 |
if (authUser.getEmailId().equals("tarun.verma@smartdukaan.com")
|
| 1055 |
|| ptam.getCollectionTarget() >= totalCollectionPlan) {
|
1056 |
|| authUser.getEmailId().equals("rakesh.sonawane@smartdukaan.com")
|
| 1056 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
1057 |
|| ptam.getCollectionTarget() >= totalCollectionPlan) {
|
| 1057 |
partnerCollectionPlan.setActive(true);
|
1058 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
| 1058 |
partnerCollectionPlan
|
1059 |
partnerCollectionPlan.setActive(true);
|
| 1059 |
.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
|
1060 |
partnerCollectionPlan
|
| 1060 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
1061 |
.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
|
| 1061 |
} else {
|
1062 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
| 1062 |
throw new ProfitMandiBusinessException("collection target", "",
|
1063 |
} else {
|
| 1063 |
"collection target should be more than " + totalCollectionPlan);
|
1064 |
throw new ProfitMandiBusinessException("collection target", "",
|
| 1064 |
}
|
1065 |
"collection target should be more than " + totalCollectionPlan);
|
| 1065 |
|
1066 |
}
|
| 1066 |
} else {
|
1067 |
|
| 1067 |
|
1068 |
} else {
|
| 1068 |
if (authUser.getEmailId().equals("tarun.verma@smartdukaan.com")
|
1069 |
|
| 1069 |
|| authUser.getEmailId().equals("rakesh.sonawane@smartdukaan.com")
|
1070 |
if (authUser.getEmailId().equals("tarun.verma@smartdukaan.com")
|
| 1070 |
|| ptam.getCollectionTarget() >= totalCollectionPlan) {
|
1071 |
|| authUser.getEmailId().equals("rakesh.sonawane@smartdukaan.com")
|
| 1071 |
|
1072 |
|| ptam.getCollectionTarget() >= totalCollectionPlan) {
|
| 1072 |
partnerCollectionPlan.setActive(false);
|
1073 |
|
| 1073 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
1074 |
partnerCollectionPlan.setActive(false);
|
| 1074 |
partnerCollectionPlan = new PartnerCollectionPlan();
|
1075 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
| 1075 |
partnerCollectionPlan.setCreateTimestamp(LocalDateTime.now());
|
1076 |
partnerCollectionPlan = new PartnerCollectionPlan();
|
| 1076 |
partnerCollectionPlan.setAuthId(authUser.getId());
|
1077 |
partnerCollectionPlan.setCreateTimestamp(LocalDateTime.now());
|
| 1077 |
partnerCollectionPlan.setFofoId(ptam.getFofoId());
|
1078 |
partnerCollectionPlan.setAuthId(authUser.getId());
|
| 1078 |
partnerCollectionPlan.setActive(true);
|
1079 |
partnerCollectionPlan.setFofoId(ptam.getFofoId());
|
| 1079 |
partnerCollectionPlan
|
1080 |
partnerCollectionPlan.setActive(true);
|
| 1080 |
.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
1081 |
partnerCollectionPlan
|
| 1081 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
1082 |
.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
| 1082 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
1083 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
| 1083 |
partnerCollectionPlanRepository.persist(partnerCollectionPlan);
|
1084 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
| 1084 |
} else {
|
1085 |
partnerCollectionPlanRepository.persist(partnerCollectionPlan);
|
| 1085 |
throw new ProfitMandiBusinessException("collection target", "",
|
1086 |
} else {
|
| 1086 |
"collection target should be more than " + totalCollectionPlan);
|
1087 |
throw new ProfitMandiBusinessException("collection target", "",
|
| 1087 |
}
|
1088 |
"collection target should be more than " + totalCollectionPlan);
|
| 1088 |
}
|
1089 |
}
|
| 1089 |
}
|
1090 |
}
|
| 1090 |
|
1091 |
}
|
| 1091 |
if ((LocalDate.now().atStartOfDay().equals(ptam.getCollectionCommitmentDate().atStartOfDay())
|
1092 |
|
| 1092 |
|| ptam.getCollectionCommitmentDate().atStartOfDay().isAfter(LocalDate.now().atStartOfDay()))
|
1093 |
if ((LocalDate.now().atStartOfDay().equals(ptam.getCollectionCommitmentDate().atStartOfDay())
|
| 1093 |
&& partnerCollectionPlan.getCollectionPlan() == ptam.getCollectionTarget()) {
|
1094 |
|| ptam.getCollectionCommitmentDate().atStartOfDay().isAfter(LocalDate.now().atStartOfDay()))
|
| 1094 |
partnerCollectionPlan.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
|
1095 |
&& partnerCollectionPlan.getCollectionPlan() == ptam.getCollectionTarget()) {
|
| 1095 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
1096 |
partnerCollectionPlan.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
|
| 1096 |
}
|
1097 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
| 1097 |
|
1098 |
}
|
| 1098 |
}
|
1099 |
|
| 1099 |
|
1100 |
}
|
| 1100 |
PartnerCollectionRemark pcr = new PartnerCollectionRemark();
|
1101 |
|
| 1101 |
pcr.setFofoId(ptam.getFofoId());
|
1102 |
PartnerCollectionRemark pcr = new PartnerCollectionRemark();
|
| 1102 |
pcr.setAuthId(authUser.getId());
|
1103 |
pcr.setFofoId(ptam.getFofoId());
|
| 1103 |
pcr.setMessage("Collection plan for" + ptam.getCollectionCommitmentDate());
|
1104 |
pcr.setAuthId(authUser.getId());
|
| 1104 |
pcr.setRemark(CollectionRemark.COLLECTION_PLAN);
|
1105 |
pcr.setMessage("Collection plan for" + ptam.getCollectionCommitmentDate());
|
| 1105 |
pcr.setCreateTimestamp(LocalDateTime.now());
|
1106 |
pcr.setRemark(CollectionRemark.COLLECTION_PLAN);
|
| 1106 |
partnerCollectionRemarkRepository.persist(pcr);
|
1107 |
pcr.setCreateTimestamp(LocalDateTime.now());
|
| 1107 |
} else {
|
1108 |
partnerCollectionRemarkRepository.persist(pcr);
|
| 1108 |
throw new ProfitMandiBusinessException("Date", "",
|
1109 |
} else {
|
| 1109 |
"you can't select the back date " + ptam.getCollectionCommitmentDate());
|
1110 |
throw new ProfitMandiBusinessException("Date", "",
|
| 1110 |
}
|
1111 |
"you can't select the back date " + ptam.getCollectionCommitmentDate());
|
| 1111 |
|
1112 |
}
|
| 1112 |
for (Entry<String, PartnerSecondaryPlanModel> pspm : ptam.getPartnerSecondaryModel().entrySet()) {
|
1113 |
|
| 1113 |
|
1114 |
for (Entry<String, PartnerSecondaryPlanModel> pspm : ptam.getPartnerSecondaryModel().entrySet()) {
|
| 1114 |
if (ptam.getCollectionCommitmentDate().isAfter(LocalDate.now())
|
1115 |
|
| 1115 |
|| ptam.getCollectionCommitmentDate().isEqual(LocalDate.now())) {
|
1116 |
if (ptam.getCollectionCommitmentDate().isAfter(LocalDate.now())
|
| 1116 |
PartnerSecondaryPlanModel plan = pspm.getValue();
|
1117 |
|| ptam.getCollectionCommitmentDate().isEqual(LocalDate.now())) {
|
| 1117 |
PartnerSecondaryPlan psp = partnerSecondaryPlanRepository.selectByLocalDateBrand(plan.getBrand(),
|
1118 |
PartnerSecondaryPlanModel plan = pspm.getValue();
|
| 1118 |
LocalDate.now(), ptam.getFofoId(), true);
|
1119 |
PartnerSecondaryPlan psp = partnerSecondaryPlanRepository.selectByLocalDateBrand(plan.getBrand(),
|
| 1119 |
LOGGER.info("psp" + psp);
|
1120 |
LocalDate.now(), ptam.getFofoId(), true);
|
| 1120 |
|
1121 |
LOGGER.info("psp" + psp);
|
| 1121 |
if (psp == null) {
|
1122 |
|
| 1122 |
if (plan.getTargetPlan() != null && plan.getTargetPlan() > 0) {
|
1123 |
if (psp == null) {
|
| 1123 |
|
1124 |
if (plan.getTargetPlan() != null && plan.getTargetPlan() > 0) {
|
| 1124 |
psp = new PartnerSecondaryPlan();
|
1125 |
|
| 1125 |
psp.setAuthId(authUser.getId());
|
1126 |
psp = new PartnerSecondaryPlan();
|
| 1126 |
psp.setBrand(pspm.getKey());
|
1127 |
psp.setAuthId(authUser.getId());
|
| 1127 |
psp.setFofoId(pspm.getValue().getFofoId());
|
1128 |
psp.setBrand(pspm.getKey());
|
| 1128 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
1129 |
psp.setFofoId(pspm.getValue().getFofoId());
|
| 1129 |
psp.setCreateTimestamp(LocalDateTime.now());
|
1130 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
| 1130 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
1131 |
psp.setCreateTimestamp(LocalDateTime.now());
|
| 1131 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
1132 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
| 1132 |
psp.setActive(true);
|
1133 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
| 1133 |
partnerSecondaryPlanRepository.persist(psp);
|
1134 |
psp.setActive(true);
|
| 1134 |
}
|
1135 |
partnerSecondaryPlanRepository.persist(psp);
|
| 1135 |
|
1136 |
}
|
| 1136 |
} else {
|
1137 |
|
| 1137 |
if (plan.getTargetPlan() != psp.getSecondaryPlan()) {
|
1138 |
} else {
|
| 1138 |
float totalSecondaryPlan = psp.getSecondaryPlan() + 10000;
|
1139 |
if (plan.getTargetPlan() != psp.getSecondaryPlan()) {
|
| 1139 |
if (authUser.getId() == plan.getAuthId()) {
|
1140 |
float totalSecondaryPlan = psp.getSecondaryPlan() + 10000;
|
| 1140 |
if (authUser.getEmailId().equals("tarun.verma@smartdukaan.com")
|
1141 |
if (authUser.getId() == plan.getAuthId()) {
|
| 1141 |
|| authUser.getEmailId().equals("rakesh.sonawane@smartdukaan.com")
|
1142 |
if (authUser.getEmailId().equals("tarun.verma@smartdukaan.com")
|
| 1142 |
|| plan.getTargetPlan() >= totalSecondaryPlan) {
|
1143 |
|| authUser.getEmailId().equals("rakesh.sonawane@smartdukaan.com")
|
| 1143 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
1144 |
|| plan.getTargetPlan() >= totalSecondaryPlan) {
|
| 1144 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
1145 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
| 1145 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
1146 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
| 1146 |
psp.setActive(true);
|
1147 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
| 1147 |
} else {
|
1148 |
psp.setActive(true);
|
| 1148 |
throw new ProfitMandiBusinessException("secondary target", "",
|
1149 |
} else {
|
| 1149 |
"secondary target should be more than " + totalSecondaryPlan);
|
1150 |
throw new ProfitMandiBusinessException("secondary target", "",
|
| 1150 |
}
|
1151 |
"secondary target should be more than " + totalSecondaryPlan);
|
| 1151 |
|
1152 |
}
|
| 1152 |
} else {
|
1153 |
|
| 1153 |
|
1154 |
} else {
|
| 1154 |
if (authUser.getEmailId().equals("tarun.verma@smartdukaan.com")
|
1155 |
|
| 1155 |
|| authUser.getEmailId().equals("rakesh.sonawane@smartdukaan.com")
|
1156 |
if (authUser.getEmailId().equals("tarun.verma@smartdukaan.com")
|
| 1156 |
|| plan.getTargetPlan() >= totalSecondaryPlan) {
|
1157 |
|| authUser.getEmailId().equals("rakesh.sonawane@smartdukaan.com")
|
| 1157 |
|
1158 |
|| plan.getTargetPlan() >= totalSecondaryPlan) {
|
| 1158 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
1159 |
|
| 1159 |
psp.setActive(false);
|
1160 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
| 1160 |
psp = new PartnerSecondaryPlan();
|
1161 |
psp.setActive(false);
|
| 1161 |
psp.setAuthId(authUser.getId());
|
1162 |
psp = new PartnerSecondaryPlan();
|
| 1162 |
psp.setBrand(pspm.getKey());
|
1163 |
psp.setAuthId(authUser.getId());
|
| 1163 |
psp.setFofoId(pspm.getValue().getFofoId());
|
1164 |
psp.setBrand(pspm.getKey());
|
| 1164 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
1165 |
psp.setFofoId(pspm.getValue().getFofoId());
|
| 1165 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
1166 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
| 1166 |
psp.setCreateTimestamp(LocalDateTime.now());
|
1167 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
| 1167 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
1168 |
psp.setCreateTimestamp(LocalDateTime.now());
|
| 1168 |
psp.setActive(true);
|
1169 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
| 1169 |
partnerSecondaryPlanRepository.persist(psp);
|
1170 |
psp.setActive(true);
|
| 1170 |
} else {
|
1171 |
partnerSecondaryPlanRepository.persist(psp);
|
| 1171 |
throw new ProfitMandiBusinessException("secondary target", "",
|
1172 |
} else {
|
| 1172 |
"secondary target should be more than " + totalSecondaryPlan);
|
1173 |
throw new ProfitMandiBusinessException("secondary target", "",
|
| 1173 |
}
|
1174 |
"secondary target should be more than " + totalSecondaryPlan);
|
| 1174 |
}
|
1175 |
}
|
| 1175 |
}
|
1176 |
}
|
| 1176 |
|
1177 |
}
|
| 1177 |
if ((LocalDate.now().atStartOfDay().equals(ptam.getSecondaryCommitmentDate().atStartOfDay())
|
1178 |
|
| 1178 |
|| ptam.getSecondaryCommitmentDate().atStartOfDay().isAfter(LocalDate.now().atStartOfDay()))
|
1179 |
if ((LocalDate.now().atStartOfDay().equals(ptam.getSecondaryCommitmentDate().atStartOfDay())
|
| 1179 |
&& plan.getTargetPlan() == psp.getSecondaryPlan()) {
|
1180 |
|| ptam.getSecondaryCommitmentDate().atStartOfDay().isAfter(LocalDate.now().atStartOfDay()))
|
| 1180 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
1181 |
&& plan.getTargetPlan() == psp.getSecondaryPlan()) {
|
| 1181 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
1182 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
| 1182 |
}
|
1183 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
| 1183 |
|
1184 |
}
|
| 1184 |
}
|
1185 |
|
| 1185 |
} else {
|
1186 |
}
|
| 1186 |
throw new ProfitMandiBusinessException("Date", "",
|
1187 |
} else {
|
| 1187 |
"you can't select the back date " + ptam.getSecondaryCommitmentDate());
|
1188 |
throw new ProfitMandiBusinessException("Date", "",
|
| 1188 |
}
|
1189 |
"you can't select the back date " + ptam.getSecondaryCommitmentDate());
|
| 1189 |
|
1190 |
}
|
| 1190 |
}
|
1191 |
|
| 1191 |
|
1192 |
}
|
| 1192 |
return responseSender.ok(true);
|
1193 |
|
| 1193 |
|
1194 |
return responseSender.ok(true);
|
| 1194 |
}
|
1195 |
|
| 1195 |
|
1196 |
}
|
| 1196 |
@RequestMapping(value = "/viewTickets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
1197 |
|
| 1197 |
@ApiImplicitParams({
|
1198 |
@RequestMapping(value = "/viewTickets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1198 |
|
1199 |
@ApiImplicitParams({
|
| 1199 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
1200 |
|
| 1200 |
public ResponseEntity<?> viewTickets(HttpServletRequest request, @RequestParam int fofoId)
|
1201 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 1201 |
throws ProfitMandiBusinessException {
|
1202 |
public ResponseEntity<?> viewTickets(HttpServletRequest request, @RequestParam int fofoId)
|
| 1202 |
List<Ticket> tickets = ticketRepository.selectAllOpenTicketByRetailer(fofoId);
|
1203 |
throws ProfitMandiBusinessException {
|
| 1203 |
|
1204 |
List<Ticket> tickets = ticketRepository.selectAllOpenTicketByRetailer(fofoId);
|
| 1204 |
List<TicketViewModel> viewList = new ArrayList<>();
|
1205 |
|
| 1205 |
for (Ticket ticket : tickets) {
|
1206 |
List<TicketViewModel> viewList = new ArrayList<>();
|
| 1206 |
|
1207 |
for (Ticket ticket : tickets) {
|
| 1207 |
TicketViewModel ticketViewModel = new TicketViewModel();
|
1208 |
|
| 1208 |
ticketViewModel.setId(ticket.getId());
|
1209 |
TicketViewModel ticketViewModel = new TicketViewModel();
|
| 1209 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
|
1210 |
ticketViewModel.setId(ticket.getId());
|
| 1210 |
TicketCategory ticketCategory = ticketCategoryRepository.selectById(ticketSubCategory.getCategoryId());
|
1211 |
TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
|
| 1211 |
|
1212 |
TicketCategory ticketCategory = ticketCategoryRepository.selectById(ticketSubCategory.getCategoryId());
|
| 1212 |
ticketViewModel.setCategoryName(ticketCategory.getName());
|
1213 |
|
| 1213 |
ticketViewModel.setSubCategoryName(ticketSubCategory.getName());
|
1214 |
ticketViewModel.setCategoryName(ticketCategory.getName());
|
| 1214 |
ticketViewModel.setCreatedTimestamp(ticket.getCreateTimestamp());
|
1215 |
ticketViewModel.setSubCategoryName(ticketSubCategory.getName());
|
| 1215 |
|
1216 |
ticketViewModel.setCreatedTimestamp(ticket.getCreateTimestamp());
|
| 1216 |
viewList.add(ticketViewModel);
|
1217 |
|
| 1217 |
}
|
1218 |
viewList.add(ticketViewModel);
|
| 1218 |
return responseSender.ok(viewList);
|
1219 |
}
|
| 1219 |
|
1220 |
return responseSender.ok(viewList);
|
| 1220 |
}
|
1221 |
|
| 1221 |
|
1222 |
}
|
| 1222 |
@RequestMapping(value = "/viewRecentTickets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
1223 |
|
| 1223 |
@ApiImplicitParams({
|
1224 |
@RequestMapping(value = "/viewRecentTickets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1224 |
|
1225 |
@ApiImplicitParams({
|
| 1225 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
1226 |
|
| 1226 |
public ResponseEntity<?> viewRecentTickets(HttpServletRequest request, @RequestParam int fofoId)
|
1227 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 1227 |
throws ProfitMandiBusinessException {
|
1228 |
public ResponseEntity<?> viewRecentTickets(HttpServletRequest request, @RequestParam int fofoId)
|
| 1228 |
List<TicketViewModel> viewList = ticketRepository.selectRecentClosedTicket(fofoId,
|
1229 |
throws ProfitMandiBusinessException {
|
| 1229 |
LocalDateTime.now().minusDays(20));
|
1230 |
List<TicketViewModel> viewList = ticketRepository.selectRecentClosedTicket(fofoId,
|
| 1230 |
|
1231 |
LocalDateTime.now().minusDays(20));
|
| 1231 |
return responseSender.ok(viewList);
|
1232 |
|
| 1232 |
|
1233 |
return responseSender.ok(viewList);
|
| 1233 |
}
|
1234 |
|
| 1234 |
|
1235 |
}
|
| 1235 |
@RequestMapping(value = "/createTicket", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
1236 |
|
| 1236 |
@ApiImplicitParams({
|
1237 |
@RequestMapping(value = "/createTicket", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1237 |
|
1238 |
@ApiImplicitParams({
|
| 1238 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
1239 |
|
| 1239 |
public ResponseEntity<?> createTicket(HttpServletRequest request) throws ProfitMandiBusinessException {
|
1240 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 1240 |
List<TicketCategory> ticketCategories = csService.getAllTicketCategotyFromSubCategory();
|
1241 |
public ResponseEntity<?> createTicket(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| 1241 |
|
1242 |
List<TicketCategory> ticketCategories = csService.getAllTicketCategotyFromSubCategory();
|
| 1242 |
return responseSender.ok(ticketCategories);
|
1243 |
|
| 1243 |
}
|
1244 |
return responseSender.ok(ticketCategories);
|
| 1244 |
|
1245 |
}
|
| 1245 |
@RequestMapping(value = "/getSubCategoriesByCategoryId", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
1246 |
|
| 1246 |
@ApiImplicitParams({
|
1247 |
@RequestMapping(value = "/getSubCategoriesByCategoryId", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1247 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
1248 |
@ApiImplicitParams({
|
| 1248 |
|
1249 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 1249 |
public ResponseEntity<?> getSubCategoriesByCategoryId(HttpServletRequest request,
|
1250 |
|
| 1250 |
@RequestParam(name = "categoryId", defaultValue = "0") int categoryId, Model model) {
|
1251 |
public ResponseEntity<?> getSubCategoriesByCategoryId(HttpServletRequest request,
|
| 1251 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectAll(categoryId);
|
1252 |
@RequestParam(name = "categoryId", defaultValue = "0") int categoryId, Model model) {
|
| 1252 |
LOGGER.info(ticketSubCategories);
|
1253 |
List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectAll(categoryId);
|
| 1253 |
return responseSender.ok(ticketSubCategories);
|
1254 |
LOGGER.info(ticketSubCategories);
|
| 1254 |
}
|
1255 |
return responseSender.ok(ticketSubCategories);
|
| 1255 |
|
1256 |
}
|
| 1256 |
@RequestMapping(value = "/createTicket", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
1257 |
|
| 1257 |
@ApiImplicitParams({
|
1258 |
@RequestMapping(value = "/createTicket", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1258 |
|
1259 |
@ApiImplicitParams({
|
| 1259 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
1260 |
|
| 1260 |
public ResponseEntity<?> createTicket(HttpServletRequest request, @RequestParam(name = "categoryId") int categoryId,
|
1261 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 1261 |
@RequestParam(name = "subCategoryId") int subCategoryId, @RequestParam(name = "message") String message,
|
1262 |
public ResponseEntity<?> createTicket(HttpServletRequest request, @RequestParam(name = "categoryId") int categoryId,
|
| 1262 |
@RequestParam(name = "fofoId") int fofoId) throws Exception {
|
1263 |
@RequestParam(name = "subCategoryId") int subCategoryId, @RequestParam(name = "message") String message,
|
| 1263 |
|
1264 |
@RequestParam(name = "fofoId") int fofoId) throws Exception {
|
| 1264 |
int id = (int) request.getAttribute("userId");
|
1265 |
|
| 1265 |
|
1266 |
int id = (int) request.getAttribute("userId");
|
| 1266 |
LOGGER.info("id" + id);
|
1267 |
|
| 1267 |
|
1268 |
LOGGER.info("id" + id);
|
| 1268 |
User user = userRepository.selectById(id);
|
1269 |
|
| 1269 |
|
1270 |
User user = userRepository.selectById(id);
|
| 1270 |
AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
|
1271 |
|
| 1271 |
|
1272 |
AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
|
| 1272 |
List<Ticket> tickets = ticketRepository.selectAllResolvedMarkedTicketByCreator(fofoId);
|
1273 |
|
| 1273 |
if (tickets.size() > 3 || tickets.size() == 3) {
|
1274 |
List<Ticket> tickets = ticketRepository.selectAllResolvedMarkedTicketByCreator(fofoId);
|
| 1274 |
return responseSender.ok(false);
|
1275 |
if (tickets.size() > 3 || tickets.size() == 3) {
|
| 1275 |
} else {
|
1276 |
return responseSender.ok(false);
|
| 1276 |
csService.createTicket(fofoId, categoryId, subCategoryId, message);
|
1277 |
} else {
|
| 1277 |
|
1278 |
csService.createTicket(fofoId, categoryId, subCategoryId, message);
|
| 1278 |
PartnerCollectionRemark pcr = new PartnerCollectionRemark();
|
1279 |
|
| 1279 |
pcr.setFofoId(fofoId);
|
1280 |
PartnerCollectionRemark pcr = new PartnerCollectionRemark();
|
| 1280 |
pcr.setAuthId(authUser.getId());
|
1281 |
pcr.setFofoId(fofoId);
|
| 1281 |
pcr.setMessage("Ticket Created");
|
1282 |
pcr.setAuthId(authUser.getId());
|
| 1282 |
pcr.setRemark(CollectionRemark.TICKET_CREATED);
|
1283 |
pcr.setMessage("Ticket Created");
|
| 1283 |
pcr.setCreateTimestamp(LocalDateTime.now());
|
1284 |
pcr.setRemark(CollectionRemark.TICKET_CREATED);
|
| 1284 |
partnerCollectionRemarkRepository.persist(pcr);
|
1285 |
pcr.setCreateTimestamp(LocalDateTime.now());
|
| 1285 |
|
1286 |
partnerCollectionRemarkRepository.persist(pcr);
|
| 1286 |
}
|
1287 |
|
| 1287 |
return responseSender.ok(true);
|
1288 |
}
|
| 1288 |
}
|
1289 |
return responseSender.ok(true);
|
| 1289 |
|
1290 |
}
|
| 1290 |
@RequestMapping(value = "/getCollectionRemark", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
1291 |
|
| 1291 |
@ApiImplicitParams({
|
1292 |
@RequestMapping(value = "/getCollectionRemark", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1292 |
|
1293 |
@ApiImplicitParams({
|
| 1293 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
1294 |
|
| 1294 |
public ResponseEntity<?> getCollectionRemark(HttpServletRequest request) throws ProfitMandiBusinessException {
|
1295 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 1295 |
List<CollectionRemark> remarks = Arrays.asList(CollectionRemark.values()).stream()
|
1296 |
public ResponseEntity<?> getCollectionRemark(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| 1296 |
.filter(x -> !x.equals(CollectionRemark.COLLECTION_PLAN)).collect(Collectors.toList());
|
1297 |
List<CollectionRemark> remarks = Arrays.asList(CollectionRemark.values()).stream()
|
| 1297 |
return responseSender.ok(remarks);
|
1298 |
.filter(x -> !x.equals(CollectionRemark.COLLECTION_PLAN)).collect(Collectors.toList());
|
| 1298 |
}
|
1299 |
return responseSender.ok(remarks);
|
| 1299 |
|
1300 |
}
|
| 1300 |
@RequestMapping(value = "/createPartnerColectionRemark", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
1301 |
|
| 1301 |
@ApiImplicitParams({
|
1302 |
@RequestMapping(value = "/createPartnerColectionRemark", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1302 |
|
1303 |
@ApiImplicitParams({
|
| 1303 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
1304 |
|
| 1304 |
public ResponseEntity<?> createPartnerColectionRemark(HttpServletRequest request,
|
1305 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 1305 |
@RequestBody PartnerCollectionRemarkModel partnerCollectionRemarkModel)
|
1306 |
public ResponseEntity<?> createPartnerColectionRemark(HttpServletRequest request,
|
| 1306 |
throws ProfitMandiBusinessException {
|
1307 |
@RequestBody PartnerCollectionRemarkModel partnerCollectionRemarkModel)
|
| 1307 |
AuthUser authUser = authRepository.selectByGmailId(partnerCollectionRemarkModel.getGmailId());
|
1308 |
throws ProfitMandiBusinessException {
|
| 1308 |
|
1309 |
AuthUser authUser = authRepository.selectByGmailId(partnerCollectionRemarkModel.getGmailId());
|
| 1309 |
PartnerCollectionRemark pcr = new PartnerCollectionRemark();
|
1310 |
|
| 1310 |
pcr.setFofoId(partnerCollectionRemarkModel.getFofoId());
|
1311 |
PartnerCollectionRemark pcr = new PartnerCollectionRemark();
|
| 1311 |
pcr.setAuthId(authUser.getId());
|
1312 |
pcr.setFofoId(partnerCollectionRemarkModel.getFofoId());
|
| 1312 |
pcr.setMessage(partnerCollectionRemarkModel.getMessage());
|
1313 |
pcr.setAuthId(authUser.getId());
|
| 1313 |
pcr.setRemark(partnerCollectionRemarkModel.getRemark());
|
1314 |
pcr.setMessage(partnerCollectionRemarkModel.getMessage());
|
| 1314 |
pcr.setCreateTimestamp(LocalDateTime.now());
|
1315 |
pcr.setRemark(partnerCollectionRemarkModel.getRemark());
|
| 1315 |
partnerCollectionRemarkRepository.persist(pcr);
|
1316 |
pcr.setCreateTimestamp(LocalDateTime.now());
|
| 1316 |
return responseSender.ok(true);
|
1317 |
partnerCollectionRemarkRepository.persist(pcr);
|
| 1317 |
|
1318 |
return responseSender.ok(true);
|
| 1318 |
}
|
1319 |
|
| 1319 |
|
1320 |
}
|
| 1320 |
@RequestMapping(value = "/uploadFranchiseeVisit", method = RequestMethod.POST)
|
1321 |
|
| 1321 |
public ResponseEntity<?> readCsvFileAndSetLead(HttpServletRequest request, @RequestPart MultipartFile multipartFile)
|
1322 |
@RequestMapping(value = "/uploadFranchiseeVisit", method = RequestMethod.POST)
|
| 1322 |
throws Throwable {
|
1323 |
public ResponseEntity<?> readCsvFileAndSetLead(HttpServletRequest request, @RequestPart MultipartFile multipartFile)
|
| 1323 |
|
1324 |
throws Throwable {
|
| 1324 |
int id = (int) request.getAttribute("userId");
|
1325 |
|
| 1325 |
|
1326 |
int id = (int) request.getAttribute("userId");
|
| 1326 |
LOGGER.info("id" + id);
|
1327 |
|
| 1327 |
|
1328 |
LOGGER.info("id" + id);
|
| 1328 |
User user = userRepository.selectById(id);
|
1329 |
|
| 1329 |
|
1330 |
User user = userRepository.selectById(id);
|
| 1330 |
AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
|
1331 |
|
| 1331 |
|
1332 |
AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
|
| 1332 |
String fileName = multipartFile.getName();
|
1333 |
|
| 1333 |
String fileNames = multipartFile.getOriginalFilename();
|
1334 |
String fileName = multipartFile.getName();
|
| 1334 |
|
1335 |
String fileNames = multipartFile.getOriginalFilename();
|
| 1335 |
LOGGER.info("fileName" + fileName);
|
1336 |
|
| 1336 |
LOGGER.info("fileNames" + fileNames);
|
1337 |
LOGGER.info("fileName" + fileName);
|
| 1337 |
|
1338 |
LOGGER.info("fileNames" + fileNames);
|
| 1338 |
List<CSVRecord> records = FileUtil.readFile(multipartFile);
|
1339 |
|
| 1339 |
|
1340 |
List<CSVRecord> records = FileUtil.readFile(multipartFile);
|
| 1340 |
for (CSVRecord record : records) {
|
1341 |
|
| 1341 |
FranchiseeVisit franchiseeVisit = new FranchiseeVisit();
|
1342 |
for (CSVRecord record : records) {
|
| 1342 |
franchiseeVisit.setFofoId(Integer.parseInt(record.get(0)));
|
1343 |
FranchiseeVisit franchiseeVisit = new FranchiseeVisit();
|
| 1343 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(Integer.parseInt(record.get(0)));
|
1344 |
franchiseeVisit.setFofoId(Integer.parseInt(record.get(0)));
|
| 1344 |
|
1345 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(Integer.parseInt(record.get(0)));
|
| 1345 |
franchiseeVisit.setPartnerName(customRetailer.getBusinessName());
|
1346 |
|
| 1346 |
franchiseeVisit.setAgenda(record.get(1));
|
1347 |
franchiseeVisit.setPartnerName(customRetailer.getBusinessName());
|
| 1347 |
franchiseeVisit.setCreatedTimestamp(LocalDateTime.now());
|
1348 |
franchiseeVisit.setAgenda(record.get(1));
|
| 1348 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
1349 |
franchiseeVisit.setCreatedTimestamp(LocalDateTime.now());
|
| 1349 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.OPEN);
|
1350 |
franchiseeVisit.setUpdatedTimestamp(LocalDateTime.now());
|
| 1350 |
|
1351 |
franchiseeVisit.setStatus(FranchiseeVisitStatus.OPEN);
|
| 1351 |
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
|
1352 |
|
| 1352 |
LOGGER.info(record.get(1));
|
1353 |
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
|
| 1353 |
LocalDate dateTime = LocalDate.parse(record.get(2), formatter);
|
1354 |
LOGGER.info(record.get(1));
|
| 1354 |
|
1355 |
LocalDate dateTime = LocalDate.parse(record.get(2), formatter);
|
| 1355 |
franchiseeVisit.setScheduleTimestamp(dateTime.atStartOfDay());
|
1356 |
|
| 1356 |
// change
|
1357 |
franchiseeVisit.setScheduleTimestamp(dateTime.atStartOfDay());
|
| 1357 |
|
1358 |
// change
|
| 1358 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
1359 |
|
| 1359 |
franchiseeVisit.setCreatedBy(authUserName);
|
1360 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
| 1360 |
franchiseeVisit.setAuthId(authUser.getId());
|
1361 |
franchiseeVisit.setCreatedBy(authUserName);
|
| 1361 |
|
1362 |
franchiseeVisit.setAuthId(authUser.getId());
|
| 1362 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
1363 |
|
| 1363 |
|
1364 |
franchiseeVisitRepository.persist(franchiseeVisit);
|
| 1364 |
return responseSender.ok(true);
|
1365 |
|
| 1365 |
}
|
1366 |
return responseSender.ok(true);
|
| 1366 |
|
1367 |
}
|
| 1367 |
return responseSender.ok(true);
|
1368 |
|
| 1368 |
|
1369 |
return responseSender.ok(true);
|
| 1369 |
}
|
1370 |
|
| 1370 |
|
1371 |
}
|
| 1371 |
@RequestMapping(value = "/downloadFranchiseeVisitTemplate", method = RequestMethod.GET)
|
1372 |
|
| 1372 |
public ResponseEntity<?> downloadFranchiseeVisitTemplate(HttpServletRequest request) throws Exception {
|
1373 |
@RequestMapping(value = "/downloadFranchiseeVisitTemplate", method = RequestMethod.GET)
|
| 1373 |
|
1374 |
public ResponseEntity<?> downloadFranchiseeVisitTemplate(HttpServletRequest request) throws Exception {
|
| 1374 |
// ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
1375 |
|
| 1375 |
|
1376 |
// ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| 1376 |
List<List<?>> rows = new ArrayList<>();
|
1377 |
|
| 1377 |
|
1378 |
List<List<?>> rows = new ArrayList<>();
|
| 1378 |
org.apache.commons.io.output.ByteArrayOutputStream byteArrayOutputStream = FileUtil
|
1379 |
|
| 1379 |
.getCSVByteStream(Arrays.asList("Partner Id", "Agenda", "Schedule Timestamp"), rows);
|
1380 |
org.apache.commons.io.output.ByteArrayOutputStream byteArrayOutputStream = FileUtil
|
| 1380 |
|
1381 |
.getCSVByteStream(Arrays.asList("Partner Id", "Agenda", "Schedule Timestamp"), rows);
|
| 1381 |
try {
|
1382 |
|
| 1382 |
byteArrayOutputStream.close();
|
1383 |
try {
|
| 1383 |
} catch (IOException e) {
|
1384 |
byteArrayOutputStream.close();
|
| 1384 |
// TODO Auto-generated catch block
|
1385 |
} catch (IOException e) {
|
| 1385 |
e.printStackTrace();
|
1386 |
// TODO Auto-generated catch block
|
| 1386 |
}
|
1387 |
e.printStackTrace();
|
| 1387 |
|
1388 |
}
|
| 1388 |
String filename = "template.csv";
|
1389 |
|
| 1389 |
HttpHeaders headers = new HttpHeaders();
|
1390 |
String filename = "template.csv";
|
| 1390 |
headers.add("Content-Type", "application/csv");
|
1391 |
HttpHeaders headers = new HttpHeaders();
|
| 1391 |
headers.setContentDispositionFormData(filename, filename);
|
1392 |
headers.add("Content-Type", "application/csv");
|
| 1392 |
|
1393 |
headers.setContentDispositionFormData(filename, filename);
|
| 1393 |
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
|
1394 |
|
| 1394 |
|
1395 |
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
|
| 1395 |
ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(byteArrayOutputStream.toByteArray(), headers,
|
1396 |
|
| 1396 |
HttpStatus.OK);
|
1397 |
ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(byteArrayOutputStream.toByteArray(), headers,
|
| 1397 |
return response;
|
1398 |
HttpStatus.OK);
|
| 1398 |
|
1399 |
return response;
|
| 1399 |
}
|
1400 |
|
| 1400 |
|
1401 |
}
|
| 1401 |
@RequestMapping(value = "/markVisitAttendance", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
1402 |
|
| 1402 |
public ResponseEntity<?> markVisitAttendance(HttpServletRequest request, @RequestParam(name = "id") int id)
|
1403 |
@RequestMapping(value = "/markVisitAttendance", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1403 |
throws ProfitMandiBusinessException {
|
1404 |
public ResponseEntity<?> markVisitAttendance(HttpServletRequest request, @RequestParam(name = "id") int id)
|
| 1404 |
FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(id);
|
1405 |
throws ProfitMandiBusinessException {
|
| 1405 |
|
1406 |
FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(id);
|
| 1406 |
franchiseeVisit.setVisitTimestamp(LocalDateTime.now());
|
1407 |
|
| 1407 |
|
1408 |
franchiseeVisit.setVisitTimestamp(LocalDateTime.now());
|
| 1408 |
return responseSender.ok(true);
|
1409 |
|
| 1409 |
|
1410 |
return responseSender.ok(true);
|
| 1410 |
}
|
1411 |
|
| 1411 |
|
1412 |
}
|
| 1412 |
@RequestMapping(value = "/getVisitRequests", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
1413 |
|
| 1413 |
public ResponseEntity<?> getVisitRequests(HttpServletRequest request,
|
1414 |
@RequestMapping(value = "/getVisitRequests", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1414 |
@RequestParam(name = "gmailId") String gmailId, Model model) throws Exception {
|
1415 |
public ResponseEntity<?> getVisitRequests(HttpServletRequest request,
|
| 1415 |
|
1416 |
@RequestParam(name = "gmailId") String gmailId, Model model) throws Exception {
|
| 1416 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
1417 |
|
| 1417 |
|
1418 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
| 1418 |
List<Integer> authUserIds = authService.getAllReportees(authUser.getId());
|
1419 |
|
| 1419 |
List<VisitSummaryModel> visitSummary = new ArrayList<>();
|
1420 |
List<Integer> authUserIds = authService.getAllReportees(authUser.getId());
|
| 1420 |
|
1421 |
List<VisitSummaryModel> visitSummary = new ArrayList<>();
|
| 1421 |
if (!authUserIds.isEmpty()) {
|
1422 |
|
| 1422 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(authUserIds);
|
1423 |
if (!authUserIds.isEmpty()) {
|
| 1423 |
|
1424 |
List<AuthUser> authUsers = authRepository.selectAllAuthUserByIds(authUserIds);
|
| 1424 |
List<VisitRequest> allVisitRequests = visitRequestRepository.selectByAuthIdsAndDate(authUserIds,
|
1425 |
|
| 1425 |
LocalDate.now().minusDays(7), Arrays.asList(VisitStatus.approved, VisitStatus.pending));
|
1426 |
List<VisitRequest> allVisitRequests = visitRequestRepository.selectByAuthIdsAndDate(authUserIds,
|
| 1426 |
LOGGER.info("allVisitRequests {}", allVisitRequests);
|
1427 |
LocalDate.now().minusDays(7), Arrays.asList(VisitStatus.approved, VisitStatus.pending));
|
| 1427 |
|
1428 |
LOGGER.info("allVisitRequests {}", allVisitRequests);
|
| 1428 |
if (!allVisitRequests.isEmpty()) {
|
1429 |
|
| 1429 |
|
1430 |
if (!allVisitRequests.isEmpty()) {
|
| 1430 |
List<Integer> leadIds = allVisitRequests.stream().filter(x -> x.getVisitType().equals("lead"))
|
1431 |
|
| 1431 |
.map(x -> x.getVisitId()).collect(Collectors.toList());
|
1432 |
List<Integer> leadIds = allVisitRequests.stream().filter(x -> x.getVisitType().equals("lead"))
|
| 1432 |
List<Lead> leads = new ArrayList<>();
|
1433 |
.map(x -> x.getVisitId()).collect(Collectors.toList());
|
| 1433 |
if (!leadIds.isEmpty()) {
|
1434 |
List<Lead> leads = new ArrayList<>();
|
| 1434 |
leads = leadRepository.selectAllByIds(leadIds);
|
1435 |
if (!leadIds.isEmpty()) {
|
| 1435 |
|
1436 |
leads = leadRepository.selectAllByIds(leadIds);
|
| 1436 |
for (Lead lead : leads) {
|
1437 |
|
| 1437 |
List<LeadActivity> leadActivities = leadActivityRepository.selectBYLeadId(lead.getId());
|
1438 |
for (Lead lead : leads) {
|
| 1438 |
lead.setScheduledTimestamp(leadActivities.get(0).getSchelduleTimestamp());
|
1439 |
List<LeadActivity> leadActivities = leadActivityRepository.selectBYLeadId(lead.getId());
|
| 1439 |
lead.setLeadActivity(leadActivities.get(0));
|
1440 |
lead.setScheduledTimestamp(leadActivities.get(0).getSchelduleTimestamp());
|
| 1440 |
}
|
1441 |
lead.setLeadActivity(leadActivities.get(0));
|
| 1441 |
}
|
1442 |
}
|
| 1442 |
List<Integer> franchiseeIds = allVisitRequests.stream()
|
1443 |
}
|
| 1443 |
.filter(x -> x.getVisitType().equals("franchiseeVisit")).map(x -> x.getVisitId())
|
1444 |
List<Integer> franchiseeIds = allVisitRequests.stream()
|
| 1444 |
.collect(Collectors.toList());
|
1445 |
.filter(x -> x.getVisitType().equals("franchiseeVisit")).map(x -> x.getVisitId())
|
| 1445 |
List<FranchiseeVisit> franchiseeVisits = new ArrayList<>();
|
1446 |
.collect(Collectors.toList());
|
| 1446 |
if (!franchiseeIds.isEmpty()) {
|
1447 |
List<FranchiseeVisit> franchiseeVisits = new ArrayList<>();
|
| 1447 |
franchiseeVisits = franchiseeVisitRepository.selectAllByIds(franchiseeIds);
|
1448 |
if (!franchiseeIds.isEmpty()) {
|
| 1448 |
LOGGER.info("franchiseeVisits {}", franchiseeVisits);
|
1449 |
franchiseeVisits = franchiseeVisitRepository.selectAllByIds(franchiseeIds);
|
| 1449 |
|
1450 |
LOGGER.info("franchiseeVisits {}", franchiseeVisits);
|
| 1450 |
for (FranchiseeVisit franchiseeVisit : franchiseeVisits) {
|
1451 |
|
| 1451 |
List<FranchiseeActivity> franchiseeActivities = franchiseeActivityRepository
|
1452 |
for (FranchiseeVisit franchiseeVisit : franchiseeVisits) {
|
| 1452 |
.selectByFranchiseeVisitId(franchiseeVisit.getId());
|
1453 |
List<FranchiseeActivity> franchiseeActivities = franchiseeActivityRepository
|
| 1453 |
LOGGER.info("franchiseeActivities {}", franchiseeActivities);
|
1454 |
.selectByFranchiseeVisitId(franchiseeVisit.getId());
|
| 1454 |
|
1455 |
LOGGER.info("franchiseeActivities {}", franchiseeActivities);
|
| 1455 |
franchiseeVisit.setScheduleTimestamp(franchiseeActivities.get(0).getSchelduleTimestamp());
|
1456 |
|
| 1456 |
franchiseeVisit.setFranchiseeActivity(franchiseeActivities.get(0));
|
1457 |
franchiseeVisit.setScheduleTimestamp(franchiseeActivities.get(0).getSchelduleTimestamp());
|
| 1457 |
}
|
1458 |
franchiseeVisit.setFranchiseeActivity(franchiseeActivities.get(0));
|
| 1458 |
|
1459 |
}
|
| 1459 |
}
|
1460 |
|
| 1460 |
|
1461 |
}
|
| 1461 |
Map<LocalDate, List<VisitRequest>> dateWiseVisitRequest = allVisitRequests.stream()
|
1462 |
|
| 1462 |
.collect(Collectors.groupingBy(x -> x.getScheduleTimestamp().toLocalDate()));
|
1463 |
Map<LocalDate, List<VisitRequest>> dateWiseVisitRequest = allVisitRequests.stream()
|
| 1463 |
|
1464 |
.collect(Collectors.groupingBy(x -> x.getScheduleTimestamp().toLocalDate()));
|
| 1464 |
for (Entry<LocalDate, List<VisitRequest>> visitEntry : dateWiseVisitRequest.entrySet()) {
|
1465 |
|
| 1465 |
|
1466 |
for (Entry<LocalDate, List<VisitRequest>> visitEntry : dateWiseVisitRequest.entrySet()) {
|
| 1466 |
LocalDate date = visitEntry.getKey();
|
1467 |
|
| 1467 |
List<VisitRequest> visitRequests = visitEntry.getValue();
|
1468 |
LocalDate date = visitEntry.getKey();
|
| 1468 |
|
1469 |
List<VisitRequest> visitRequests = visitEntry.getValue();
|
| 1469 |
VisitSummaryModel visitSummaryModel = new VisitSummaryModel();
|
1470 |
|
| 1470 |
|
1471 |
VisitSummaryModel visitSummaryModel = new VisitSummaryModel();
|
| 1471 |
visitSummaryModel.setDate(date);
|
1472 |
|
| 1472 |
List<Integer> dateWiseLeadEntry = visitRequests.stream()
|
1473 |
visitSummaryModel.setDate(date);
|
| 1473 |
.filter(x -> x.getVisitType().equals("lead")).map(x -> x.getVisitId())
|
1474 |
List<Integer> dateWiseLeadEntry = visitRequests.stream()
|
| 1474 |
.collect(Collectors.toList());
|
1475 |
.filter(x -> x.getVisitType().equals("lead")).map(x -> x.getVisitId())
|
| 1475 |
|
1476 |
.collect(Collectors.toList());
|
| 1476 |
List<Integer> dateWiseFranchiseeIds = visitRequests.stream()
|
1477 |
|
| 1477 |
.filter(x -> x.getVisitType().equals("franchiseeVisit")).map(x -> x.getVisitId())
|
1478 |
List<Integer> dateWiseFranchiseeIds = visitRequests.stream()
|
| 1478 |
.collect(Collectors.toList());
|
1479 |
.filter(x -> x.getVisitType().equals("franchiseeVisit")).map(x -> x.getVisitId())
|
| 1479 |
|
1480 |
.collect(Collectors.toList());
|
| 1480 |
Map<Integer, List<Lead>> filteredLeadsMap = null;
|
1481 |
|
| 1481 |
if (!leads.isEmpty()) {
|
1482 |
Map<Integer, List<Lead>> filteredLeadsMap = null;
|
| 1482 |
filteredLeadsMap = leads.stream().filter(x -> dateWiseLeadEntry.contains(x.getId()))
|
1483 |
if (!leads.isEmpty()) {
|
| 1483 |
.collect(Collectors.groupingBy(x -> x.getAssignTo()));
|
1484 |
filteredLeadsMap = leads.stream().filter(x -> dateWiseLeadEntry.contains(x.getId()))
|
| 1484 |
|
1485 |
.collect(Collectors.groupingBy(x -> x.getAssignTo()));
|
| 1485 |
}
|
1486 |
|
| 1486 |
|
1487 |
}
|
| 1487 |
Map<Integer, List<FranchiseeVisit>> filteredFranchiseeVisitsMap = null;
|
1488 |
|
| 1488 |
|
1489 |
Map<Integer, List<FranchiseeVisit>> filteredFranchiseeVisitsMap = null;
|
| 1489 |
if (!franchiseeVisits.isEmpty()) {
|
1490 |
|
| 1490 |
filteredFranchiseeVisitsMap = franchiseeVisits.stream()
|
1491 |
if (!franchiseeVisits.isEmpty()) {
|
| 1491 |
.filter(x -> dateWiseFranchiseeIds.contains(x.getId()))
|
1492 |
filteredFranchiseeVisitsMap = franchiseeVisits.stream()
|
| 1492 |
.collect(Collectors.groupingBy(x -> x.getAuthId()));
|
1493 |
.filter(x -> dateWiseFranchiseeIds.contains(x.getId()))
|
| 1493 |
|
1494 |
.collect(Collectors.groupingBy(x -> x.getAuthId()));
|
| 1494 |
}
|
1495 |
|
| 1495 |
|
1496 |
}
|
| 1496 |
List<UserVisitModel> userVisits = new ArrayList<>();
|
1497 |
|
| 1497 |
|
1498 |
List<UserVisitModel> userVisits = new ArrayList<>();
|
| 1498 |
for (AuthUser auth : authUsers) {
|
1499 |
|
| 1499 |
UserVisitModel userVisitModel = new UserVisitModel();
|
1500 |
for (AuthUser auth : authUsers) {
|
| 1500 |
List<VisitDescriptionModel> visitDescriptions = new ArrayList<>();
|
1501 |
UserVisitModel userVisitModel = new UserVisitModel();
|
| 1501 |
|
1502 |
List<VisitDescriptionModel> visitDescriptions = new ArrayList<>();
|
| 1502 |
List<Lead> authLeads = new ArrayList<>();
|
1503 |
|
| 1503 |
if (filteredLeadsMap != null) {
|
1504 |
List<Lead> authLeads = new ArrayList<>();
|
| 1504 |
authLeads = filteredLeadsMap.get(auth.getId());
|
1505 |
if (filteredLeadsMap != null) {
|
| 1505 |
|
1506 |
authLeads = filteredLeadsMap.get(auth.getId());
|
| 1506 |
}
|
1507 |
|
| 1507 |
|
1508 |
}
|
| 1508 |
if (authLeads != null && !authLeads.isEmpty()) {
|
1509 |
|
| 1509 |
userVisitModel.setAuthUser(auth.getFullName());
|
1510 |
if (authLeads != null && !authLeads.isEmpty()) {
|
| 1510 |
|
1511 |
userVisitModel.setAuthUser(auth.getFullName());
|
| 1511 |
for (Lead lead : authLeads) {
|
1512 |
|
| 1512 |
|
1513 |
for (Lead lead : authLeads) {
|
| 1513 |
VisitRequest visitRequest = visitRequests.stream().filter(
|
1514 |
|
| 1514 |
x -> x.getVisitId() == lead.getId() && x.getCreatedBy() == lead.getAssignTo())
|
1515 |
VisitRequest visitRequest = visitRequests.stream().filter(
|
| 1515 |
.findAny().orElse(null);
|
1516 |
x -> x.getVisitId() == lead.getId() && x.getCreatedBy() == lead.getAssignTo())
|
| 1516 |
VisitDescriptionModel visitDescriptionModel = new VisitDescriptionModel();
|
1517 |
.findAny().orElse(null);
|
| 1517 |
visitDescriptionModel.setVisitId(visitRequest.getId());
|
1518 |
VisitDescriptionModel visitDescriptionModel = new VisitDescriptionModel();
|
| 1518 |
visitDescriptionModel.setVisitName(lead.getFirstName());
|
1519 |
visitDescriptionModel.setVisitId(visitRequest.getId());
|
| 1519 |
visitDescriptionModel.setCity(lead.getCity());
|
1520 |
visitDescriptionModel.setVisitName(lead.getFirstName());
|
| 1520 |
visitDescriptionModel.setState(lead.getState());
|
1521 |
visitDescriptionModel.setCity(lead.getCity());
|
| 1521 |
visitDescriptionModel.setScheduleTime(lead.getScheduledTimestamp());
|
1522 |
visitDescriptionModel.setState(lead.getState());
|
| 1522 |
visitDescriptionModel.setStatus(visitRequest.getStatus());
|
1523 |
visitDescriptionModel.setScheduleTime(lead.getScheduledTimestamp());
|
| 1523 |
visitDescriptionModel.setRemarks(lead.getLeadActivity().getRemark());
|
1524 |
visitDescriptionModel.setStatus(visitRequest.getStatus());
|
| 1524 |
visitDescriptionModel.setVisitType(visitRequest.getVisitType());
|
1525 |
visitDescriptionModel.setRemarks(lead.getLeadActivity().getRemark());
|
| 1525 |
visitDescriptions.add(visitDescriptionModel);
|
1526 |
visitDescriptionModel.setVisitType(visitRequest.getVisitType());
|
| 1526 |
|
1527 |
visitDescriptions.add(visitDescriptionModel);
|
| 1527 |
}
|
1528 |
|
| 1528 |
}
|
1529 |
}
|
| 1529 |
|
1530 |
}
|
| 1530 |
List<FranchiseeVisit> authfranchiseeVisit = new ArrayList<>();
|
1531 |
|
| 1531 |
if (filteredFranchiseeVisitsMap != null) {
|
1532 |
List<FranchiseeVisit> authfranchiseeVisit = new ArrayList<>();
|
| 1532 |
authfranchiseeVisit = filteredFranchiseeVisitsMap.get(auth.getId());
|
1533 |
if (filteredFranchiseeVisitsMap != null) {
|
| 1533 |
|
1534 |
authfranchiseeVisit = filteredFranchiseeVisitsMap.get(auth.getId());
|
| 1534 |
}
|
1535 |
|
| 1535 |
|
1536 |
}
|
| 1536 |
if (authfranchiseeVisit != null && !authfranchiseeVisit.isEmpty()) {
|
1537 |
|
| 1537 |
userVisitModel.setAuthUser(auth.getFullName());
|
1538 |
if (authfranchiseeVisit != null && !authfranchiseeVisit.isEmpty()) {
|
| 1538 |
|
1539 |
userVisitModel.setAuthUser(auth.getFullName());
|
| 1539 |
for (FranchiseeVisit franchiseeVisit : authfranchiseeVisit) {
|
1540 |
|
| 1540 |
|
1541 |
for (FranchiseeVisit franchiseeVisit : authfranchiseeVisit) {
|
| 1541 |
VisitRequest visitRequest = visitRequests.stream()
|
1542 |
|
| 1542 |
.filter(x -> x.getVisitId() == franchiseeVisit.getId()
|
1543 |
VisitRequest visitRequest = visitRequests.stream()
|
| 1543 |
&& x.getCreatedBy() == franchiseeVisit.getAuthId())
|
1544 |
.filter(x -> x.getVisitId() == franchiseeVisit.getId()
|
| 1544 |
.findAny().orElse(null);
|
1545 |
&& x.getCreatedBy() == franchiseeVisit.getAuthId())
|
| 1545 |
|
1546 |
.findAny().orElse(null);
|
| 1546 |
CustomRetailer customRetailer = retailerService
|
1547 |
|
| 1547 |
.getFofoRetailer(franchiseeVisit.getFofoId());
|
1548 |
CustomRetailer customRetailer = retailerService
|
| 1548 |
VisitDescriptionModel visitDescriptionModel = new VisitDescriptionModel();
|
1549 |
.getFofoRetailer(franchiseeVisit.getFofoId());
|
| 1549 |
visitDescriptionModel.setVisitId(visitRequest.getId());
|
1550 |
VisitDescriptionModel visitDescriptionModel = new VisitDescriptionModel();
|
| 1550 |
visitDescriptionModel.setVisitName(franchiseeVisit.getPartnerName());
|
1551 |
visitDescriptionModel.setVisitId(visitRequest.getId());
|
| 1551 |
visitDescriptionModel.setCity(customRetailer.getAddress().getCity());
|
1552 |
visitDescriptionModel.setVisitName(franchiseeVisit.getPartnerName());
|
| 1552 |
visitDescriptionModel.setState(customRetailer.getAddress().getState());
|
1553 |
visitDescriptionModel.setCity(customRetailer.getAddress().getCity());
|
| 1553 |
visitDescriptionModel.setScheduleTime(
|
1554 |
visitDescriptionModel.setState(customRetailer.getAddress().getState());
|
| 1554 |
franchiseeVisit.getFranchiseeActivity().getSchelduleTimestamp());
|
1555 |
visitDescriptionModel.setScheduleTime(
|
| 1555 |
visitDescriptionModel.setStatus(visitRequest.getStatus());
|
1556 |
franchiseeVisit.getFranchiseeActivity().getSchelduleTimestamp());
|
| 1556 |
visitDescriptionModel.setRemarks(franchiseeVisit.getAgenda());
|
1557 |
visitDescriptionModel.setStatus(visitRequest.getStatus());
|
| 1557 |
visitDescriptionModel.setVisitType(visitRequest.getVisitType());
|
1558 |
visitDescriptionModel.setRemarks(franchiseeVisit.getAgenda());
|
| 1558 |
|
1559 |
visitDescriptionModel.setVisitType(visitRequest.getVisitType());
|
| 1559 |
visitDescriptions.add(visitDescriptionModel);
|
1560 |
|
| 1560 |
|
1561 |
visitDescriptions.add(visitDescriptionModel);
|
| 1561 |
}
|
1562 |
|
| 1562 |
}
|
1563 |
}
|
| 1563 |
|
1564 |
}
|
| 1564 |
userVisitModel.setVisitDescriptions(visitDescriptions);
|
1565 |
|
| 1565 |
LOGGER.info("userVisit {}", userVisitModel);
|
1566 |
userVisitModel.setVisitDescriptions(visitDescriptions);
|
| 1566 |
|
1567 |
LOGGER.info("userVisit {}", userVisitModel);
|
| 1567 |
if (userVisitModel.getAuthUser() != null) {
|
1568 |
|
| 1568 |
userVisits.add(userVisitModel);
|
1569 |
if (userVisitModel.getAuthUser() != null) {
|
| 1569 |
}
|
1570 |
userVisits.add(userVisitModel);
|
| 1570 |
|
1571 |
}
|
| 1571 |
}
|
1572 |
|
| 1572 |
|
1573 |
}
|
| 1573 |
visitSummaryModel.setUserVisits(userVisits);
|
1574 |
|
| 1574 |
|
1575 |
visitSummaryModel.setUserVisits(userVisits);
|
| 1575 |
visitSummary.add(visitSummaryModel);
|
1576 |
|
| 1576 |
|
1577 |
visitSummary.add(visitSummaryModel);
|
| 1577 |
}
|
1578 |
|
| 1578 |
|
1579 |
}
|
| 1579 |
}
|
1580 |
|
| 1580 |
|
1581 |
}
|
| 1581 |
}
|
1582 |
|
| 1582 |
return responseSender.ok(visitSummary);
|
1583 |
}
|
| 1583 |
|
1584 |
return responseSender.ok(visitSummary);
|
| 1584 |
}
|
1585 |
|
| 1585 |
|
1586 |
}
|
| 1586 |
@RequestMapping(value = "/visitRequest", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
1587 |
|
| 1587 |
public ResponseEntity<?> visitRequest(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId,
|
1588 |
@RequestMapping(value = "/visitRequest", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 1588 |
@RequestParam(name = "visitId") int visitId, @RequestParam(name = "status") VisitStatus status, Model model)
|
1589 |
public ResponseEntity<?> visitRequest(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId,
|
| 1589 |
throws Exception {
|
1590 |
@RequestParam(name = "visitId") int visitId, @RequestParam(name = "status") VisitStatus status, Model model)
|
| 1590 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
1591 |
throws Exception {
|
| 1591 |
|
1592 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
| 1592 |
VisitRequest visitRequest = visitRequestRepository.selectById(visitId);
|
1593 |
|
| 1593 |
visitRequest.setActionedBy(authUser.getId());
|
1594 |
VisitRequest visitRequest = visitRequestRepository.selectById(visitId);
|
| 1594 |
visitRequest.setStatus(status);
|
1595 |
visitRequest.setActionedBy(authUser.getId());
|
| 1595 |
visitRequest.setUpdatedTimestamp(LocalDateTime.now());
|
1596 |
visitRequest.setStatus(status);
|
| 1596 |
if (status.equals(VisitStatus.approved)) {
|
1597 |
visitRequest.setUpdatedTimestamp(LocalDateTime.now());
|
| 1597 |
visitRequest.setApprovedTimestamp(LocalDateTime.now());
|
1598 |
if (status.equals(VisitStatus.approved)) {
|
| 1598 |
}
|
1599 |
visitRequest.setApprovedTimestamp(LocalDateTime.now());
|
| 1599 |
|
1600 |
}
|
| 1600 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
1601 |
|
| 1601 |
sendNotificationModel.setCampaignName("Visit Request");
|
1602 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 1602 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
1603 |
sendNotificationModel.setCampaignName("Visit Request");
|
| 1603 |
sendNotificationModel.setTitle("Visit Request");
|
1604 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 1604 |
String message = "Visit Request has been " + status + " for scheduled time on "
|
1605 |
sendNotificationModel.setTitle("Visit Request");
|
| 1605 |
+ visitRequest.getScheduleTimestamp().toLocalDate();
|
1606 |
String message = "Visit Request has been " + status + " for scheduled time on "
|
| 1606 |
|
1607 |
+ visitRequest.getScheduleTimestamp().toLocalDate();
|
| 1607 |
sendNotificationModel.setMessage(message);
|
1608 |
|
| 1608 |
sendNotificationModel.setMessageType(MessageType.notification);
|
1609 |
sendNotificationModel.setMessage(message);
|
| 1609 |
User user = userRepository.selectByEmailId(gmailId);
|
1610 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 1610 |
sendNotificationModel.setUserIds(new ArrayList<>(user.getId()));
|
1611 |
User user = userRepository.selectByEmailId(gmailId);
|
| - |
|
1612 |
sendNotificationModel.setUserIds(new ArrayList<>(user.getId()));
|
| 1611 |
|
1613 |
|
| 1612 |
notificationService.sendNotificationToAll(sendNotificationModel);
|
1614 |
notificationService.sendNotificationToAll(sendNotificationModel);
|
| 1613 |
|
1615 |
|
| 1614 |
return responseSender.ok(true);
|
1616 |
return responseSender.ok(true);
|
| 1615 |
|
1617 |
|
| 1616 |
}
|
1618 |
}
|
| 1617 |
|
1619 |
|
| 1618 |
}
|
1620 |
}
|
| 1619 |
|
1621 |
|