| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.text.DecimalFormat;
|
| 3 |
import java.time.LocalDate;
|
4 |
import java.time.LocalDate;
|
| 4 |
import java.time.LocalDateTime;
|
5 |
import java.time.LocalDateTime;
|
| 5 |
import java.time.LocalTime;
|
6 |
import java.time.LocalTime;
|
| 6 |
import java.util.ArrayList;
|
7 |
import java.util.ArrayList;
|
| 7 |
import java.util.LinkedHashMap;
|
8 |
import java.util.LinkedHashMap;
|
| 8 |
import java.util.List;
|
9 |
import java.util.List;
|
| 9 |
import java.util.Map;
|
10 |
import java.util.Map;
|
| 10 |
import java.util.stream.Collectors;
|
11 |
import java.util.stream.Collectors;
|
| 11 |
|
12 |
|
| 12 |
import javax.servlet.http.HttpServletRequest;
|
13 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
14 |
import javax.transaction.Transactional;
|
| 13 |
|
15 |
|
| 14 |
import org.apache.logging.log4j.LogManager;
|
16 |
import org.apache.logging.log4j.LogManager;
|
| 15 |
import org.apache.logging.log4j.Logger;
|
17 |
import org.apache.logging.log4j.Logger;
|
| 16 |
import org.springframework.beans.factory.annotation.Autowired;
|
18 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 17 |
import org.springframework.beans.factory.annotation.Value;
|
19 |
import org.springframework.beans.factory.annotation.Value;
|
| 18 |
import org.springframework.stereotype.Controller;
|
20 |
import org.springframework.stereotype.Controller;
|
| 19 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 20 |
import org.springframework.ui.Model;
|
21 |
import org.springframework.ui.Model;
|
| 21 |
import org.springframework.web.bind.annotation.RequestMapping;
|
22 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 22 |
import org.springframework.web.bind.annotation.RequestMethod;
|
23 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 23 |
|
24 |
|
| 24 |
import com.mongodb.DBObject;
|
25 |
import com.mongodb.DBObject;
|
| Line 165... |
Line 166... |
| 165 |
investments.put("short", investment.getShortPercentage());
|
166 |
investments.put("short", investment.getShortPercentage());
|
| 166 |
investments.put("okDays", okInvestmentDays);
|
167 |
investments.put("okDays", okInvestmentDays);
|
| 167 |
return investments;
|
168 |
return investments;
|
| 168 |
}
|
169 |
}
|
| 169 |
|
170 |
|
| 170 |
private Map<String, Double> getSales(int fofoId) {
|
171 |
private Map<String, Object> getSales(int fofoId) {
|
| 171 |
Map<String, Double> salesMap = new LinkedHashMap<>();
|
172 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
| 172 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
173 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 173 |
int monthLength = LocalDate.now().lengthOfMonth();
|
174 |
int monthLength = LocalDate.now().lengthOfMonth();
|
| 174 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId, curDate,
|
175 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId, curDate,
|
| 175 |
curDate.with(LocalTime.MAX));
|
176 |
curDate.with(LocalTime.MAX));
|
| 176 |
List<FofoOrderItem> mtdFofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId,
|
177 |
List<FofoOrderItem> mtdFofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId,
|
| Line 190... |
Line 191... |
| 190 |
if (targetIds.size() > 0) {
|
191 |
if (targetIds.size() > 0) {
|
| 191 |
PartnerTarget target = partnerTargetRepository.selectAllPartnerTargetForPartner(fofoId, targetIds).get(0);
|
192 |
PartnerTarget target = partnerTargetRepository.selectAllPartnerTargetForPartner(fofoId, targetIds).get(0);
|
| 192 |
double targetValue = (double)target.getTargetValue();
|
193 |
double targetValue = (double)target.getTargetValue();
|
| 193 |
int remainingDays = monthLength - curDate.getDayOfMonth() + 1;
|
194 |
int remainingDays = monthLength - curDate.getDayOfMonth() + 1;
|
| 194 |
//Should not consider today's sale while evaluating today's target.
|
195 |
//Should not consider today's sale while evaluating today's target.
|
| 195 |
double todayTargetValue = Math.round((targetValue - (mtdSale-todaySale))/remainingDays);
|
196 |
double todayTargetValue = Math.round((targetValue - (mtdSale-todaySale))/remainingDays);
|
| - |
|
197 |
DecimalFormat df = new DecimalFormat("#.##");
|
| - |
|
198 |
String targetValueString = df.format(targetValue/100000) + "Lac";
|
| 196 |
salesMap.put("todayTarget", todayTargetValue);
|
199 |
salesMap.put("todayTarget", todayTargetValue);
|
| 197 |
salesMap.put("monthTarget", targetValue);
|
200 |
salesMap.put("monthTarget", targetValue);
|
| 198 |
} else {
|
201 |
} else {
|
| 199 |
salesMap.put("todayTarget", 0d);
|
202 |
salesMap.put("todayTarget", 0d);
|
| 200 |
salesMap.put("monthTarget", 0d);
|
203 |
salesMap.put("monthTarget", 0d);
|