| Line 13... |
Line 13... |
| 13 |
import java.util.HashSet;
|
13 |
import java.util.HashSet;
|
| 14 |
import java.util.List;
|
14 |
import java.util.List;
|
| 15 |
import java.util.Map;
|
15 |
import java.util.Map;
|
| 16 |
import java.util.Map.Entry;
|
16 |
import java.util.Map.Entry;
|
| 17 |
import java.util.Set;
|
17 |
import java.util.Set;
|
| 18 |
import java.util.stream.Collector;
|
- |
|
| 19 |
import java.util.stream.Collectors;
|
18 |
import java.util.stream.Collectors;
|
| 20 |
|
19 |
|
| 21 |
import javax.servlet.http.HttpServletRequest;
|
20 |
import javax.servlet.http.HttpServletRequest;
|
| 22 |
import javax.servlet.http.HttpServletResponse;
|
21 |
import javax.servlet.http.HttpServletResponse;
|
| 23 |
import javax.transaction.Transactional;
|
22 |
import javax.transaction.Transactional;
|
| Line 56... |
Line 55... |
| 56 |
import com.spice.profitmandi.dao.entity.logistics.ProviderDetails;
|
55 |
import com.spice.profitmandi.dao.entity.logistics.ProviderDetails;
|
| 57 |
import com.spice.profitmandi.dao.entity.logistics.ProviderTat;
|
56 |
import com.spice.profitmandi.dao.entity.logistics.ProviderTat;
|
| 58 |
import com.spice.profitmandi.dao.entity.logistics.PublicHolidays;
|
57 |
import com.spice.profitmandi.dao.entity.logistics.PublicHolidays;
|
| 59 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
58 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 60 |
import com.spice.profitmandi.dao.model.BilledOrderListModel;
|
59 |
import com.spice.profitmandi.dao.model.BilledOrderListModel;
|
| - |
|
60 |
import com.spice.profitmandi.dao.model.DelayBillingModel;
|
| 61 |
import com.spice.profitmandi.dao.model.DelayDayModel;
|
61 |
import com.spice.profitmandi.dao.model.DelayDayModel;
|
| 62 |
import com.spice.profitmandi.dao.model.DispatchNotificationModel;
|
62 |
import com.spice.profitmandi.dao.model.DispatchNotificationModel;
|
| 63 |
import com.spice.profitmandi.dao.model.MarkDeliveredModel;
|
63 |
import com.spice.profitmandi.dao.model.MarkDeliveredModel;
|
| 64 |
import com.spice.profitmandi.dao.model.ProviderDetailModel;
|
64 |
import com.spice.profitmandi.dao.model.ProviderDetailModel;
|
| 65 |
import com.spice.profitmandi.dao.model.ProviderTatModel;
|
65 |
import com.spice.profitmandi.dao.model.ProviderTatModel;
|
| Line 694... |
Line 694... |
| 694 |
|
694 |
|
| 695 |
List<Order> vorders = orderRepository.selectByAirwayBillNumber(
|
695 |
List<Order> vorders = orderRepository.selectByAirwayBillNumber(
|
| 696 |
deliveredList.stream().map(x -> x.getAirwayBillNumber()).collect(Collectors.toList()));
|
696 |
deliveredList.stream().map(x -> x.getAirwayBillNumber()).collect(Collectors.toList()));
|
| 697 |
|
697 |
|
| 698 |
List<Order> filteredorders = vorders.stream()
|
698 |
List<Order> filteredorders = vorders.stream()
|
| 699 |
.filter(x -> !x.getStatus().equals(OrderStatus.SHIPPED_FROM_WH)).collect(Collectors.toList());
|
699 |
.filter(x -> (!x.getStatus().equals(OrderStatus.SHIPPED_FROM_WH)
|
| - |
|
700 |
|| !x.getStatus().equals(OrderStatus.DELIVERY_SUCCESS)))
|
| - |
|
701 |
.collect(Collectors.toList());
|
| 700 |
|
702 |
|
| 701 |
if (!filteredorders.isEmpty()) {
|
703 |
if (!filteredorders.isEmpty()) {
|
| 702 |
throw new ProfitMandiBusinessException("Upload File", "",
|
704 |
throw new ProfitMandiBusinessException("Upload File", "",
|
| 703 |
"Order status should be shipped from warehouse");
|
705 |
"Order status should be shipped from warehouse");
|
| 704 |
|
706 |
|
| Line 770... |
Line 772... |
| 770 |
parser.close();
|
772 |
parser.close();
|
| 771 |
return records;
|
773 |
return records;
|
| 772 |
|
774 |
|
| 773 |
}
|
775 |
}
|
| 774 |
|
776 |
|
| - |
|
777 |
@RequestMapping(value = "/delayBillingTemplate", method = RequestMethod.GET)
|
| - |
|
778 |
public ResponseEntity<?> delayBillingTemplate(HttpServletRequest request) throws Exception {
|
| - |
|
779 |
List<List<?>> rows = new ArrayList<>();
|
| - |
|
780 |
|
| - |
|
781 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
|
| - |
|
782 |
.getCSVByteStream(Arrays.asList("Invoice Number", "Reason"), rows);
|
| - |
|
783 |
|
| - |
|
784 |
final HttpHeaders headers = new HttpHeaders();
|
| - |
|
785 |
headers.set("Content-Type", "text/csv");
|
| - |
|
786 |
headers.set("Content-disposition", "inline; filename=delay-billing-template.csv");
|
| - |
|
787 |
headers.setContentLength(baos.toByteArray().length);
|
| - |
|
788 |
|
| - |
|
789 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
| - |
|
790 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| - |
|
791 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| - |
|
792 |
|
| - |
|
793 |
}
|
| - |
|
794 |
|
| - |
|
795 |
@RequestMapping(value = "/getDelayBillingFileUploader", method = RequestMethod.POST)
|
| - |
|
796 |
public String getDelayBillingFileUploader(HttpServletRequest request, Model model, HttpServletResponse response,
|
| - |
|
797 |
@RequestPart MultipartFile file) throws Throwable {
|
| - |
|
798 |
|
| - |
|
799 |
LOGGER.info("file" + file.toString());
|
| - |
|
800 |
String fileName = file.getName();
|
| - |
|
801 |
|
| - |
|
802 |
String fileNames = file.getOriginalFilename();
|
| - |
|
803 |
|
| - |
|
804 |
LOGGER.info("fileName" + fileName);
|
| - |
|
805 |
LOGGER.info("fileNames" + fileNames);
|
| - |
|
806 |
|
| - |
|
807 |
List<CSVRecord> records = this.readFile(file);
|
| - |
|
808 |
|
| - |
|
809 |
List<DelayBillingModel> delayBillingModel = new ArrayList<DelayBillingModel>();
|
| - |
|
810 |
for (CSVRecord record : records) {
|
| - |
|
811 |
DelayBillingModel dbm = new DelayBillingModel();
|
| - |
|
812 |
dbm.setInvoiceNumber(record.get(0));
|
| - |
|
813 |
dbm.setReason(record.get(1));
|
| - |
|
814 |
delayBillingModel.add(dbm);
|
| - |
|
815 |
|
| - |
|
816 |
}
|
| - |
|
817 |
|
| - |
|
818 |
if (!delayBillingModel.isEmpty()) {
|
| - |
|
819 |
for (DelayBillingModel delayBilling : delayBillingModel) {
|
| - |
|
820 |
|
| - |
|
821 |
List<Order> orders = orderRepository.selectByInvoiceNumber(delayBilling.getInvoiceNumber());
|
| - |
|
822 |
|
| - |
|
823 |
for (Order order : orders) {
|
| - |
|
824 |
order.setDelayReasonText(delayBilling.getReason());
|
| - |
|
825 |
|
| - |
|
826 |
if (!order.getStatus().equals(OrderStatus.BILLED)) {
|
| - |
|
827 |
throw new ProfitMandiBusinessException("Upload File", "",
|
| - |
|
828 |
"Order" + order.getInvoiceNumber() + "status should be Billed");
|
| - |
|
829 |
|
| - |
|
830 |
}
|
| - |
|
831 |
}
|
| - |
|
832 |
|
| - |
|
833 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
834 |
sendNotificationModel.setCampaignName("Order Hold");
|
| - |
|
835 |
sendNotificationModel.setTitle("Order Hold");
|
| - |
|
836 |
sendNotificationModel.setMessage(String.format("Dear partner, your SmartDukaan ORDER "
|
| - |
|
837 |
+ delayBilling.getInvoiceNumber() + "has been delayed for " + delayBilling.getReason() + "."));
|
| - |
|
838 |
sendNotificationModel.setType("url");
|
| - |
|
839 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| - |
|
840 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| - |
|
841 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| - |
|
842 |
int userId = userAccountRepository.selectUserIdByRetailerId(orders.get(0).getRetailerId());
|
| - |
|
843 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| - |
|
844 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
845 |
}
|
| - |
|
846 |
}
|
| - |
|
847 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
848 |
|
| - |
|
849 |
return "response";
|
| - |
|
850 |
}
|
| 775 |
|
851 |
|
| 776 |
}
|
852 |
}
|