| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.io.ByteArrayInputStream;
|
| - |
|
4 |
import java.io.ByteArrayOutputStream;
|
| - |
|
5 |
import java.io.InputStream;
|
| 3 |
import java.util.ArrayList;
|
6 |
import java.util.ArrayList;
|
| 4 |
import java.util.HashMap;
|
7 |
import java.util.HashMap;
|
| 5 |
import java.util.HashSet;
|
8 |
import java.util.HashSet;
|
| 6 |
import java.util.List;
|
9 |
import java.util.List;
|
| 7 |
import java.util.Map;
|
10 |
import java.util.Map;
|
| 8 |
import java.util.Set;
|
11 |
import java.util.Set;
|
| 9 |
|
12 |
|
| 10 |
import javax.servlet.http.HttpServletRequest;
|
13 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
14 |
import javax.servlet.http.HttpServletResponse;
|
| 11 |
import javax.transaction.Transactional;
|
15 |
import javax.transaction.Transactional;
|
| 12 |
|
16 |
|
| 13 |
import org.slf4j.Logger;
|
17 |
import org.slf4j.Logger;
|
| 14 |
import org.slf4j.LoggerFactory;
|
18 |
import org.slf4j.LoggerFactory;
|
| 15 |
import org.springframework.beans.factory.annotation.Autowired;
|
19 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
20 |
import org.springframework.core.io.InputStreamResource;
|
| - |
|
21 |
import org.springframework.http.HttpHeaders;
|
| - |
|
22 |
import org.springframework.http.HttpStatus;
|
| - |
|
23 |
import org.springframework.http.MediaType;
|
| - |
|
24 |
import org.springframework.http.ResponseEntity;
|
| 16 |
import org.springframework.stereotype.Controller;
|
25 |
import org.springframework.stereotype.Controller;
|
| 17 |
import org.springframework.web.bind.annotation.RequestBody;
|
26 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 18 |
import org.springframework.web.bind.annotation.RequestMapping;
|
27 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 19 |
import org.springframework.web.bind.annotation.RequestMethod;
|
28 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
29 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 20 |
|
30 |
|
| 21 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
31 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 22 |
import com.spice.profitmandi.common.model.CustomAddress;
|
32 |
import com.spice.profitmandi.common.model.CustomAddress;
|
| - |
|
33 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
| - |
|
34 |
import com.spice.profitmandi.common.model.CustomFofoLineItem;
|
| - |
|
35 |
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
|
| - |
|
36 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| - |
|
37 |
import com.spice.profitmandi.common.model.PdfModel;
|
| 23 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
38 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
39 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 24 |
import com.spice.profitmandi.common.util.StringUtils;
|
40 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 25 |
import com.spice.profitmandi.dao.entity.Address;
|
41 |
import com.spice.profitmandi.dao.entity.Address;
|
| 26 |
import com.spice.profitmandi.dao.entity.CurrentInventorySnapshot;
|
42 |
import com.spice.profitmandi.dao.entity.CurrentInventorySnapshot;
|
| 27 |
import com.spice.profitmandi.dao.entity.Customer;
|
43 |
import com.spice.profitmandi.dao.entity.Customer;
|
| 28 |
import com.spice.profitmandi.dao.entity.FofoLineItem;
|
44 |
import com.spice.profitmandi.dao.entity.FofoLineItem;
|
| Line 32... |
Line 48... |
| 32 |
import com.spice.profitmandi.dao.entity.InvoiceNumberGenerationSequence;
|
48 |
import com.spice.profitmandi.dao.entity.InvoiceNumberGenerationSequence;
|
| 33 |
import com.spice.profitmandi.dao.entity.Item;
|
49 |
import com.spice.profitmandi.dao.entity.Item;
|
| 34 |
import com.spice.profitmandi.dao.entity.LineItem;
|
50 |
import com.spice.profitmandi.dao.entity.LineItem;
|
| 35 |
import com.spice.profitmandi.dao.entity.Order;
|
51 |
import com.spice.profitmandi.dao.entity.Order;
|
| 36 |
import com.spice.profitmandi.dao.entity.PaymentOption;
|
52 |
import com.spice.profitmandi.dao.entity.PaymentOption;
|
| - |
|
53 |
import com.spice.profitmandi.dao.entity.Retailer;
|
| 37 |
import com.spice.profitmandi.dao.entity.ScanRecord;
|
54 |
import com.spice.profitmandi.dao.entity.ScanRecord;
|
| - |
|
55 |
import com.spice.profitmandi.dao.entity.User;
|
| 38 |
import com.spice.profitmandi.dao.enumuration.ScanType;
|
56 |
import com.spice.profitmandi.dao.enumuration.ScanType;
|
| 39 |
import com.spice.profitmandi.dao.repository.AddressRepository;
|
57 |
import com.spice.profitmandi.dao.repository.AddressRepository;
|
| 40 |
import com.spice.profitmandi.dao.repository.CurrentInventorySnapshotRepository;
|
58 |
import com.spice.profitmandi.dao.repository.CurrentInventorySnapshotRepository;
|
| 41 |
import com.spice.profitmandi.dao.repository.CustomerRepository;
|
59 |
import com.spice.profitmandi.dao.repository.CustomerRepository;
|
| 42 |
import com.spice.profitmandi.dao.repository.FofoLineItemRepository;
|
60 |
import com.spice.profitmandi.dao.repository.FofoLineItemRepository;
|
| Line 44... |
Line 62... |
| 44 |
import com.spice.profitmandi.dao.repository.FofoOrderRepository;
|
62 |
import com.spice.profitmandi.dao.repository.FofoOrderRepository;
|
| 45 |
import com.spice.profitmandi.dao.repository.InventoryItemRepository;
|
63 |
import com.spice.profitmandi.dao.repository.InventoryItemRepository;
|
| 46 |
import com.spice.profitmandi.dao.repository.InvoiceNumberGenerationSequenceRepository;
|
64 |
import com.spice.profitmandi.dao.repository.InvoiceNumberGenerationSequenceRepository;
|
| 47 |
import com.spice.profitmandi.dao.repository.OrderRepository;
|
65 |
import com.spice.profitmandi.dao.repository.OrderRepository;
|
| 48 |
import com.spice.profitmandi.dao.repository.PaymentOptionRepository;
|
66 |
import com.spice.profitmandi.dao.repository.PaymentOptionRepository;
|
| - |
|
67 |
import com.spice.profitmandi.dao.repository.RetailerRegisteredAddressRepository;
|
| - |
|
68 |
import com.spice.profitmandi.dao.repository.RetailerRepository;
|
| 49 |
import com.spice.profitmandi.dao.repository.ScanRecordRepository;
|
69 |
import com.spice.profitmandi.dao.repository.ScanRecordRepository;
|
| - |
|
70 |
import com.spice.profitmandi.dao.repository.UserAccountRepository;
|
| - |
|
71 |
import com.spice.profitmandi.dao.repository.UserRepository;
|
| 50 |
import com.spice.profitmandi.web.model.FofoDetails;
|
72 |
import com.spice.profitmandi.web.model.FofoDetails;
|
| 51 |
import com.spice.profitmandi.web.request.CreateOrderRequest;
|
73 |
import com.spice.profitmandi.web.request.CreateOrderRequest;
|
| 52 |
import com.spice.profitmandi.web.request.CustomCustomer;
|
- |
|
| 53 |
import com.spice.profitmandi.web.request.CustomFofoLineItem;
|
- |
|
| 54 |
import com.spice.profitmandi.web.request.CustomPaymentOption;
|
74 |
import com.spice.profitmandi.web.request.CustomPaymentOption;
|
| 55 |
import com.spice.profitmandi.web.response.ItemIdQuantityAvailability;
|
75 |
import com.spice.profitmandi.web.response.ItemIdQuantityAvailability;
|
| 56 |
import com.spice.profitmandi.web.response.Quantity;
|
76 |
import com.spice.profitmandi.web.response.Quantity;
|
| 57 |
import com.spice.profitmandi.web.util.CookiesFetcher;
|
77 |
import com.spice.profitmandi.web.util.CookiesFetcher;
|
| 58 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
78 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| Line 95... |
Line 115... |
| 95 |
|
115 |
|
| 96 |
@Autowired
|
116 |
@Autowired
|
| 97 |
FofoOrderRepository fofoOrderRepository;
|
117 |
FofoOrderRepository fofoOrderRepository;
|
| 98 |
|
118 |
|
| 99 |
@Autowired
|
119 |
@Autowired
|
| - |
|
120 |
RetailerRepository retailerRepository;
|
| - |
|
121 |
|
| - |
|
122 |
@Autowired
|
| - |
|
123 |
UserRepository userRepository;
|
| - |
|
124 |
|
| - |
|
125 |
@Autowired
|
| - |
|
126 |
UserAccountRepository userAccountRepository;
|
| - |
|
127 |
|
| - |
|
128 |
@Autowired
|
| - |
|
129 |
RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
| - |
|
130 |
|
| - |
|
131 |
@Autowired
|
| 100 |
MVCResponseSender mvcResponseSender;
|
132 |
MVCResponseSender mvcResponseSender;
|
| 101 |
|
133 |
|
| 102 |
@Autowired
|
134 |
@Autowired
|
| 103 |
CookiesFetcher cookiesFetcher;
|
135 |
CookiesFetcher cookiesFetcher;
|
| 104 |
|
136 |
|
| Line 144... |
Line 176... |
| 144 |
}
|
176 |
}
|
| 145 |
}
|
177 |
}
|
| 146 |
if(!(fofoLineItem.getSellingPrice() > 0)){
|
178 |
if(!(fofoLineItem.getSellingPrice() > 0)){
|
| 147 |
lineItemPrice.put(fofoLineItem.getItemId(), fofoLineItem.getSellingPrice());
|
179 |
lineItemPrice.put(fofoLineItem.getItemId(), fofoLineItem.getSellingPrice());
|
| 148 |
}else{
|
180 |
}else{
|
| 149 |
totalAmount = totalAmount + fofoLineItem.getSellingPrice();
|
181 |
totalAmount = totalAmount + fofoLineItem.getSellingPrice() * fofoLineItem.getQuantity();
|
| 150 |
}
|
182 |
}
|
| 151 |
}
|
183 |
}
|
| 152 |
}
|
184 |
}
|
| 153 |
|
185 |
|
| 154 |
try{
|
186 |
try{
|
| 155 |
this.validatePaymentOptionsAndTotalAmount(createOrderRequest.getPaymentOptions(), totalAmount);
|
187 |
this.validatePaymentOptionsAndTotalAmount(createOrderRequest.getPaymentOptions(), totalAmount);
|
| 156 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
188 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| 157 |
LOGGER.error("Error occured while validating payment options : ", profitMandiBusinessException);
|
189 |
LOGGER.error("Error occured while validating payment options : ", profitMandiBusinessException);
|
| 158 |
return "error";
|
190 |
return "error";
|
| 159 |
}
|
191 |
}
|
| - |
|
192 |
|
| 160 |
if(!itemIdQuantityAvailabilities.isEmpty()){
|
193 |
if(!itemIdQuantityAvailabilities.isEmpty()){
|
| 161 |
// itemIdQuantity request is not valid
|
194 |
// itemIdQuantity request is not valid
|
| 162 |
LOGGER.error("Requested quantities should not be greater than currently available quantities {}", itemIdQuantityAvailabilities);
|
195 |
LOGGER.error("Requested quantities should not be greater than currently available quantities {}", itemIdQuantityAvailabilities);
|
| 163 |
return "error";
|
196 |
return "error";
|
| 164 |
}
|
197 |
}
|
| Line 244... |
Line 277... |
| 244 |
try{
|
277 |
try{
|
| 245 |
customer = customerRepository.selectByEmailIdAndMobileNumber(customCustomer.getEmailId(), customCustomer.getMobileNumber());
|
278 |
customer = customerRepository.selectByEmailIdAndMobileNumber(customCustomer.getEmailId(), customCustomer.getMobileNumber());
|
| 246 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
279 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| 247 |
LOGGER.error("Error : ", profitMandiBusinessException);
|
280 |
LOGGER.error("Error : ", profitMandiBusinessException);
|
| 248 |
customer = new Customer();
|
281 |
customer = new Customer();
|
| - |
|
282 |
customCustomer.setName(customCustomer.getName());
|
| 249 |
customer.setEmailId(customCustomer.getEmailId());
|
283 |
customer.setEmailId(customCustomer.getEmailId());
|
| 250 |
customer.setMobileNumber(customCustomer.getMobileNumber());
|
284 |
customer.setMobileNumber(customCustomer.getMobileNumber());
|
| 251 |
customer.setAddressId(address.getId());
|
285 |
customer.setAddressId(address.getId());
|
| 252 |
customerRepository.persist(customer);
|
286 |
customerRepository.persist(customer);
|
| 253 |
}
|
287 |
}
|
| Line 292... |
Line 326... |
| 292 |
fofoLineItem.setItemId(customFofoLineItem.getItemId());
|
326 |
fofoLineItem.setItemId(customFofoLineItem.getItemId());
|
| 293 |
fofoLineItem.setQuantity(customFofoLineItem.getQuantity());
|
327 |
fofoLineItem.setQuantity(customFofoLineItem.getQuantity());
|
| 294 |
fofoLineItem.setSellingPrice(customFofoLineItem.getSellingPrice() * customFofoLineItem.getQuantity());
|
328 |
fofoLineItem.setSellingPrice(customFofoLineItem.getSellingPrice() * customFofoLineItem.getQuantity());
|
| 295 |
fofoLineItem.setOrderId(fofoOrder.getId());
|
329 |
fofoLineItem.setOrderId(fofoOrder.getId());
|
| 296 |
fofoLineItem.setDp(customFofoLineItem.getSellingPrice());
|
330 |
fofoLineItem.setDp(customFofoLineItem.getSellingPrice());
|
| - |
|
331 |
fofoLineItem.setTax(0);
|
| - |
|
332 |
fofoLineItem.setTaxRate(0);
|
| 297 |
Map<String, String> itemIdDetail = itemIdDetails.get(customFofoLineItem.getItemId());
|
333 |
Map<String, String> itemIdDetail = itemIdDetails.get(customFofoLineItem.getItemId());
|
| 298 |
fofoLineItem.setBrand(itemIdDetail.get(ProfitMandiConstants.BRAND));
|
334 |
fofoLineItem.setBrand(itemIdDetail.get(ProfitMandiConstants.BRAND));
|
| 299 |
fofoLineItem.setModelName(itemIdDetail.get(ProfitMandiConstants.MODEL_NAME));
|
335 |
fofoLineItem.setModelName(itemIdDetail.get(ProfitMandiConstants.MODEL_NAME));
|
| 300 |
fofoLineItem.setModelNumber(itemIdDetail.get(ProfitMandiConstants.MODEL_NUMBER));
|
336 |
fofoLineItem.setModelNumber(itemIdDetail.get(ProfitMandiConstants.MODEL_NUMBER));
|
| 301 |
fofoLineItem.setColor(itemIdDetail.get(ProfitMandiConstants.COLOR));
|
337 |
fofoLineItem.setColor(itemIdDetail.get(ProfitMandiConstants.COLOR));
|
| Line 385... |
Line 421... |
| 385 |
address.setPhoneNumber(customAddress.getPhoneNumber());
|
421 |
address.setPhoneNumber(customAddress.getPhoneNumber());
|
| 386 |
address.setEnabled(true);
|
422 |
address.setEnabled(true);
|
| 387 |
return address;
|
423 |
return address;
|
| 388 |
}
|
424 |
}
|
| 389 |
|
425 |
|
| 390 |
private void validateCreateOrderRequest(CreateOrderRequest createOrderRequest){
|
426 |
private CustomAddress createCustomAddress(Address address){
|
| 391 |
Set<CustomPaymentOption> customPaymentOptions = createOrderRequest.getPaymentOptions();
|
427 |
CustomAddress customAddress = new CustomAddress();
|
| - |
|
428 |
customAddress.setName(address.getName());
|
| - |
|
429 |
customAddress.setLine1(address.getLine1());
|
| - |
|
430 |
customAddress.setLine2(address.getLine2());
|
| - |
|
431 |
customAddress.setLandmark(address.getLandmark());
|
| - |
|
432 |
customAddress.setCity(address.getCity());
|
| - |
|
433 |
customAddress.setPinCode(address.getPinCode());
|
| - |
|
434 |
customAddress.setState(address.getState());
|
| - |
|
435 |
customAddress.setCountry(address.getCountry());
|
| - |
|
436 |
customAddress.setPhoneNumber(address.getPhoneNumber());
|
| 392 |
|
437 |
return customAddress;
|
| 393 |
}
|
438 |
}
|
| 394 |
|
439 |
|
| 395 |
|
- |
|
| 396 |
private void validatePaymentOptionsAndTotalAmount(Set<CustomPaymentOption> customPaymentOptions, float totalAmount) throws ProfitMandiBusinessException
|
440 |
private void validatePaymentOptionsAndTotalAmount(Set<CustomPaymentOption> customPaymentOptions, float totalAmount) throws ProfitMandiBusinessException
|
| 397 |
{
|
441 |
{
|
| 398 |
float calculatedAmount = 0;
|
442 |
float calculatedAmount = 0;
|
| 399 |
Set<String> paymentOptionTypes = new HashSet<>();
|
443 |
Set<String> paymentOptionTypes = new HashSet<>();
|
| 400 |
for(CustomPaymentOption customPaymentOption : customPaymentOptions){
|
444 |
for(CustomPaymentOption customPaymentOption : customPaymentOptions){
|
| Line 408... |
Line 452... |
| 408 |
if(calculatedAmount != totalAmount){
|
452 |
if(calculatedAmount != totalAmount){
|
| 409 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_CALCULATED_AMOUNT, calculatedAmount, "");
|
453 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.PAYMENT_OPTION_CALCULATED_AMOUNT, calculatedAmount, "");
|
| 410 |
}
|
454 |
}
|
| 411 |
}
|
455 |
}
|
| 412 |
|
456 |
|
| - |
|
457 |
|
| - |
|
458 |
@RequestMapping(value = "/generateInvoice")
|
| - |
|
459 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws Throwable{
|
| - |
|
460 |
LOGGER.info("Request received at url {} with params {} ", request.getRequestURI(), request.getParameterMap());
|
| - |
|
461 |
//FofoDetails fofoDetails = cookiesFetcher.getCookiesObject(request);
|
| - |
|
462 |
FofoDetails fofoDetails = new FofoDetails();
|
| - |
|
463 |
fofoDetails.setFofoId(963490);
|
| - |
|
464 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
| - |
|
465 |
PdfModel pdfModel = new PdfModel();
|
| - |
|
466 |
pdfModel.setAuther("profitmandi");
|
| - |
|
467 |
pdfModel.setTitle("Retailer Invoice");
|
| - |
|
468 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
| - |
|
469 |
CustomCustomer customCustomer = new CustomCustomer();
|
| - |
|
470 |
customCustomer.setName(customer.getName());
|
| - |
|
471 |
customCustomer.setEmailId(customer.getEmailId());
|
| - |
|
472 |
customCustomer.setMobileNumber(customer.getMobileNumber());
|
| - |
|
473 |
Address customerAddress = addressRepository.selectById(customer.getAddressId());
|
| - |
|
474 |
customCustomer.setAddress(this.createCustomAddress(customerAddress));
|
| - |
|
475 |
pdfModel.setCustomer(customCustomer);
|
| - |
|
476 |
pdfModel.setInvoiceNumber(fofoOrder.getInvoiceNumber());
|
| - |
|
477 |
pdfModel.setTotalAmount(fofoOrder.getTotalAmount());
|
| - |
|
478 |
|
| - |
|
479 |
Retailer retailer = retailerRepository.selectById(fofoDetails.getFofoId());
|
| - |
|
480 |
User user = userRepository.selectById(userAccountRepository.selectUserIdByRetailerId(retailer.getId()));
|
| - |
|
481 |
CustomRetailer customRetailer = new CustomRetailer();
|
| - |
|
482 |
customRetailer.setBusinessName(retailer.getName());
|
| - |
|
483 |
customRetailer.setMobileNumber(user.getMobileNumber());
|
| - |
|
484 |
customRetailer.setTinNumber(retailer.getNumber());
|
| - |
|
485 |
Address retailerAddress = addressRepository.selectById(retailerRegisteredAddressRepository.selectAddressIdByRetailerId(retailer.getId()));
|
| - |
|
486 |
customRetailer.setAddress(this.createCustomAddress(retailerAddress));
|
| - |
|
487 |
pdfModel.setRetailer(customRetailer);
|
| - |
|
488 |
List<FofoLineItem> fofoLineItems = fofoLineItemRepository.selectByOrderId(fofoOrder.getId());
|
| - |
|
489 |
|
| - |
|
490 |
Set<CustomFofoOrderItem> customerFofoOrderItems = new HashSet<>();
|
| - |
|
491 |
for(FofoLineItem fofoLineItem : fofoLineItems){
|
| - |
|
492 |
CustomFofoOrderItem customFofoOrderItem = new CustomFofoOrderItem();
|
| - |
|
493 |
customFofoOrderItem.setAmount(fofoLineItem.getQuantity() * fofoLineItem.getSellingPrice());
|
| - |
|
494 |
customFofoOrderItem.setDescription(fofoLineItem.getBrand() + " " + fofoLineItem.getModelName() + " " + fofoLineItem.getModelNumber() + " " + fofoLineItem.getColor());
|
| - |
|
495 |
float itemTotal = customFofoOrderItem.getAmount() - fofoLineItem.getTax();
|
| - |
|
496 |
customFofoOrderItem.setRate(fofoLineItem.getSellingPrice());
|
| - |
|
497 |
customFofoOrderItem.setQuantity(fofoLineItem.getQuantity());
|
| - |
|
498 |
customFofoOrderItem.setTax(fofoLineItem.getTax());
|
| - |
|
499 |
customFofoOrderItem.setTaxRate(fofoLineItem.getTaxRate());
|
| - |
|
500 |
customFofoOrderItem.setItemTotal(itemTotal);
|
| - |
|
501 |
customFofoOrderItem.setSerialNumbers(String.join(", ",this.toSerialNumbers(fofoLineItem.getFofoLineItemSerialNumbers())));
|
| - |
|
502 |
customerFofoOrderItems.add(customFofoOrderItem);
|
| - |
|
503 |
}
|
| - |
|
504 |
pdfModel.setOrderItems(customerFofoOrderItems);
|
| - |
|
505 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| - |
|
506 |
PdfUtils.generateAndWrite(pdfModel, byteArrayOutputStream);
|
| - |
|
507 |
//final MediaType mediaType=MediaType.parseMediaType(profilePhotoModel.getContentType().getValue());
|
| - |
|
508 |
LOGGER.info("Pdf Stream length {}", byteArrayOutputStream.toByteArray().length);
|
| - |
|
509 |
final HttpHeaders headers=new HttpHeaders();
|
| - |
|
510 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
| - |
|
511 |
//headers.set("Content-Disposition", "retailerInvoice.pdf");
|
| - |
|
512 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
| - |
|
513 |
final InputStream inputStream=new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
| - |
|
514 |
final InputStreamResource inputStreamResource=new InputStreamResource(inputStream);
|
| - |
|
515 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| - |
|
516 |
}
|
| - |
|
517 |
|
| - |
|
518 |
private Set<String> toSerialNumbers(Set<FofoLineItemSerialNumber> fofoLineItemSerialNumbers){
|
| - |
|
519 |
Set<String> serialNumbers = new HashSet<>(fofoLineItemSerialNumbers.size());
|
| - |
|
520 |
for(FofoLineItemSerialNumber fofoLineItemSerialNumber : fofoLineItemSerialNumbers){
|
| - |
|
521 |
serialNumbers.add(fofoLineItemSerialNumber.getSerialNumber());
|
| - |
|
522 |
}
|
| - |
|
523 |
return serialNumbers;
|
| - |
|
524 |
}
|
| 413 |
}
|
525 |
}
|