| 21615 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 23568 |
govind |
3 |
import java.io.IOException;
|
|
|
4 |
import java.net.URISyntaxException;
|
| 24288 |
amit.gupta |
5 |
import java.time.DayOfWeek;
|
|
|
6 |
import java.time.LocalDate;
|
| 24276 |
amit.gupta |
7 |
import java.time.LocalDateTime;
|
| 24880 |
govind |
8 |
import java.time.LocalTime;
|
| 24288 |
amit.gupta |
9 |
import java.time.temporal.TemporalAdjusters;
|
| 24339 |
amit.gupta |
10 |
import java.util.ArrayList;
|
| 24880 |
govind |
11 |
import java.util.HashMap;
|
| 23884 |
amit.gupta |
12 |
import java.util.List;
|
| 24880 |
govind |
13 |
import java.util.Map;
|
|
|
14 |
import java.util.Set;
|
|
|
15 |
import java.util.function.IntFunction;
|
|
|
16 |
import java.util.function.IntPredicate;
|
|
|
17 |
import java.util.stream.Collectors;
|
| 23568 |
govind |
18 |
|
| 22086 |
amit.gupta |
19 |
import javax.servlet.http.HttpServletRequest;
|
|
|
20 |
|
| 23786 |
amit.gupta |
21 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
22 |
import org.apache.logging.log4j.Logger;
|
| 24321 |
amit.gupta |
23 |
import org.json.JSONArray;
|
|
|
24 |
import org.json.JSONObject;
|
| 22481 |
ashik.ali |
25 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23379 |
ashik.ali |
26 |
import org.springframework.beans.factory.annotation.Value;
|
| 21615 |
kshitij.so |
27 |
import org.springframework.stereotype.Controller;
|
| 22481 |
ashik.ali |
28 |
import org.springframework.transaction.annotation.Transactional;
|
| 22073 |
ashik.ali |
29 |
import org.springframework.ui.Model;
|
| 21615 |
kshitij.so |
30 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
31 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 24098 |
tejbeer |
32 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21615 |
kshitij.so |
33 |
|
| 24996 |
amit.gupta |
34 |
import com.mongodb.DBObject;
|
| 24880 |
govind |
35 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
| 22481 |
ashik.ali |
36 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24996 |
amit.gupta |
37 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
| 24203 |
amit.gupta |
38 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 24880 |
govind |
39 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
|
|
40 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| 24098 |
tejbeer |
41 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
| 24880 |
govind |
42 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
|
|
43 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 22654 |
ashik.ali |
44 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 24288 |
amit.gupta |
45 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 24880 |
govind |
46 |
import com.spice.profitmandi.dao.enumuration.dtr.RechargeType;
|
|
|
47 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 22481 |
ashik.ali |
48 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24880 |
govind |
49 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
|
|
50 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
| 24996 |
amit.gupta |
51 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 24098 |
tejbeer |
52 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
| 24880 |
govind |
53 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| 24203 |
amit.gupta |
54 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24880 |
govind |
55 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 24288 |
amit.gupta |
56 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 24336 |
amit.gupta |
57 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 23844 |
amit.gupta |
58 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 23884 |
amit.gupta |
59 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
|
|
60 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 22481 |
ashik.ali |
61 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
62 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24263 |
tejbeer |
63 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22481 |
ashik.ali |
64 |
|
| 21615 |
kshitij.so |
65 |
@Controller
|
| 22481 |
ashik.ali |
66 |
@Transactional(rollbackFor = Throwable.class)
|
| 21615 |
kshitij.so |
67 |
public class DashboardController {
|
| 23923 |
amit.gupta |
68 |
|
| 23379 |
ashik.ali |
69 |
@Value("${web.api.host}")
|
|
|
70 |
private String webApiHost;
|
| 23923 |
amit.gupta |
71 |
|
| 24072 |
amit.gupta |
72 |
@Value("${web.api.scheme}")
|
|
|
73 |
private String webApiScheme;
|
| 24288 |
amit.gupta |
74 |
|
| 24078 |
amit.gupta |
75 |
@Value("${web.api.root}")
|
|
|
76 |
private String webApiRoot;
|
|
|
77 |
|
| 23379 |
ashik.ali |
78 |
@Value("${web.api.port}")
|
|
|
79 |
private int webApiPort;
|
| 21615 |
kshitij.so |
80 |
|
| 22481 |
ashik.ali |
81 |
@Autowired
|
| 22927 |
ashik.ali |
82 |
private CookiesProcessor cookiesProcessor;
|
| 23923 |
amit.gupta |
83 |
|
| 23568 |
govind |
84 |
@Autowired
|
| 24880 |
govind |
85 |
private ItemRepository itemRepository;
|
|
|
86 |
|
|
|
87 |
@Autowired
|
| 23786 |
amit.gupta |
88 |
private RoleManager roleManager;
|
| 23923 |
amit.gupta |
89 |
|
| 23838 |
ashik.ali |
90 |
@Autowired
|
|
|
91 |
private FofoStoreRepository fofoStoreRepository;
|
| 23884 |
amit.gupta |
92 |
|
|
|
93 |
@Autowired
|
| 24880 |
govind |
94 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 23923 |
amit.gupta |
95 |
|
| 23884 |
amit.gupta |
96 |
@Autowired
|
| 24880 |
govind |
97 |
private PartnerInvestmentService partnerInvestmentService;
|
| 24288 |
amit.gupta |
98 |
|
| 23884 |
amit.gupta |
99 |
@Autowired
|
| 24880 |
govind |
100 |
private InsurancePolicyRepository insurancePolicyRepository;
|
| 23923 |
amit.gupta |
101 |
/*
|
|
|
102 |
* @Autowired private ScanRepository scanRepository;
|
|
|
103 |
*/
|
| 24880 |
govind |
104 |
@Autowired
|
|
|
105 |
private RechargeTransactionRepository rechargeTransactionRepository;
|
| 23923 |
amit.gupta |
106 |
|
| 23884 |
amit.gupta |
107 |
@Autowired
|
|
|
108 |
private TransactionService transactionService;
|
| 24996 |
amit.gupta |
109 |
|
|
|
110 |
@Autowired
|
|
|
111 |
private InventoryService inventoryService;
|
| 24263 |
tejbeer |
112 |
|
| 24098 |
tejbeer |
113 |
@Autowired
|
| 24263 |
tejbeer |
114 |
private MVCResponseSender mvcResponseSender;
|
|
|
115 |
|
|
|
116 |
@Autowired
|
| 24098 |
tejbeer |
117 |
private NotificationPanelRepository notificationPanelRepository;
|
| 23923 |
amit.gupta |
118 |
|
| 24203 |
amit.gupta |
119 |
@Autowired
|
|
|
120 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
121 |
|
| 24880 |
govind |
122 |
@Autowired
|
|
|
123 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
|
|
124 |
|
|
|
125 |
@Autowired
|
|
|
126 |
private InsuranceProviderRepository insuranceProviderRepository;
|
| 24996 |
amit.gupta |
127 |
|
|
|
128 |
@Autowired
|
|
|
129 |
private Mongo mongoClient;
|
| 24880 |
govind |
130 |
|
| 23568 |
govind |
131 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 23923 |
amit.gupta |
132 |
|
| 21615 |
kshitij.so |
133 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 24312 |
amit.gupta |
134 |
public String dashboard(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24098 |
tejbeer |
135 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 23923 |
amit.gupta |
136 |
throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
|
|
137 |
// LOGGER.info("scanRepository.selectScansByInventoryItemId(1)",
|
|
|
138 |
// scanRepository.selectScansByInventoryItemId(1));
|
| 23884 |
amit.gupta |
139 |
LOGGER.info("In Dashboard");
|
| 22927 |
ashik.ali |
140 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23923 |
amit.gupta |
141 |
|
| 22481 |
ashik.ali |
142 |
FofoStore fofoStore = null;
|
|
|
143 |
try {
|
| 22927 |
ashik.ali |
144 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 22481 |
ashik.ali |
145 |
} catch (ProfitMandiBusinessException e) {
|
| 22927 |
ashik.ali |
146 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
| 22481 |
ashik.ali |
147 |
}
|
| 23884 |
amit.gupta |
148 |
|
| 24312 |
amit.gupta |
149 |
float sale = 0;
|
| 23923 |
amit.gupta |
150 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
| 24263 |
tejbeer |
151 |
model.addAttribute("sale", sale);
|
|
|
152 |
List<NotificationData> notificationData = null;
|
|
|
153 |
long size = 0;
|
|
|
154 |
|
|
|
155 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
|
|
156 |
size = notificationPanelRepository.selectAllCount();
|
|
|
157 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
158 |
|
|
|
159 |
LOGGER.info("notification_data {}", size);
|
| 24880 |
govind |
160 |
// Map<String, Object> saleSummary=this.getAllSaleDetails(loginDetails);
|
|
|
161 |
// model.addAllAttributes(saleSummary);
|
| 24263 |
tejbeer |
162 |
if (!notificationData.isEmpty()) {
|
|
|
163 |
|
|
|
164 |
model.addAttribute("notificationData", notificationData);
|
|
|
165 |
LOGGER.info("notificationdata", notificationData);
|
|
|
166 |
model.addAttribute("start", offset + 1);
|
|
|
167 |
model.addAttribute("size", size);
|
|
|
168 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
169 |
|
|
|
170 |
LOGGER.info("start {}", offset + 1);
|
|
|
171 |
LOGGER.info("SIZE {}", size);
|
|
|
172 |
|
|
|
173 |
if (notificationData.size() < limit) {
|
|
|
174 |
model.addAttribute("end", offset + notificationData.size());
|
|
|
175 |
LOGGER.info("SIZE2 {}", offset + notificationData.size());
|
|
|
176 |
} else {
|
|
|
177 |
model.addAttribute("end", offset + limit);
|
|
|
178 |
|
|
|
179 |
LOGGER.info("end {}", size);
|
|
|
180 |
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
} else {
|
|
|
184 |
|
|
|
185 |
model.addAttribute("notificationData", notificationData);
|
|
|
186 |
model.addAttribute("size", size);
|
|
|
187 |
LOGGER.info("sizeOriginal {}", size);
|
|
|
188 |
|
|
|
189 |
}
|
| 23923 |
amit.gupta |
190 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
| 24312 |
amit.gupta |
191 |
|
| 24263 |
tejbeer |
192 |
List<NotificationData> notificationData = null;
|
|
|
193 |
long size = 0;
|
|
|
194 |
|
|
|
195 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
|
|
196 |
size = notificationPanelRepository.selectCountByActiveFlag(true);
|
|
|
197 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
198 |
|
|
|
199 |
LOGGER.info("notification_data {}", size);
|
|
|
200 |
|
| 24880 |
govind |
201 |
///// DashBoard ......................///////
|
|
|
202 |
model.addAllAttributes(this.getAllInsuranceDetails(loginDetails.getFofoId()));
|
|
|
203 |
model.addAllAttributes(this.getAllRechargeDetails(loginDetails.getFofoId()));
|
|
|
204 |
model.addAllAttributes(this.getAllSaleDetails(loginDetails.getFofoId()));
|
|
|
205 |
model.addAttribute("fofoId", loginDetails.getFofoId());
|
|
|
206 |
///////////////////////////////
|
| 24263 |
tejbeer |
207 |
if (!notificationData.isEmpty()) {
|
|
|
208 |
|
|
|
209 |
model.addAttribute("notificationData", notificationData);
|
|
|
210 |
LOGGER.info("notificationdata", notificationData);
|
|
|
211 |
model.addAttribute("start", offset + 1);
|
|
|
212 |
model.addAttribute("size", size);
|
|
|
213 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
214 |
|
|
|
215 |
LOGGER.info("start {}", offset + 1);
|
|
|
216 |
LOGGER.info("SIZE {}", size);
|
|
|
217 |
|
|
|
218 |
if (notificationData.size() < limit) {
|
|
|
219 |
model.addAttribute("end", offset + notificationData.size());
|
|
|
220 |
LOGGER.info("SIZE2 {}", offset + notificationData.size());
|
|
|
221 |
} else {
|
|
|
222 |
model.addAttribute("end", offset + limit);
|
|
|
223 |
|
|
|
224 |
LOGGER.info("end {}", size);
|
|
|
225 |
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
} else {
|
|
|
229 |
|
|
|
230 |
model.addAttribute("notificationData", notificationData);
|
|
|
231 |
model.addAttribute("size", size);
|
|
|
232 |
LOGGER.info("sizeOriginal {}", size);
|
|
|
233 |
|
|
|
234 |
}
|
| 23884 |
amit.gupta |
235 |
}
|
| 24880 |
govind |
236 |
|
| 24366 |
amit.gupta |
237 |
boolean isInvestmentOk = partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(), 10, 30);
|
| 24288 |
amit.gupta |
238 |
LocalDate endDate = LocalDate.now().minusDays(1);
|
|
|
239 |
LocalDate weekStartDate = endDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
| 24336 |
amit.gupta |
240 |
LocalDate startDate = weekStartDate.minusWeeks(2);
|
| 24339 |
amit.gupta |
241 |
List<PartnerDailyInvestment> partnerInvestments = new ArrayList<>();
|
| 24880 |
govind |
242 |
try {
|
|
|
243 |
partnerInvestments.add(partnerInvestmentService.getInvestment(loginDetails.getFofoId(), 1));
|
|
|
244 |
partnerInvestments
|
|
|
245 |
.addAll(partnerDailyInvestmentRepository.selectAll(loginDetails.getFofoId(), startDate, endDate));
|
|
|
246 |
|
|
|
247 |
} catch (Exception e) {
|
| 24383 |
amit.gupta |
248 |
LOGGER.error("partner Investment can't exists");
|
|
|
249 |
}
|
| 24996 |
amit.gupta |
250 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(loginDetails.getFofoId());
|
|
|
251 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(loginDetails.getFofoId(), loginDetails.getEmailId(), 3);
|
|
|
252 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
|
|
253 |
mobileBrands.stream().forEach(x->{
|
| 24999 |
amit.gupta |
254 |
String brand = (String)x.get("name");
|
| 24996 |
amit.gupta |
255 |
if(brandStockPricesMap.containsKey(brand)) {
|
|
|
256 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
|
|
257 |
brandStockPrice.setBrandUrl((String)x.get("url"));
|
| 25003 |
amit.gupta |
258 |
brandStockPrice.setRank(((Double)x.get("rank")).intValue());
|
| 24996 |
amit.gupta |
259 |
brandStockPrices.add(brandStockPrice);
|
|
|
260 |
} else {
|
|
|
261 |
}
|
|
|
262 |
});
|
|
|
263 |
model.addAttribute("brandStockPrices", brandStockPrices.stream().sorted((x,y)-> y.getRank() - x.getRank()).collect(Collectors.toList()));
|
| 24366 |
amit.gupta |
264 |
model.addAttribute("isInvestmentOk", isInvestmentOk || roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 24387 |
amit.gupta |
265 |
model.addAttribute("partnerInvestment", partnerInvestments.get(0));
|
| 24996 |
amit.gupta |
266 |
//model.addAttribute("investmentChart", this.getInvestmentChartData(partnerInvestments));
|
| 23848 |
ashik.ali |
267 |
model.addAttribute("fofoStore", fofoStore);
|
| 23918 |
amit.gupta |
268 |
model.addAttribute("walletAmount");
|
| 22086 |
amit.gupta |
269 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 23796 |
amit.gupta |
270 |
model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 23379 |
ashik.ali |
271 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
272 |
model.addAttribute("webApiPort", webApiPort);
|
| 24072 |
amit.gupta |
273 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 24077 |
amit.gupta |
274 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 24203 |
amit.gupta |
275 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
|
|
276 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 24248 |
govind |
277 |
model.addAttribute("sale", sale);
|
| 24098 |
tejbeer |
278 |
|
| 23923 |
amit.gupta |
279 |
// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
|
|
280 |
// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
| 21615 |
kshitij.so |
281 |
return "dashboard";
|
|
|
282 |
}
|
| 23923 |
amit.gupta |
283 |
|
| 24312 |
amit.gupta |
284 |
private String getInvestmentChartData(List<PartnerDailyInvestment> partnerInvestments) {
|
| 24880 |
govind |
285 |
|
| 24321 |
amit.gupta |
286 |
JSONObject scale = new JSONObject().put("scaleLabel", new JSONObject().put("scaleLabel", "Amount in Rs"));
|
| 24880 |
govind |
287 |
JSONObject titleObject = new JSONObject().put("display", true).put("text", "Investment Overview").put("display",
|
|
|
288 |
true);
|
|
|
289 |
|
| 24321 |
amit.gupta |
290 |
JSONObject barData = new JSONObject();
|
| 24880 |
govind |
291 |
|
|
|
292 |
JSONObject walletStack = new JSONObject().put("backgroundColor", "rgba(255, 99, 132, 0.2)")
|
| 24323 |
amit.gupta |
293 |
.put("label", "Wallet").put("stack", "Stack1").put("data", new JSONArray());
|
| 24880 |
govind |
294 |
JSONObject inStockStack = new JSONObject().put("label", "In Stock")
|
|
|
295 |
.put("backgroundColor", "rgba(54, 162, 235, 0.2)").put("stack", "Stack1").put("data", new JSONArray());
|
|
|
296 |
JSONObject salesStack = new JSONObject().put("backgroundColor", "rgba(255, 206, 86, 0.2)").put("label", "Sales")
|
| 24325 |
amit.gupta |
297 |
.put("stack", "Stack1").put("data", new JSONArray());
|
| 24880 |
govind |
298 |
JSONObject grnPendingStack = new JSONObject().put("backgroundColor", "rgba(75, 192, 192, 0.2)")
|
| 24323 |
amit.gupta |
299 |
.put("label", "Grn Pending").put("stack", "Stack1").put("data", new JSONArray());
|
| 24880 |
govind |
300 |
JSONObject billingPendingStack = new JSONObject().put("backgroundColor", "rgba(153, 102, 255, 0.2)")
|
| 24323 |
amit.gupta |
301 |
.put("label", "Billing Pending").put("stack", "Stack1").put("data", new JSONArray());
|
| 24880 |
govind |
302 |
JSONObject inTransitStack = new JSONObject().put("backgroundColor", "rgba(255, 159, 64, 0.2)")
|
| 24324 |
amit.gupta |
303 |
.put("label", "Returned").put("stack", "Stack1").put("data", new JSONArray());
|
| 24880 |
govind |
304 |
|
|
|
305 |
JSONObject minInvestmentDataSet = new JSONObject().put("label", "Min. Ivestment").put("data", new JSONArray())
|
|
|
306 |
.put("type", "line");
|
| 24321 |
amit.gupta |
307 |
JSONArray dateLabels = new JSONArray();
|
| 24880 |
govind |
308 |
|
| 24312 |
amit.gupta |
309 |
for (PartnerDailyInvestment pdi : partnerInvestments) {
|
| 24321 |
amit.gupta |
310 |
dateLabels = dateLabels.put(pdi.getDate().toString());
|
| 24880 |
govind |
311 |
walletStack.getJSONArray("data").put((int) pdi.getWalletAmount());
|
|
|
312 |
inStockStack.getJSONArray("data").put((int) pdi.getInStockAmount());
|
|
|
313 |
salesStack.getJSONArray("data").put((int) pdi.getSalesAmount());
|
|
|
314 |
grnPendingStack.getJSONArray("data").put((int) pdi.getUnbilledAmount());
|
|
|
315 |
billingPendingStack.getJSONArray("data").put((int) pdi.getGrnPendingAmount());
|
|
|
316 |
inTransitStack.getJSONArray("data").put((int) pdi.getReturnInTransitAmount());
|
|
|
317 |
minInvestmentDataSet.getJSONArray("data").put((int) pdi.getMinInvestment());
|
| 24312 |
amit.gupta |
318 |
}
|
| 24880 |
govind |
319 |
|
|
|
320 |
JSONArray barDataSetsArray = new JSONArray().put(walletStack).put(inStockStack).put(salesStack)
|
|
|
321 |
.put(grnPendingStack).put(billingPendingStack).put(inTransitStack);
|
| 24321 |
amit.gupta |
322 |
barData.put("labels", dateLabels).put("datasets", barDataSetsArray);
|
| 24880 |
govind |
323 |
scale.put("yAxes", new JSONArray().put(new JSONObject().put("stacked", true))).put("xAxes",
|
|
|
324 |
new JSONArray().put(new JSONObject().put("stacked", true)));
|
| 24321 |
amit.gupta |
325 |
|
| 24880 |
govind |
326 |
JSONObject barOptions = new JSONObject().put("title", titleObject).put("responsive", true).put("scales", scale)
|
| 24321 |
amit.gupta |
327 |
.put("tooltips", new JSONObject().put("mode", "index").put("intersect", false));
|
| 24880 |
govind |
328 |
|
| 24321 |
amit.gupta |
329 |
JSONObject chartJSOn = new JSONObject().put("type", "bar").put("data", barData).put("options", barOptions);
|
|
|
330 |
return chartJSOn.toString();
|
| 24312 |
amit.gupta |
331 |
}
|
|
|
332 |
|
| 24288 |
amit.gupta |
333 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
334 |
private boolean hasGift(int fofoId) {
|
|
|
335 |
try {
|
| 24288 |
amit.gupta |
336 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
337 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
338 |
} catch (ProfitMandiBusinessException e) {
|
|
|
339 |
return false;
|
|
|
340 |
}
|
|
|
341 |
}
|
| 24288 |
amit.gupta |
342 |
|
| 24098 |
tejbeer |
343 |
@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
|
|
|
344 |
public String getPaginatedNotificationData(HttpServletRequest request,
|
|
|
345 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
346 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| 24263 |
tejbeer |
347 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24098 |
tejbeer |
348 |
|
| 24263 |
tejbeer |
349 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
350 |
List<NotificationData> notificationData = null;
|
| 24098 |
tejbeer |
351 |
|
| 24263 |
tejbeer |
352 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
| 24098 |
tejbeer |
353 |
|
| 24263 |
tejbeer |
354 |
LOGGER.info("notification_data {}", notificationData);
|
| 24098 |
tejbeer |
355 |
|
| 24263 |
tejbeer |
356 |
if (!notificationData.isEmpty()) {
|
| 24098 |
tejbeer |
357 |
|
| 24263 |
tejbeer |
358 |
model.addAttribute("notificationData", notificationData);
|
|
|
359 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
360 |
|
|
|
361 |
} else {
|
|
|
362 |
model.addAttribute("notificationData", notificationData);
|
|
|
363 |
|
|
|
364 |
}
|
|
|
365 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
|
|
366 |
|
|
|
367 |
List<NotificationData> notificationData = null;
|
|
|
368 |
|
|
|
369 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
|
|
370 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
371 |
|
|
|
372 |
if (!notificationData.isEmpty()) {
|
|
|
373 |
|
|
|
374 |
model.addAttribute("notificationData", notificationData);
|
|
|
375 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
376 |
|
|
|
377 |
} else {
|
|
|
378 |
model.addAttribute("notificationData", notificationData);
|
|
|
379 |
|
|
|
380 |
}
|
| 24098 |
tejbeer |
381 |
}
|
|
|
382 |
|
|
|
383 |
return "dashboard-paginated";
|
|
|
384 |
}
|
| 24288 |
amit.gupta |
385 |
|
| 22354 |
ashik.ali |
386 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 23923 |
amit.gupta |
387 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 22354 |
ashik.ali |
388 |
model.addAttribute("appContextPath", request.getContextPath());
|
|
|
389 |
return "contact-us";
|
|
|
390 |
}
|
| 23923 |
amit.gupta |
391 |
|
|
|
392 |
/*
|
|
|
393 |
* private List<PaymentOption> getPaymentOptions(int fofoId){ List<Integer>
|
|
|
394 |
* paymentOptionIds =
|
| 24288 |
amit.gupta |
395 |
* fofoPartnerPaymentOptionRepository.selectPaymentOptionIdsByFofoId(fofoId) ;
|
|
|
396 |
* if(paymentOptionIds.isEmpty()){ return new ArrayList<>(); } return
|
| 23923 |
amit.gupta |
397 |
* paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds)); }
|
|
|
398 |
*/
|
|
|
399 |
|
| 24263 |
tejbeer |
400 |
@RequestMapping(value = "/inactiveNotificationData", method = RequestMethod.POST)
|
|
|
401 |
public String inactiveNotificationData(HttpServletRequest request,
|
|
|
402 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
403 |
|
|
|
404 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
|
|
405 |
if (notificationData != null) {
|
|
|
406 |
|
|
|
407 |
notificationData.setActive(false);
|
|
|
408 |
LOGGER.info("notification" + notificationData);
|
|
|
409 |
notificationPanelRepository.persist(notificationData);
|
|
|
410 |
|
|
|
411 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
412 |
} else {
|
|
|
413 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
414 |
|
|
|
415 |
}
|
|
|
416 |
return "response";
|
|
|
417 |
}
|
|
|
418 |
|
|
|
419 |
@RequestMapping(value = "/activeNotificationData", method = RequestMethod.POST)
|
|
|
420 |
public String activeNotificationData(HttpServletRequest request,
|
|
|
421 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
422 |
|
|
|
423 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
|
|
424 |
if (notificationData != null) {
|
|
|
425 |
|
|
|
426 |
notificationData.setActive(true);
|
|
|
427 |
notificationData.setCreated_timestamp(LocalDateTime.now());
|
|
|
428 |
LOGGER.info("notification" + notificationData);
|
|
|
429 |
notificationPanelRepository.persist(notificationData);
|
|
|
430 |
|
|
|
431 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
432 |
} else {
|
|
|
433 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
434 |
|
|
|
435 |
}
|
|
|
436 |
return "response";
|
|
|
437 |
}
|
|
|
438 |
|
| 24880 |
govind |
439 |
private Map<String, Object> getAllInsuranceDetails(int fofoId) {
|
|
|
440 |
|
|
|
441 |
LocalDateTime currentDayStart = LocalDateTime.of(LocalDate.now(), LocalTime.of(00, 00));
|
|
|
442 |
LocalDateTime previousDayStart = currentDayStart.minusDays(1);
|
|
|
443 |
LocalDateTime currentDayEnd = LocalDateTime.now();
|
|
|
444 |
LocalDateTime currentMonthDayStart = LocalDateTime
|
|
|
445 |
.of(LocalDate.of(currentDayStart.getYear(), currentDayStart.getMonth(), 01), LocalTime.of(00, 00));
|
|
|
446 |
LocalDateTime previousDayEnd = currentDayStart.minusMinutes(1);
|
|
|
447 |
LocalDateTime previousMonthFirstDay = currentMonthDayStart.minusMonths(1);
|
|
|
448 |
LocalDateTime previousMonthLastDay = currentMonthDayStart.minusMinutes(1);
|
|
|
449 |
|
|
|
450 |
List<String> insuranceProviders = insuranceProviderRepository.selectAll().stream().map(x -> x.getName())
|
|
|
451 |
.collect(Collectors.toList());
|
|
|
452 |
|
|
|
453 |
Map<String, Object> map = new HashMap<>();
|
|
|
454 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository
|
|
|
455 |
.selectByRetailerIdAndBetweenCreatedTimeStamp(fofoId, previousMonthFirstDay, LocalDateTime.now());
|
|
|
456 |
|
|
|
457 |
Map<Integer, Double> currentMonthTotalInsurance = insurancePolicies.stream()
|
|
|
458 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
459 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
460 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
|
|
461 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
462 |
|
|
|
463 |
Map<Integer, Double> previousMonthTotalInsurance = insurancePolicies.stream()
|
|
|
464 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
465 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
|
|
466 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
|
|
467 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
468 |
|
|
|
469 |
Map<Integer, Double> currentDayTotalInsurance = insurancePolicies.stream().filter(
|
|
|
470 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
471 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
|
|
472 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
473 |
|
|
|
474 |
Map<Integer, Double> previousDayTotalInsurance = insurancePolicies.stream()
|
|
|
475 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
476 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
|
|
477 |
.collect(Collectors.groupingBy(InsurancePolicy::getRetailerId,
|
|
|
478 |
Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
479 |
|
|
|
480 |
IntFunction<String> intFunction = (providerId) -> {
|
|
|
481 |
try {
|
|
|
482 |
return insuranceProviderRepository.selectById(providerId).getName();
|
|
|
483 |
} catch (ProfitMandiBusinessException e1) {
|
|
|
484 |
// TODO Auto-generated catch block
|
|
|
485 |
return "";
|
|
|
486 |
}
|
|
|
487 |
};
|
|
|
488 |
Map<String, Double> currentMonthTotalInsuranceByPolicyName = insurancePolicies.stream()
|
|
|
489 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
490 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
491 |
.collect(Collectors.groupingBy(x -> {
|
|
|
492 |
return intFunction.apply(x.getProviderId());
|
|
|
493 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
494 |
|
|
|
495 |
Map<String, Double> previousMonthTotalInsuranceByPolicyName = insurancePolicies.stream()
|
|
|
496 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
497 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
|
|
498 |
.collect(Collectors.groupingBy(x -> {
|
|
|
499 |
return intFunction.apply(x.getProviderId());
|
|
|
500 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
501 |
|
|
|
502 |
Map<String, Double> previousDayTotalInsuranceByPolicyName = insurancePolicies.stream()
|
|
|
503 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
504 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
|
|
505 |
.collect(Collectors.groupingBy(x -> {
|
|
|
506 |
return intFunction.apply(x.getProviderId());
|
|
|
507 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
508 |
|
|
|
509 |
Map<String, Double> currentDayTotalInsuranceByPolicyName = insurancePolicies.stream().filter(
|
|
|
510 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
511 |
.collect(Collectors.groupingBy(x -> {
|
|
|
512 |
return intFunction.apply(x.getProviderId());
|
|
|
513 |
}, Collectors.summingDouble(InsurancePolicy::getSellingPrice)));
|
|
|
514 |
|
|
|
515 |
map.put("currentMonthTotalInsurance", currentMonthTotalInsurance);
|
|
|
516 |
map.put("previousMonthTotalInsurance", previousMonthTotalInsurance);
|
|
|
517 |
map.put("currentDayTotalInsurance", currentDayTotalInsurance);
|
|
|
518 |
map.put("previousDayTotalInsurance", previousDayTotalInsurance);
|
|
|
519 |
map.put("currentMonthTotalInsuranceByPolicyName", currentMonthTotalInsuranceByPolicyName);
|
|
|
520 |
map.put("previousMonthTotalInsuranceByPolicyName", previousMonthTotalInsuranceByPolicyName);
|
|
|
521 |
map.put("previousDayTotalInsuranceByPolicyName", previousDayTotalInsuranceByPolicyName);
|
|
|
522 |
map.put("currentDayTotalInsuranceByPolicyName", currentDayTotalInsuranceByPolicyName);
|
|
|
523 |
map.put("insuranceProviders", insuranceProviders);
|
|
|
524 |
return map;
|
|
|
525 |
}
|
|
|
526 |
|
|
|
527 |
private Map<String, Object> getAllRechargeDetails(int fofoId) {
|
|
|
528 |
|
|
|
529 |
LocalDateTime currentDayStart = LocalDateTime.of(LocalDate.now(), LocalTime.of(00, 00));
|
|
|
530 |
LocalDateTime previousDayStart = currentDayStart.minusDays(1);
|
|
|
531 |
LocalDateTime currentDayEnd = LocalDateTime.now();
|
|
|
532 |
LocalDateTime currentMonthDayStart = LocalDateTime
|
|
|
533 |
.of(LocalDate.of(currentDayStart.getYear(), currentDayStart.getMonth(), 01), LocalTime.of(00, 00));
|
|
|
534 |
LocalDateTime previousDayEnd = currentDayStart.minusMinutes(1);
|
|
|
535 |
LocalDateTime previousMonthFirstDay = currentMonthDayStart.minusMonths(1);
|
|
|
536 |
LocalDateTime previousMonthLastDay = currentMonthDayStart.minusMinutes(1);
|
|
|
537 |
|
|
|
538 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository
|
|
|
539 |
.getAllRechargeTransactionByCreatedTimeStamp(fofoId, previousMonthFirstDay, currentDayEnd).stream()
|
|
|
540 |
.filter(x -> x.getStatus().equals(RechargeStatus.SUCCESS)).collect(Collectors.toList());
|
|
|
541 |
|
|
|
542 |
LOGGER.info(rechargeTransactions);
|
|
|
543 |
Map<Integer, Double> currentMonthTotalRecharge = rechargeTransactions.stream()
|
|
|
544 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
545 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
546 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
|
|
547 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
548 |
LOGGER.info(currentMonthTotalRecharge);
|
|
|
549 |
Map<Integer, Double> previousMonthTotalRecharge = rechargeTransactions.stream()
|
|
|
550 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
551 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
|
|
552 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
|
|
553 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
554 |
|
|
|
555 |
LOGGER.info(previousMonthTotalRecharge);
|
|
|
556 |
Map<Integer, Double> currentDayTotalRecharge = rechargeTransactions.stream().filter(
|
|
|
557 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
558 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
|
|
559 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
560 |
|
|
|
561 |
Map<Integer, Double> previousDayTotalRecharge = rechargeTransactions.stream()
|
|
|
562 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
563 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
|
|
564 |
.collect(Collectors.groupingBy(RechargeTransaction::getRetailerId,
|
|
|
565 |
Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
566 |
|
|
|
567 |
Map<Object, Double> currentMonthTotalRechargeByRechargeType = rechargeTransactions.stream()
|
|
|
568 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
569 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
570 |
.collect(Collectors.groupingBy(x -> {
|
|
|
571 |
return x.getType();
|
|
|
572 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
573 |
|
|
|
574 |
Map<Object, Double> previosMonthTotalRechargeByRechargeType = rechargeTransactions.stream()
|
|
|
575 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
576 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
|
|
577 |
.collect(Collectors.groupingBy(x -> {
|
|
|
578 |
return x.getType();
|
|
|
579 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
580 |
|
|
|
581 |
Map<Object, Double> currentDayTotalRechargeByRechargeType = rechargeTransactions.stream().filter(
|
|
|
582 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
583 |
.collect(Collectors.groupingBy(x -> {
|
|
|
584 |
return x.getType();
|
|
|
585 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
586 |
|
|
|
587 |
Map<Object, Double> previousDayTotalRechargeByRechargeType = rechargeTransactions.stream()
|
|
|
588 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
589 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
|
|
590 |
.collect(Collectors.groupingBy(x -> {
|
|
|
591 |
return x.getType();
|
|
|
592 |
}, Collectors.summingDouble(RechargeTransaction::getAmount)));
|
|
|
593 |
|
|
|
594 |
LOGGER.info("previosMonthTotalRechargeByRechargeType" + previosMonthTotalRechargeByRechargeType);
|
|
|
595 |
Map<String, Object> map = new HashMap<>();
|
|
|
596 |
map.put("currentMonthTotalRecharge", currentMonthTotalRecharge);
|
|
|
597 |
map.put("previousMonthTotalRecharge", previousMonthTotalRecharge);
|
|
|
598 |
map.put("currentDayTotalRecharge", currentDayTotalRecharge);
|
|
|
599 |
map.put("previousDayTotalRecharge", previousDayTotalRecharge);
|
|
|
600 |
map.put("currentMonthTotalRechargeByRechargeType", currentMonthTotalRechargeByRechargeType);
|
|
|
601 |
map.put("previosMonthTotalRechargeByRechargeType", previosMonthTotalRechargeByRechargeType);
|
|
|
602 |
map.put("currentDayTotalRechargeByRechargeType", currentDayTotalRechargeByRechargeType);
|
|
|
603 |
map.put("previousDayTotalRechargeByRechargeType", previousDayTotalRechargeByRechargeType);
|
|
|
604 |
map.put("rechargeTypes", RechargeType.values());
|
|
|
605 |
|
|
|
606 |
return map;
|
|
|
607 |
|
|
|
608 |
}
|
|
|
609 |
|
|
|
610 |
private Map<String, Object> getAllSaleDetails(int fofoId) {
|
|
|
611 |
|
|
|
612 |
LocalDateTime currentDayStart = LocalDateTime.of(LocalDate.now(), LocalTime.of(00, 00));
|
|
|
613 |
LocalDateTime previousDayStart = currentDayStart.minusDays(1);
|
|
|
614 |
LocalDateTime currentDayEnd = LocalDateTime.now();
|
|
|
615 |
LocalDateTime currentMonthDayStart = LocalDateTime
|
|
|
616 |
.of(LocalDate.of(currentDayStart.getYear(), currentDayStart.getMonth(), 01), LocalTime.of(00, 00));
|
|
|
617 |
LocalDateTime previousDayEnd = currentDayStart.minusMinutes(1);
|
|
|
618 |
LocalDateTime previousMonthFirstDay = currentMonthDayStart.minusMonths(1);
|
|
|
619 |
LocalDateTime previousMonthLastDay = currentMonthDayStart.minusMinutes(1);
|
|
|
620 |
|
|
|
621 |
Map<String, Object> map = new HashMap<>();
|
|
|
622 |
|
|
|
623 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId,
|
|
|
624 |
previousMonthFirstDay, currentDayEnd);
|
|
|
625 |
|
|
|
626 |
Double currentMonthTotalSale = fofoOrderItems.stream()
|
|
|
627 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
628 |
&& x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
629 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
630 |
|
|
|
631 |
LOGGER.info("currentMonthTotalSale" + currentMonthTotalSale);
|
|
|
632 |
Double previousMonthTotalSale = fofoOrderItems.stream()
|
|
|
633 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
634 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay))
|
|
|
635 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
636 |
|
|
|
637 |
Double currentDayTotalSale = fofoOrderItems.stream().filter(
|
|
|
638 |
x -> x.getCreateTimestamp().isAfter(currentDayStart) && x.getCreateTimestamp().isBefore(currentDayEnd))
|
|
|
639 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
640 |
|
|
|
641 |
LOGGER.info(currentDayTotalSale);
|
|
|
642 |
|
|
|
643 |
Double previousDayTotalSale = fofoOrderItems.stream()
|
|
|
644 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
645 |
&& x.getCreateTimestamp().isBefore(previousDayEnd))
|
|
|
646 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
647 |
LOGGER.info(previousDayTotalSale);
|
|
|
648 |
IntPredicate checkHandset = (itemId) -> {
|
|
|
649 |
try {
|
|
|
650 |
Item item = itemRepository.selectById(itemId);
|
|
|
651 |
return item.getCategoryId() == 10006;
|
|
|
652 |
} catch (ProfitMandiBusinessException e) {
|
|
|
653 |
// TODO Auto-generated catch block
|
|
|
654 |
e.printStackTrace();
|
|
|
655 |
return false;
|
|
|
656 |
}
|
|
|
657 |
};
|
|
|
658 |
|
|
|
659 |
Set<String> brands = fofoOrderItemRepository
|
|
|
660 |
.selectBetweenDates(previousMonthFirstDay.minusMonths(1), currentDayEnd).stream()
|
|
|
661 |
.filter(x -> checkHandset.test(x.getItemId())).map(x -> x.getBrand()).collect(Collectors.toSet());
|
|
|
662 |
Set<String> accessories = fofoOrderItemRepository
|
|
|
663 |
.selectBetweenDates(previousMonthFirstDay.minusMonths(1), currentDayEnd).stream()
|
|
|
664 |
.filter(x -> !checkHandset.test(x.getItemId())).map(x -> x.getBrand()).collect(Collectors.toSet());
|
|
|
665 |
|
|
|
666 |
Double currentMonthTotalMobileSale = fofoOrderItems.stream()
|
|
|
667 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
668 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
669 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
670 |
|
|
|
671 |
Double previousMonthTotalMobileSale = fofoOrderItems.stream()
|
|
|
672 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
673 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && checkHandset.test(x.getItemId()))
|
|
|
674 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
675 |
|
|
|
676 |
Double previousDayTotalMobileSale = fofoOrderItems.stream()
|
|
|
677 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
678 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
679 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
680 |
|
|
|
681 |
Double currentDayTotalMobileSale = fofoOrderItems.stream()
|
|
|
682 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
|
|
683 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
684 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
685 |
|
|
|
686 |
Double currentMonthTotalAccessoriesSale = fofoOrderItems.stream()
|
|
|
687 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
688 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
689 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
690 |
|
|
|
691 |
Double previousMonthTotalAccessoriesSale = fofoOrderItems.stream()
|
|
|
692 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
693 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && !checkHandset.test(x.getItemId()))
|
|
|
694 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
695 |
|
|
|
696 |
Double previousDayTotalAccessoriesSale = fofoOrderItems.stream()
|
|
|
697 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
698 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
699 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
700 |
|
|
|
701 |
Double currentDayTotalAccessoriesSale = fofoOrderItems.stream()
|
|
|
702 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
|
|
703 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
704 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
705 |
|
|
|
706 |
Map<String, Double> currentMonthMobileSalegroupByBrand = fofoOrderItems.stream()
|
|
|
707 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
708 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
709 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
710 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
711 |
|
|
|
712 |
Map<String, Double> currentMonthAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
|
|
713 |
.filter(x -> x.getCreateTimestamp().isAfter(currentMonthDayStart)
|
|
|
714 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
715 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
716 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
717 |
|
|
|
718 |
Map<String, Double> previousMonthAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
|
|
719 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
720 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && !checkHandset.test(x.getItemId()))
|
|
|
721 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
722 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
723 |
|
|
|
724 |
Map<String, Double> currentDayAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
|
|
725 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
|
|
726 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
727 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
728 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
729 |
|
|
|
730 |
Map<String, Double> previousDayAccesoriesSalegroupByBrand = fofoOrderItems.stream()
|
|
|
731 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
732 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && !checkHandset.test(x.getItemId()))
|
|
|
733 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
734 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
735 |
|
|
|
736 |
Map<String, Double> currentDayMobileSalegroupByBrand = fofoOrderItems.stream()
|
|
|
737 |
.filter(x -> x.getCreateTimestamp().isAfter(currentDayStart)
|
|
|
738 |
&& x.getCreateTimestamp().isBefore(currentDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
739 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
740 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
741 |
|
|
|
742 |
Map<String, Double> previousDayMobileSalegroupByBrand = fofoOrderItems.stream()
|
|
|
743 |
.filter(x -> x.getCreateTimestamp().isAfter(previousDayStart)
|
|
|
744 |
&& x.getCreateTimestamp().isBefore(previousDayEnd) && checkHandset.test(x.getItemId()))
|
|
|
745 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
746 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
747 |
Map<String, Double> previousMonthMobileSalegroupByBrand = fofoOrderItems.stream()
|
|
|
748 |
.filter(x -> x.getCreateTimestamp().isAfter(previousMonthFirstDay)
|
|
|
749 |
&& x.getCreateTimestamp().isBefore(previousMonthLastDay) && checkHandset.test(x.getItemId()))
|
|
|
750 |
.collect(Collectors.groupingBy(x -> x.getBrand(),
|
|
|
751 |
Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity())));
|
|
|
752 |
|
|
|
753 |
map.put("brands", brands);
|
|
|
754 |
map.put("accessories", accessories);
|
|
|
755 |
map.put("currentMonthTotalSale", currentMonthTotalSale);
|
|
|
756 |
map.put("previousMonthTotalSale", previousMonthTotalSale);
|
|
|
757 |
map.put("currentDayTotalSale", currentDayTotalSale);
|
|
|
758 |
map.put("previousDayTotalSale", previousDayTotalSale);
|
|
|
759 |
map.put("currentMonthMobileSalegroupByBrand", currentMonthMobileSalegroupByBrand);
|
|
|
760 |
map.put("currentMonthAccesoriesSalegroupByBrand", currentMonthAccesoriesSalegroupByBrand);
|
|
|
761 |
map.put("previousMonthAccesoriesSalegroupByBrand", previousMonthAccesoriesSalegroupByBrand);
|
|
|
762 |
map.put("previousDayAccesoriesSalegroupByBrand", previousDayAccesoriesSalegroupByBrand);
|
|
|
763 |
map.put("currentDayMobileSalegroupByBrand", currentDayMobileSalegroupByBrand);
|
|
|
764 |
map.put("previousDayMobileSalegroupByBrand", previousDayMobileSalegroupByBrand);
|
|
|
765 |
map.put("currentDayAccesoriesSalegroupByBrand", currentDayAccesoriesSalegroupByBrand);
|
|
|
766 |
map.put("previousMonthMobileSalegroupByBrand", previousMonthMobileSalegroupByBrand);
|
|
|
767 |
|
|
|
768 |
map.put("currentMonthTotalMobileSale", currentMonthTotalMobileSale);
|
|
|
769 |
map.put("previousMonthTotalMobileSale", previousMonthTotalMobileSale);
|
|
|
770 |
map.put("previousDayTotalMobileSale", previousDayTotalMobileSale);
|
|
|
771 |
map.put("currentDayTotalMobileSale", currentDayTotalMobileSale);
|
|
|
772 |
map.put("currentMonthTotalAccessoriesSale", currentMonthTotalAccessoriesSale);
|
|
|
773 |
map.put("previousMonthTotalAccessoriesSale", previousMonthTotalAccessoriesSale);
|
|
|
774 |
map.put("previousDayTotalAccessoriesSale", previousDayTotalAccessoriesSale);
|
|
|
775 |
map.put("currentDayTotalAccessoriesSale", currentDayTotalAccessoriesSale);
|
|
|
776 |
|
|
|
777 |
return map;
|
|
|
778 |
}
|
| 21615 |
kshitij.so |
779 |
}
|