| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.text.MessageFormat;
|
| 3 |
import java.time.LocalDateTime;
|
4 |
import java.time.LocalDateTime;
|
| 4 |
import java.util.ArrayList;
|
5 |
import java.util.ArrayList;
|
| 5 |
import java.util.Arrays;
|
6 |
import java.util.Arrays;
|
| 6 |
import java.util.HashMap;
|
7 |
import java.util.HashMap;
|
| 7 |
import java.util.List;
|
8 |
import java.util.List;
|
| Line 40... |
Line 41... |
| 40 |
import com.spice.profitmandi.common.model.GrnPendingDataModel;
|
41 |
import com.spice.profitmandi.common.model.GrnPendingDataModel;
|
| 41 |
import com.spice.profitmandi.common.model.ImeiDropSummaryModel;
|
42 |
import com.spice.profitmandi.common.model.ImeiDropSummaryModel;
|
| 42 |
import com.spice.profitmandi.common.model.ItemDescriptionModel;
|
43 |
import com.spice.profitmandi.common.model.ItemDescriptionModel;
|
| 43 |
import com.spice.profitmandi.common.model.PartnerImeiNotSold;
|
44 |
import com.spice.profitmandi.common.model.PartnerImeiNotSold;
|
| 44 |
import com.spice.profitmandi.common.model.PriceDropModel;
|
45 |
import com.spice.profitmandi.common.model.PriceDropModel;
|
| - |
|
46 |
import com.spice.profitmandi.common.model.PriceDropProcessModel;
|
| 45 |
import com.spice.profitmandi.common.model.ReporticoResponseModel;
|
47 |
import com.spice.profitmandi.common.model.ReporticoResponseModel;
|
| 46 |
import com.spice.profitmandi.common.services.ReporticoService;
|
48 |
import com.spice.profitmandi.common.services.ReporticoService;
|
| 47 |
import com.spice.profitmandi.common.util.FileUtil;
|
49 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 48 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
50 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 49 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
51 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 50 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
52 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| - |
|
53 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 51 |
import com.spice.profitmandi.dao.entity.inventory.VendorItemPricing;
|
54 |
import com.spice.profitmandi.dao.entity.inventory.VendorItemPricing;
|
| 52 |
import com.spice.profitmandi.dao.entity.transaction.LineItemImei;
|
- |
|
| 53 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
55 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| 54 |
import com.spice.profitmandi.dao.entity.transaction.PriceDropIMEI;
|
- |
|
| 55 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
56 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 56 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
57 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| - |
|
58 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 57 |
import com.spice.profitmandi.dao.repository.inventory.VendorItemPricingRepository;
|
59 |
import com.spice.profitmandi.dao.repository.inventory.VendorItemPricingRepository;
|
| 58 |
import com.spice.profitmandi.dao.repository.transaction.LineItemImeisRepository;
|
- |
|
| 59 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropIMEIRepository;
|
- |
|
| 60 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
60 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| 61 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
61 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 62 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
62 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 63 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
63 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 64 |
import com.spice.profitmandi.service.wallet.WalletService;
|
64 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 65 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
65 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 66 |
|
66 |
|
| - |
|
67 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| - |
|
68 |
|
| 67 |
@Controller
|
69 |
@Controller
|
| 68 |
@Transactional
|
70 |
@Transactional
|
| 69 |
public class PriceDropController {
|
71 |
public class PriceDropController {
|
| 70 |
|
72 |
|
| 71 |
private static final Logger LOGGER = LogManager.getLogger(PriceDropController.class);
|
73 |
private static final Logger LOGGER = LogManager.getLogger(PriceDropController.class);
|
| Line 75... |
Line 77... |
| 75 |
|
77 |
|
| 76 |
@Autowired
|
78 |
@Autowired
|
| 77 |
private ObjectMapper objectMapper;
|
79 |
private ObjectMapper objectMapper;
|
| 78 |
|
80 |
|
| 79 |
@Autowired
|
81 |
@Autowired
|
| 80 |
private PriceDropIMEIRepository priceDropIMEIRepository;
|
- |
|
| 81 |
|
- |
|
| 82 |
@Autowired
|
- |
|
| 83 |
private VendorItemPricingRepository vendorItemPricingRepository;
|
82 |
private VendorItemPricingRepository vendorItemPricingRepository;
|
| 84 |
|
83 |
|
| 85 |
@Autowired
|
84 |
@Autowired
|
| 86 |
private PriceDropService priceDropService;
|
- |
|
| 87 |
|
- |
|
| 88 |
@Autowired
|
- |
|
| 89 |
@Qualifier("fofoInventoryService")
|
85 |
@Qualifier("fofoInventoryService")
|
| 90 |
private InventoryService inventoryService;
|
86 |
private InventoryService inventoryService;
|
| 91 |
|
87 |
|
| 92 |
@Autowired
|
88 |
@Autowired
|
| 93 |
private MVCResponseSender mvcResponseSender;
|
89 |
private InventoryItemRepository inventoryItemRepository;
|
| 94 |
|
90 |
|
| 95 |
@Autowired
|
91 |
@Autowired
|
| 96 |
private WalletService walletService;
|
92 |
private MVCResponseSender mvcResponseSender;
|
| 97 |
|
93 |
|
| 98 |
@Autowired
|
94 |
@Autowired
|
| 99 |
private LineItemImeisRepository lineItemImeisRepository;
|
95 |
private WalletService walletService;
|
| 100 |
|
96 |
|
| 101 |
@Autowired
|
97 |
@Autowired
|
| 102 |
private TagListingRepository tagListingRepository;
|
98 |
private TagListingRepository tagListingRepository;
|
| 103 |
|
99 |
|
| 104 |
@Autowired
|
100 |
@Autowired
|
| Line 107... |
Line 103... |
| 107 |
@Autowired
|
103 |
@Autowired
|
| 108 |
@Qualifier("catalogItemRepository")
|
104 |
@Qualifier("catalogItemRepository")
|
| 109 |
private ItemRepository itemRepository;
|
105 |
private ItemRepository itemRepository;
|
| 110 |
|
106 |
|
| 111 |
@Autowired
|
107 |
@Autowired
|
| - |
|
108 |
private SchemeService schemeService;
|
| - |
|
109 |
|
| - |
|
110 |
@Autowired
|
| 112 |
ReporticoService reporticoService;
|
111 |
ReporticoService reporticoService;
|
| 113 |
|
112 |
|
| 114 |
@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
|
113 |
@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
|
| 115 |
public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
114 |
public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
|
| 116 |
|
115 |
|
| 117 |
List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
116 |
List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
| 118 |
Map<Integer, TagListing> tagListingMap = new HashMap<>();
|
117 |
Map<Integer, TagListing> tagListingMap = new HashMap<>();
|
| 119 |
List<ItemDescriptionModel> customItems = new ArrayList<>();
|
118 |
List<ItemDescriptionModel> customItems = new ArrayList<>();
|
| - |
|
119 |
Map<Integer, String> catalogDescription = new HashMap<>();
|
| 120 |
for (TagListing tagListing : tagListings) {
|
120 |
for (TagListing tagListing : tagListings) {
|
| - |
|
121 |
Item item = itemRepository.selectById(tagListing.getItemId());
|
| 121 |
tagListing.setItemDescription(itemRepository.selectById(tagListing.getItemId()).getItemDescription());
|
122 |
tagListing.setItemDescription(item.getItemDescription());
|
| 122 |
tagListingMap.put(tagListing.getItemId(), tagListing);
|
123 |
tagListingMap.put(tagListing.getItemId(), tagListing);
|
| 123 |
ItemDescriptionModel itemDescriptionModel = new ItemDescriptionModel();
|
124 |
ItemDescriptionModel itemDescriptionModel = new ItemDescriptionModel();
|
| 124 |
itemDescriptionModel.setItemId(tagListing.getItemId());
|
125 |
itemDescriptionModel.setItemId(tagListing.getItemId());
|
| 125 |
itemDescriptionModel
|
126 |
itemDescriptionModel
|
| 126 |
.setItemDescription(tagListing.getItemDescription() + "(" + tagListing.getItemId() + ")");
|
127 |
.setItemDescription(tagListing.getItemDescription() + "(" + tagListing.getItemId() + ")");
|
| 127 |
customItems.add(itemDescriptionModel);
|
128 |
customItems.add(itemDescriptionModel);
|
| - |
|
129 |
catalogDescription.put(item.getCatalogItemId(), item.getItemDescriptionNoColor());
|
| 128 |
}
|
130 |
}
|
| 129 |
|
131 |
|
| 130 |
List<PriceDrop> priceDrops = priceDropRepository.selectAll();
|
132 |
List<PriceDrop> priceDrops = priceDropRepository.selectAll();
|
| 131 |
model.addAttribute("tagListingMap", tagListingMap);
|
133 |
model.addAttribute("tagListingMap", tagListingMap);
|
| 132 |
model.addAttribute("customItems", new JSONArray(customItems).toString());
|
134 |
model.addAttribute("customItems", new JSONArray(customItems).toString());
|
| 133 |
model.addAttribute("priceDrops", priceDrops);
|
135 |
model.addAttribute("priceDrops", priceDrops);
|
| - |
|
136 |
model.addAttribute("catalogDescription", catalogDescription);
|
| 134 |
return "price-drop";
|
137 |
return "price-drop";
|
| 135 |
|
138 |
|
| 136 |
}
|
139 |
}
|
| 137 |
|
140 |
|
| 138 |
/*
|
141 |
/*
|
| Line 174... |
Line 177... |
| 174 |
|
177 |
|
| 175 |
@RequestMapping(value = "/price-drop/imes/download")
|
178 |
@RequestMapping(value = "/price-drop/imes/download")
|
| 176 |
public ResponseEntity<ByteArrayResource> downloadPriceDropImeis(HttpServletRequest request,
|
179 |
public ResponseEntity<ByteArrayResource> downloadPriceDropImeis(HttpServletRequest request,
|
| 177 |
@RequestParam LocalDateTime affectedDate, @RequestParam int itemId) throws Exception {
|
180 |
@RequestParam LocalDateTime affectedDate, @RequestParam int itemId) throws Exception {
|
| 178 |
Item item = itemRepository.selectById(itemId);
|
181 |
Item item = itemRepository.selectById(itemId);
|
| 179 |
ByteArrayOutputStream baos = getByteArrayOutputStream(affectedDate,
|
182 |
ByteArrayOutputStream baos = getByteArrayOutputStream(affectedDate, item.getCatalogItemId());
|
| 180 |
item.getCatalogItemId());
|
- |
|
| 181 |
final HttpHeaders headers = new HttpHeaders();
|
183 |
final HttpHeaders headers = new HttpHeaders();
|
| 182 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
184 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| 183 |
headers.set("Content-disposition", "inline; filename=imei-" + item.getItemDescriptionNoColor() + ".csv");
|
185 |
headers.set("Content-disposition", "inline; filename=imei-" + item.getItemDescriptionNoColor() + ".csv");
|
| 184 |
byte[] byteArray = baos.toByteArray();
|
186 |
byte[] byteArray = baos.toByteArray();
|
| 185 |
headers.setContentLength(byteArray.length);
|
187 |
headers.setContentLength(byteArray.length);
|
| 186 |
return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
|
188 |
return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
|
| 187 |
}
|
189 |
}
|
| 188 |
|
190 |
|
| 189 |
@RequestMapping(value = "/paymentAgainstPriceDrop/{priceDropId}/{processedamount}", method = RequestMethod.POST)
|
191 |
@RequestMapping(value = "/processPriceDrop", method = RequestMethod.POST)
|
| 190 |
public String paymentAgainstPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
|
192 |
public String processPriceDrop(HttpServletRequest request, @RequestBody PriceDropProcessModel priceDropProcess,
|
| 191 |
@PathVariable int processedamount, Model model) throws Exception {
|
193 |
Model model) throws Exception {
|
| - |
|
194 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropProcess.getPriceDropId());
|
| - |
|
195 |
boolean response = false;
|
| - |
|
196 |
if (priceDrop.getProcessTimestamp() == null) {
|
| - |
|
197 |
priceDrop.setPartnerPayout(priceDropProcess.getPartnerPayout());
|
| - |
|
198 |
priceDrop.setPriceDropIn(priceDropProcess.getPriceDropIn());
|
| - |
|
199 |
priceDrop.setProcessTimestamp(LocalDateTime.now());
|
| - |
|
200 |
priceDropRepository.persist(priceDrop);
|
| - |
|
201 |
List<ImeiDropSummaryModel> partnerPendingImeis = getPartnerPendingImeis(priceDrop.getAffectedOn(),
|
| - |
|
202 |
priceDrop.getCatalogItemId());
|
| - |
|
203 |
if (partnerPendingImeis.size() > 0) {
|
| - |
|
204 |
Map<Integer, List<ImeiDropSummaryModel>> partnerImeiMap = new HashMap<>();
|
| - |
|
205 |
for (ImeiDropSummaryModel pendingImei : partnerPendingImeis) {
|
| - |
|
206 |
if (!partnerImeiMap.containsKey(pendingImei.getRetailerId())) {
|
| - |
|
207 |
partnerImeiMap.put(pendingImei.getRetailerId(), new ArrayList<>());
|
| - |
|
208 |
}
|
| - |
|
209 |
partnerImeiMap.get(pendingImei.getRetailerId()).add(pendingImei);
|
| - |
|
210 |
}
|
| 192 |
|
211 |
|
| 193 |
int noOfIMEIForPartner = 1;
|
- |
|
| 194 |
Map<Integer, Integer> noOfPriceDropToPartners = new HashMap<>();
|
212 |
for (Map.Entry<Integer, List<ImeiDropSummaryModel>> pendingPartnerImei : partnerImeiMap.entrySet()) {
|
| 195 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
|
213 |
List<ImeiDropSummaryModel> retailerImeiList = pendingPartnerImei.getValue();
|
| 196 |
List<Item> items = itemRepository.selectAllByCatalogItemId(priceDrop.getCatalogItemId());
|
214 |
int fofoId = pendingPartnerImei.getKey();
|
| 197 |
List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByPriceDropId(priceDrop.getId());
|
215 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByFofoIdSerialNumbers(fofoId,
|
| 198 |
List<String> imeis = priceDropIMEIs.stream().map(x -> x.getImei()).collect(Collectors.toList());
|
216 |
retailerImeiList.stream().map(x -> x.getSerialNumber()).collect(Collectors.toSet()), true);
|
| - |
|
217 |
String reversalReason = MessageFormat.format(
|
| 199 |
List<LineItemImei> lineItemImeis = lineItemImeisRepository.selectByIMEI(imeis);
|
218 |
"Scheme amount reversal due to Price Drop of Rs.{0} on {1}. Affected on {3}, Total {2} item(s)",
|
| 200 |
Map<String, Integer> priceDropIMEIfofoIds = priceDropService.getIMEIAndfofoIdForPriceDrop(lineItemImeis,
|
219 |
priceDrop.getAmount(), priceDrop.getDescription(), pendingPartnerImei.getValue().size(),
|
| 201 |
priceDrop);
|
220 |
FormattingUtils.formatDate(priceDrop.getAffectedOn()));
|
| 202 |
if (priceDropIMEIfofoIds.size() > 0) {
|
221 |
String aReason = MessageFormat.format(
|
| 203 |
for (Map.Entry<String, Integer> priceDropIMEIAndFofoId : priceDropIMEIfofoIds.entrySet()) {
|
222 |
"Per unit payout of Rs.{4} Price Drop of Rs.{0} on {1} affected on {3}. Total {2} item(s)",
|
| 204 |
int fofoId = priceDropIMEIAndFofoId.getValue();
|
223 |
priceDrop.getAmount(), priceDrop.getDescription(), pendingPartnerImei.getValue().size(),
|
| - |
|
224 |
FormattingUtils.formatDate(priceDrop.getAffectedOn()), priceDropProcess.getPartnerPayout());
|
| - |
|
225 |
schemeService.reverseSchemes(inventoryItems, priceDropProcess.getPriceDropId(), reversalReason);
|
| 205 |
if (noOfPriceDropToPartners.containsKey(fofoId)) {
|
226 |
inventoryService.updatePriceDrop(inventoryItems, priceDrop.getAmount());
|
| 206 |
noOfPriceDropToPartners.put(fofoId, noOfPriceDropToPartners.get(fofoId) + 1);
|
227 |
walletService.addAmountToWallet(fofoId, priceDrop.getId(), WalletReferenceType.PRICE_DROP,
|
| 207 |
} else {
|
- |
|
| 208 |
noOfPriceDropToPartners.put(fofoId, noOfIMEIForPartner);
|
228 |
aReason, priceDropProcess.getPartnerPayout()*pendingPartnerImei.getValue().size());
|
| 209 |
}
|
229 |
}
|
| 210 |
|
230 |
|
| 211 |
}
|
231 |
}
|
| 212 |
priceDrop.setProcessTimestamp(LocalDateTime.now());
|
- |
|
| 213 |
priceDrop.setPartnerPayout(processedamount);
|
- |
|
| 214 |
priceDropRepository.persist(priceDrop);
|
- |
|
| 215 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
- |
|
| 216 |
return "response";
|
- |
|
| 217 |
} else {
|
- |
|
| 218 |
priceDrop.setProcessTimestamp(LocalDateTime.now());
|
- |
|
| 219 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
- |
|
| 220 |
return "false";
|
232 |
response = true;
|
| 221 |
}
|
233 |
}
|
| - |
|
234 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
| - |
|
235 |
return "response";
|
| 222 |
}
|
236 |
}
|
| 223 |
|
237 |
|
| 224 |
@RequestMapping(value = "/priceDrop", method = RequestMethod.POST)
|
238 |
@RequestMapping(value = "/priceDrop", method = RequestMethod.POST)
|
| 225 |
public String addPriceDrop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel)
|
239 |
public String addPriceDrop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel)
|
| 226 |
throws Exception {
|
240 |
throws Exception {
|
| 227 |
boolean response = false;
|
241 |
boolean response = false;
|
| - |
|
242 |
priceDropModel.setAllColors(true);
|
| 228 |
if (this.validatePriceDrop(priceDropModel)) {
|
243 |
if (this.validatePriceDrop(priceDropModel)) {
|
| 229 |
TagListing tagListing = tagListingRepository.selectByItemId(priceDropModel.getItemId());
|
244 |
TagListing tagListing = tagListingRepository.selectByItemId(priceDropModel.getItemId());
|
| 230 |
float newDp = tagListing.getSellingPrice() - priceDropModel.getPd();
|
245 |
float newDp = tagListing.getSellingPrice() - priceDropModel.getPd();
|
| 231 |
if (newDp > 0) {
|
246 |
if (newDp > 0) {
|
| 232 |
List<Item> allItems = null;
|
247 |
List<Item> allItems = null;
|
| Line 254... |
Line 269... |
| 254 |
}
|
269 |
}
|
| 255 |
transactionService.updatePriceDrop(item.getId(), newDp);
|
270 |
transactionService.updatePriceDrop(item.getId(), newDp);
|
| 256 |
}
|
271 |
}
|
| 257 |
PriceDrop priceDrop = new PriceDrop();
|
272 |
PriceDrop priceDrop = new PriceDrop();
|
| 258 |
priceDrop.setAffectedOn(priceDropModel.getAffectedDate());
|
273 |
priceDrop.setAffectedOn(priceDropModel.getAffectedDate());
|
| - |
|
274 |
priceDrop.setOldDp(newDp + priceDropModel.getPd());
|
| 259 |
priceDrop.setAmount(priceDropModel.getPd());
|
275 |
priceDrop.setAmount(priceDropModel.getPd());
|
| - |
|
276 |
priceDrop.setNewDp(newDp);
|
| - |
|
277 |
priceDrop.setNlc(priceDropModel.getNlc());
|
| - |
|
278 |
priceDrop.setTp(priceDropModel.getTp());
|
| 260 |
priceDrop.setCreatedOn(LocalDateTime.now());
|
279 |
priceDrop.setCreatedOn(LocalDateTime.now());
|
| 261 |
priceDrop.setCatalogItemId(currentItem.getCatalogItemId());
|
280 |
priceDrop.setCatalogItemId(currentItem.getCatalogItemId());
|
| 262 |
priceDropRepository.persist(priceDrop);
|
281 |
priceDropRepository.persist(priceDrop);
|
| 263 |
response = true;
|
282 |
response = true;
|
| 264 |
} else {
|
283 |
} else {
|
| Line 273... |
Line 292... |
| 273 |
@RequestMapping(value = "/downloadtotalPriceDropIMEI/{priceDropId}", method = RequestMethod.GET)
|
292 |
@RequestMapping(value = "/downloadtotalPriceDropIMEI/{priceDropId}", method = RequestMethod.GET)
|
| 274 |
public ResponseEntity<?> downloadTotalPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
|
293 |
public ResponseEntity<?> downloadTotalPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
|
| 275 |
Model model) throws ProfitMandiBusinessException, Exception {
|
294 |
Model model) throws ProfitMandiBusinessException, Exception {
|
| 276 |
|
295 |
|
| 277 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
|
296 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
|
| - |
|
297 |
Item item = itemRepository.selectAllByCatalogItemId(priceDrop.getCatalogItemId()).get(0);
|
| - |
|
298 |
ByteArrayOutputStream baos = getByteArrayOutputStream(priceDrop.getAffectedOn(), priceDrop.getCatalogItemId());
|
| - |
|
299 |
final HttpHeaders headers = new HttpHeaders();
|
| - |
|
300 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| - |
|
301 |
headers.set("Content-disposition", "inline; filename=pricedrop-" + item.getItemDescriptionNoColor() + "-"
|
| - |
|
302 |
+ FormattingUtils.formatDate(priceDrop.getAffectedOn()) + ".csv");
|
| - |
|
303 |
byte[] byteArray = baos.toByteArray();
|
| - |
|
304 |
headers.setContentLength(byteArray.length);
|
| - |
|
305 |
return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
|
| 278 |
|
306 |
|
| 279 |
return new ResponseEntity<Boolean>(true, null, HttpStatus.OK);
|
- |
|
| 280 |
}
|
307 |
}
|
| 281 |
|
308 |
|
| 282 |
private ByteArrayOutputStream getByteArrayOutputStream(LocalDateTime affectedOn, Integer catalogItemId)
|
309 |
private List<ImeiDropSummaryModel> getPartnerPendingImeis(LocalDateTime affectedOn, Integer catalogItemId)
|
| 283 |
throws Exception {
|
310 |
throws Exception {
|
| 284 |
Map<String, String> params = new HashMap<>();
|
311 |
Map<String, String> params = new HashMap<>();
|
| 285 |
params.put("MANUAL_criteria1_FROMDATE", FormattingUtils.formatReporitcoDate(affectedOn));
|
312 |
params.put("MANUAL_criteria1_FROMDATE", FormattingUtils.formatReporitcoDate(affectedOn));
|
| 286 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogItemId);
|
313 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogItemId);
|
| 287 |
List<String> itemIds = items.stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList());
|
314 |
List<String> itemIds = items.stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList());
|
| Line 300... |
Line 327... |
| 300 |
List<? extends ImeiDropSummaryModel> itemStockOnDateList = getReports(ClosingStockOnDate.class,
|
327 |
List<? extends ImeiDropSummaryModel> itemStockOnDateList = getReports(ClosingStockOnDate.class,
|
| 301 |
ReporticoProject.WAREHOUSENEW, "itemstockondate.xml", params2);
|
328 |
ReporticoProject.WAREHOUSENEW, "itemstockondate.xml", params2);
|
| 302 |
List<ImeiDropSummaryModel> mergedImeis = new ArrayList<>();
|
329 |
List<ImeiDropSummaryModel> mergedImeis = new ArrayList<>();
|
| 303 |
mergedImeis.addAll(grnPendingList);
|
330 |
mergedImeis.addAll(grnPendingList);
|
| 304 |
mergedImeis.addAll(partnerImeiNotSoldList);
|
331 |
mergedImeis.addAll(partnerImeiNotSoldList);
|
| - |
|
332 |
|
| - |
|
333 |
return mergedImeis;
|
| - |
|
334 |
}
|
| - |
|
335 |
|
| - |
|
336 |
private ByteArrayOutputStream getByteArrayOutputStream(LocalDateTime affectedOn, Integer catalogItemId)
|
| - |
|
337 |
throws Exception {
|
| - |
|
338 |
|
| - |
|
339 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogItemId);
|
| - |
|
340 |
List<String> itemIds = items.stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList());
|
| - |
|
341 |
|
| - |
|
342 |
Map<String, String> params = new HashMap<>();
|
| - |
|
343 |
params.put("MANUAL_criteria1_FROMDATE", FormattingUtils.formatReporitcoDate(affectedOn));
|
| - |
|
344 |
params.put("MANUAL_itemId", StringUtils.join(itemIds, ","));
|
| - |
|
345 |
|
| - |
|
346 |
Map<String, String> params1 = new HashMap<>();
|
| - |
|
347 |
params1.put("MANUAL_criteriaDate_FROMDATE", FormattingUtils.formatReporitcoDate(affectedOn));
|
| - |
|
348 |
params1.put("MANUAL_criteriaItemId", StringUtils.join(itemIds, ","));
|
| - |
|
349 |
|
| - |
|
350 |
List<? extends ImeiDropSummaryModel> grnPendingList = getReports(GrnPendingDataModel.class,
|
| - |
|
351 |
ReporticoProject.FOCO, "imeispendinggrn.xml", params);
|
| - |
|
352 |
List<? extends ImeiDropSummaryModel> partnerImeiNotSoldList = getReports(PartnerImeiNotSold.class,
|
| - |
|
353 |
ReporticoProject.FOCO, "PartnerIMEINotSold.xml", params1);
|
| - |
|
354 |
|
| - |
|
355 |
List<ImeiDropSummaryModel> mergedImeis = new ArrayList<>();
|
| 305 |
mergedImeis.addAll(itemStockOnDateList);
|
356 |
mergedImeis.addAll(grnPendingList);
|
| - |
|
357 |
mergedImeis.addAll(partnerImeiNotSoldList);
|
| - |
|
358 |
|
| 306 |
List<List<Object>> rows = new ArrayList<>();
|
359 |
List<List<Object>> rows = new ArrayList<>();
|
| 307 |
for (ImeiDropSummaryModel imeiDropSummaryModel : mergedImeis) {
|
360 |
for (ImeiDropSummaryModel imeiDropSummaryModel : mergedImeis) {
|
| 308 |
List<Object> row = new ArrayList<>();
|
361 |
List<Object> row = new ArrayList<>();
|
| 309 |
row.add(imeiDropSummaryModel.getSerialNumber());
|
362 |
row.add(imeiDropSummaryModel.getSerialNumber());
|
| 310 |
row.add(imeiDropSummaryModel.getStoreName());
|
363 |
row.add(imeiDropSummaryModel.getStoreName());
|