| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.time.LocalDateTime;
|
| - |
|
4 |
import java.util.ArrayList;
|
| - |
|
5 |
import java.util.HashMap;
|
| 3 |
import java.util.List;
|
6 |
import java.util.List;
|
| - |
|
7 |
import java.util.Map;
|
| 4 |
|
8 |
|
| 5 |
import javax.servlet.http.HttpServletRequest;
|
9 |
import javax.servlet.http.HttpServletRequest;
|
| 6 |
|
10 |
|
| 7 |
import org.apache.logging.log4j.LogManager;
|
11 |
import org.apache.logging.log4j.LogManager;
|
| 8 |
import org.apache.logging.log4j.Logger;
|
12 |
import org.apache.logging.log4j.Logger;
|
| Line 13... |
Line 17... |
| 13 |
import org.springframework.web.bind.annotation.RequestMapping;
|
17 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 14 |
import org.springframework.web.bind.annotation.RequestMethod;
|
18 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 15 |
import org.springframework.web.bind.annotation.RequestParam;
|
19 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 16 |
|
20 |
|
| 17 |
import com.google.gson.Gson;
|
21 |
import com.google.gson.Gson;
|
| - |
|
22 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 18 |
import com.spice.profitmandi.dao.entity.dtr.GpsLocation;
|
23 |
import com.spice.profitmandi.dao.entity.dtr.GpsLocation;
|
| 19 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
24 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 20 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
25 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 21 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
26 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 22 |
import com.spice.profitmandi.dao.repository.user.GpsLocationRepository;
|
27 |
import com.spice.profitmandi.dao.repository.user.GpsLocationRepository;
|
| Line 27... |
Line 32... |
| 27 |
|
32 |
|
| 28 |
private static final Logger LOGGER = LogManager.getLogger(PostOfficeController.class);
|
33 |
private static final Logger LOGGER = LogManager.getLogger(PostOfficeController.class);
|
| 29 |
|
34 |
|
| 30 |
@Autowired
|
35 |
@Autowired
|
| 31 |
GpsLocationRepository gpsLocationRepository;
|
36 |
GpsLocationRepository gpsLocationRepository;
|
| 32 |
|
37 |
|
| 33 |
@Autowired
|
38 |
@Autowired
|
| 34 |
UserRepository userRepository;
|
39 |
UserRepository userRepository;
|
| 35 |
|
40 |
|
| 36 |
@Autowired
|
41 |
@Autowired
|
| 37 |
AuthRepository authRepository;
|
42 |
AuthRepository authRepository;
|
| 38 |
|
- |
|
| 39 |
|
43 |
|
| 40 |
@Autowired
|
44 |
@Autowired
|
| 41 |
Gson gson;
|
45 |
Gson gson;
|
| - |
|
46 |
|
| - |
|
47 |
@RequestMapping(value = "/authUserMapInfo", method = RequestMethod.GET)
|
| - |
|
48 |
public String AuthUserMapInfo(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
49 |
|
| - |
|
50 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| - |
|
51 |
|
| - |
|
52 |
model.addAttribute("authUsers", authUsers);
|
| - |
|
53 |
return "map-info";
|
| 42 |
|
54 |
}
|
| - |
|
55 |
|
| 43 |
@RequestMapping(value = "/map", method = RequestMethod.GET)
|
56 |
@RequestMapping(value = "/map", method = RequestMethod.GET)
|
| 44 |
public String getByPin(HttpServletRequest request, @RequestParam String email, Model model) throws Exception {
|
57 |
public String getByPin(HttpServletRequest request, @RequestParam List<String> emails,
|
| - |
|
58 |
@RequestParam LocalDateTime date, Model model) throws Exception {
|
| - |
|
59 |
Map<Integer, List<GpsLocation>> userIdAndLocationMap = new HashMap<>();
|
| - |
|
60 |
List<User> users = new ArrayList<>();
|
| - |
|
61 |
for (String email : emails) {
|
| 45 |
User dtrUser = userRepository.selectByEmailId(email);
|
62 |
User dtrUser = userRepository.selectByEmailId(email);
|
| - |
|
63 |
|
| 46 |
List<GpsLocation> locations = gpsLocationRepository.selectAllByUserIdAndDate(dtrUser.getId(), null);
|
64 |
List<GpsLocation> locations = gpsLocationRepository.selectAllByUserIdAndDate(dtrUser.getId(),
|
| - |
|
65 |
date.toLocalDate());
|
| - |
|
66 |
if (!locations.isEmpty()) {
|
| - |
|
67 |
userIdAndLocationMap.put(dtrUser.getId(), locations);
|
| - |
|
68 |
users.add(dtrUser);
|
| - |
|
69 |
}
|
| - |
|
70 |
}
|
| 47 |
LOGGER.info("locations {}", locations);
|
71 |
LOGGER.info("locations {}", gson.toJson(userIdAndLocationMap));
|
| - |
|
72 |
model.addAttribute("userLocationMap", gson.toJson(userIdAndLocationMap));
|
| 48 |
model.addAttribute("locations", locations);
|
73 |
model.addAttribute("users", gson.toJson(users));
|
| 49 |
return "map-index";
|
74 |
return "map-index";
|
| 50 |
}
|
75 |
}
|
| 51 |
|
76 |
|
| 52 |
}
|
77 |
}
|