| Line 56... |
Line 56... |
| 56 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
56 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
| 57 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
57 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 58 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
|
58 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
|
| 59 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
59 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 60 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
60 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| - |
|
61 |
import com.spice.profitmandi.dao.entity.cs.PartnerRegion;
|
| - |
|
62 |
import com.spice.profitmandi.dao.entity.cs.Region;
|
| 61 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
63 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 62 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
64 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 63 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
65 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 64 |
import com.spice.profitmandi.dao.entity.fofo.MonthlyPlanned;
|
66 |
import com.spice.profitmandi.dao.entity.fofo.MonthlyPlanned;
|
| 65 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
67 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| Line 74... |
Line 76... |
| 74 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
76 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 75 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
77 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
| 76 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
78 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 77 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
79 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
80 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| - |
|
81 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
| - |
|
82 |
import com.spice.profitmandi.dao.repository.cs.RegionRepository;
|
| 79 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
83 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 80 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
84 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 81 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
85 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 82 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
86 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 83 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
87 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| Line 225... |
Line 229... |
| 225 |
private SuggestedPoDetailRepository monthlyPoDetailRepository;
|
229 |
private SuggestedPoDetailRepository monthlyPoDetailRepository;
|
| 226 |
|
230 |
|
| 227 |
@Autowired
|
231 |
@Autowired
|
| 228 |
private NotificationService notificationService;
|
232 |
private NotificationService notificationService;
|
| 229 |
|
233 |
|
| - |
|
234 |
@Autowired
|
| - |
|
235 |
private RegionRepository regionRepository;
|
| - |
|
236 |
|
| - |
|
237 |
@Autowired
|
| - |
|
238 |
private PartnerRegionRepository partnerRegionRepository;
|
| - |
|
239 |
|
| 230 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
240 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
| 231 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
241 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
| 232 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
242 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
| 233 |
if(fofoId == 0) {
|
243 |
if (fofoId == 0) {
|
| 234 |
|
244 |
|
| 235 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
245 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 236 |
fofoId = loginDetails.getFofoId();
|
246 |
fofoId = loginDetails.getFofoId();
|
| 237 |
|
247 |
|
| 238 |
}
|
248 |
}
|
| 239 |
|
249 |
|
| 240 |
LocalDate currentMonthDate = LocalDate.now();
|
250 |
LocalDate currentMonthDate = LocalDate.now();
|
| 241 |
MonthlyPlanned monthlyPlanned = null;
|
251 |
MonthlyPlanned monthlyPlanned = null;
|
| 242 |
|
252 |
|
| 243 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
253 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
| 244 |
currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
254 |
currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| Line 562... |
Line 572... |
| 562 |
|
572 |
|
| 563 |
int totalPcs = 0;
|
573 |
int totalPcs = 0;
|
| 564 |
|
574 |
|
| 565 |
float totalAmount = 0;
|
575 |
float totalAmount = 0;
|
| 566 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
576 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
| 567 |
PartnerTypeChange ptc = partnerTypeChangeRepository.selectPartnerType(fofoId, LocalDate.now());
|
577 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
| 568 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByPartnerType(ptc.getPartnerType())
|
- |
|
| 569 |
.stream().collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
578 |
.collect(Collectors.toList());
|
| 570 |
|
579 |
|
| - |
|
580 |
LOGGER.info("regionIds" + regionIds);
|
| - |
|
581 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByRegionIds(regionIds).stream()
|
| - |
|
582 |
.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
| - |
|
583 |
LOGGER.info("focusedModelMap" + focusedModelMap);
|
| 571 |
LocalDate planningMonthDate = null;
|
584 |
LocalDate planningMonthDate = null;
|
| 572 |
MonthlyPlanned monthlyPlanned = null;
|
585 |
MonthlyPlanned monthlyPlanned = null;
|
| 573 |
List<Integer> fofoOrderIds = null;
|
586 |
List<Integer> fofoOrderIds = null;
|
| 574 |
LOGGER.info("localDate" + LocalDate.now());
|
587 |
LOGGER.info("localDate" + LocalDate.now());
|
| 575 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
588 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
| Line 814... |
Line 827... |
| 814 |
int totalPcs = 0;
|
827 |
int totalPcs = 0;
|
| 815 |
|
828 |
|
| 816 |
float totalAmount = 0;
|
829 |
float totalAmount = 0;
|
| 817 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
830 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
| 818 |
|
831 |
|
| 819 |
PartnerTypeChange ptc = partnerTypeChangeRepository.selectPartnerType(fofoId, LocalDate.now());
|
832 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
| - |
|
833 |
.collect(Collectors.toList());
|
| - |
|
834 |
|
| 820 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByPartnerType(ptc.getPartnerType())
|
835 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByRegionIds(regionIds).stream()
|
| 821 |
.stream().collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
836 |
.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
| 822 |
|
837 |
|
| 823 |
MonthlyPlanned monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId,
|
838 |
MonthlyPlanned monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId,
|
| 824 |
planMonthStart.minusMonths(1));
|
839 |
planMonthStart.minusMonths(1));
|
| 825 |
model.addAttribute("planningMonth", planMonthStart.minusMonths(1).getMonth());
|
840 |
model.addAttribute("planningMonth", planMonthStart.minusMonths(1).getMonth());
|
| 826 |
model.addAttribute("previousPlanningMonth", planMonthStart.minusMonths(1).getMonth());
|
841 |
model.addAttribute("previousPlanningMonth", planMonthStart.minusMonths(1).getMonth());
|
| Line 1138... |
Line 1153... |
| 1138 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
1153 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
| 1139 |
|
1154 |
|
| 1140 |
size = focusedModelRepository.selectAllCount();
|
1155 |
size = focusedModelRepository.selectAllCount();
|
| 1141 |
if (!focusedModels.isEmpty()) {
|
1156 |
if (!focusedModels.isEmpty()) {
|
| 1142 |
Map<Integer, Item> itemMap = this.getItemByCatalogId(focusedModels);
|
1157 |
Map<Integer, Item> itemMap = this.getItemByCatalogId(focusedModels);
|
| - |
|
1158 |
Map<Integer, Region> regionMap = this.getRegionByRegionId(focusedModels);
|
| 1143 |
|
1159 |
|
| - |
|
1160 |
LOGGER.info("regionMap" + regionMap);
|
| 1144 |
model.addAttribute("focusedModels", focusedModels);
|
1161 |
model.addAttribute("focusedModels", focusedModels);
|
| 1145 |
model.addAttribute("itemMap", itemMap);
|
1162 |
model.addAttribute("itemMap", itemMap);
|
| 1146 |
|
- |
|
| - |
|
1163 |
model.addAttribute("regionMap", regionMap);
|
| 1147 |
model.addAttribute("start", offset + 1);
|
1164 |
model.addAttribute("start", offset + 1);
|
| 1148 |
model.addAttribute("size", size);
|
1165 |
model.addAttribute("size", size);
|
| 1149 |
model.addAttribute("url", "/getPaginatedFocusedModel");
|
1166 |
model.addAttribute("url", "/getPaginatedFocusedModel");
|
| 1150 |
|
1167 |
|
| 1151 |
if (focusedModels.size() < limit) {
|
1168 |
if (focusedModels.size() < limit) {
|
| Line 1158... |
Line 1175... |
| 1158 |
model.addAttribute("walletRequest", focusedModels);
|
1175 |
model.addAttribute("walletRequest", focusedModels);
|
| 1159 |
model.addAttribute("size", size);
|
1176 |
model.addAttribute("size", size);
|
| 1160 |
|
1177 |
|
| 1161 |
}
|
1178 |
}
|
| 1162 |
|
1179 |
|
| - |
|
1180 |
List<Region> regions = regionRepository.selectAll();
|
| - |
|
1181 |
|
| 1163 |
model.addAttribute("partnerType", PartnerType.values());
|
1182 |
model.addAttribute("regions", regions);
|
| 1164 |
|
1183 |
|
| 1165 |
return "focused_model";
|
1184 |
return "focused_model";
|
| 1166 |
}
|
1185 |
}
|
| 1167 |
|
1186 |
|
| 1168 |
@RequestMapping(value = "/getPaginatedFocusedModel", method = RequestMethod.GET)
|
1187 |
@RequestMapping(value = "/getPaginatedFocusedModel", method = RequestMethod.GET)
|
| Line 1173... |
Line 1192... |
| 1173 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
1192 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
| 1174 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
1193 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
| 1175 |
|
1194 |
|
| 1176 |
if (!focusedModels.isEmpty()) {
|
1195 |
if (!focusedModels.isEmpty()) {
|
| 1177 |
Map<Integer, Item> itemMap = this.getItemByCatalogId(focusedModels);
|
1196 |
Map<Integer, Item> itemMap = this.getItemByCatalogId(focusedModels);
|
| 1178 |
|
- |
|
| - |
|
1197 |
Map<Integer, Region> regionMap = this.getRegionByRegionId(focusedModels);
|
| 1179 |
model.addAttribute("focusedModels", focusedModels);
|
1198 |
model.addAttribute("focusedModels", focusedModels);
|
| 1180 |
model.addAttribute("itemMap", itemMap);
|
1199 |
model.addAttribute("itemMap", itemMap);
|
| 1181 |
|
- |
|
| - |
|
1200 |
model.addAttribute("regionMap", regionMap);
|
| 1182 |
model.addAttribute("url", "/getPaginatedFocusedModel");
|
1201 |
model.addAttribute("url", "/getPaginatedFocusedModel");
|
| 1183 |
} else {
|
1202 |
} else {
|
| 1184 |
model.addAttribute("focusedModels", focusedModels);
|
1203 |
model.addAttribute("focusedModels", focusedModels);
|
| 1185 |
|
1204 |
|
| 1186 |
}
|
1205 |
}
|
| 1187 |
|
1206 |
|
| - |
|
1207 |
List<Region> regions = regionRepository.selectAll();
|
| - |
|
1208 |
|
| 1188 |
model.addAttribute("partnerType", PartnerType.values());
|
1209 |
model.addAttribute("regions", regions);
|
| 1189 |
return "focused-model-paginated";
|
1210 |
return "focused-model-paginated";
|
| 1190 |
}
|
1211 |
}
|
| 1191 |
|
1212 |
|
| 1192 |
private Map<Integer, Item> getItemByCatalogId(List<FocusedModel> focusedModels) {
|
1213 |
private Map<Integer, Item> getItemByCatalogId(List<FocusedModel> focusedModels) {
|
| 1193 |
Map<Integer, Item> itemMap = new HashMap<>();
|
1214 |
Map<Integer, Item> itemMap = new HashMap<>();
|
| Line 1197... |
Line 1218... |
| 1197 |
}
|
1218 |
}
|
| 1198 |
|
1219 |
|
| 1199 |
return itemMap;
|
1220 |
return itemMap;
|
| 1200 |
}
|
1221 |
}
|
| 1201 |
|
1222 |
|
| - |
|
1223 |
private Map<Integer, Region> getRegionByRegionId(List<FocusedModel> focusedModels) {
|
| - |
|
1224 |
Map<Integer, Region> regionMap = new HashMap<>();
|
| - |
|
1225 |
for (FocusedModel focusedModel : focusedModels) {
|
| - |
|
1226 |
Region region = regionRepository.selectById(focusedModel.getRegionId());
|
| - |
|
1227 |
regionMap.put(region.getId(), region);
|
| - |
|
1228 |
}
|
| - |
|
1229 |
|
| - |
|
1230 |
return regionMap;
|
| - |
|
1231 |
}
|
| - |
|
1232 |
|
| 1202 |
@RequestMapping(value = "/focusedModel", method = RequestMethod.POST)
|
1233 |
@RequestMapping(value = "/focusedModel", method = RequestMethod.POST)
|
| 1203 |
public String focusedModel(HttpServletRequest request, @RequestParam int catalogId, @RequestParam int recommended,
|
1234 |
public String focusedModel(HttpServletRequest request, @RequestParam int catalogId, @RequestParam int recommended,
|
| 1204 |
@RequestParam int minimumQty, @RequestParam PartnerType partnerType, Model model)
|
1235 |
@RequestParam int minimumQty, @RequestParam int regionId, Model model) throws ProfitMandiBusinessException {
|
| 1205 |
throws ProfitMandiBusinessException {
|
- |
|
| 1206 |
|
1236 |
|
| 1207 |
FocusedModel fm = new FocusedModel();
|
1237 |
FocusedModel fm = new FocusedModel();
|
| 1208 |
fm.setCatalogId(catalogId);
|
1238 |
fm.setCatalogId(catalogId);
|
| 1209 |
fm.setMinimumQty(minimumQty);
|
1239 |
fm.setMinimumQty(minimumQty);
|
| 1210 |
fm.setRecommendedQty(recommended);
|
1240 |
fm.setRecommendedQty(recommended);
|
| 1211 |
fm.setPartnerType(partnerType);
|
1241 |
fm.setRegionId(regionId);
|
| 1212 |
fm.setCreatedTimestamp(LocalDateTime.now());
|
1242 |
fm.setCreatedTimestamp(LocalDateTime.now());
|
| 1213 |
focusedModelRepository.persist(fm);
|
1243 |
focusedModelRepository.persist(fm);
|
| 1214 |
return "focused_model";
|
1244 |
return "focused_model";
|
| 1215 |
}
|
1245 |
}
|
| 1216 |
|
1246 |
|
| Line 1351... |
Line 1381... |
| 1351 |
|
1381 |
|
| 1352 |
int totalPcs = 0;
|
1382 |
int totalPcs = 0;
|
| 1353 |
|
1383 |
|
| 1354 |
float totalAmount = 0;
|
1384 |
float totalAmount = 0;
|
| 1355 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
1385 |
Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
|
| 1356 |
PartnerTypeChange ptc = partnerTypeChangeRepository.selectPartnerType(fofoId, LocalDate.now());
|
- |
|
| 1357 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByPartnerType(ptc.getPartnerType())
|
- |
|
| 1358 |
.stream().collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
- |
|
| 1359 |
|
1386 |
|
| - |
|
1387 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
| - |
|
1388 |
.collect(Collectors.toList());
|
| - |
|
1389 |
|
| - |
|
1390 |
Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAllByRegionIds(regionIds).stream()
|
| - |
|
1391 |
.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
|
| 1360 |
|
1392 |
|
| 1361 |
LocalDate currentMonthDate = LocalDate.now();
|
1393 |
LocalDate currentMonthDate = LocalDate.now();
|
| 1362 |
MonthlyPlanned monthlyPlanned = null;
|
1394 |
MonthlyPlanned monthlyPlanned = null;
|
| 1363 |
List<Integer> fofoOrderIds = null;
|
1395 |
List<Integer> fofoOrderIds = null;
|
| 1364 |
LOGGER.info("localDate" + LocalDate.now());
|
1396 |
LOGGER.info("localDate" + LocalDate.now());
|