Subversion Repositories SmartDukaan

Rev

Rev 26299 | Rev 26493 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 26299 Rev 26482
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;
3
import java.io.ByteArrayInputStream;
4
import java.io.ByteArrayOutputStream;
4
import java.io.ByteArrayOutputStream;
-
 
5
import java.io.IOException;
5
import java.io.InputStream;
6
import java.io.InputStream;
6
import java.io.InputStreamReader;
7
import java.io.InputStreamReader;
-
 
8
import java.net.URISyntaxException;
7
import java.time.LocalDateTime;
9
import java.time.LocalDateTime;
8
import java.time.format.DateTimeFormatter;
10
import java.time.format.DateTimeFormatter;
9
import java.util.ArrayList;
11
import java.util.ArrayList;
10
import java.util.Arrays;
12
import java.util.Arrays;
11
import java.util.HashMap;
13
import java.util.HashMap;
Line 47... Line 49...
47
import org.springframework.web.bind.annotation.RequestParam;
49
import org.springframework.web.bind.annotation.RequestParam;
48
import org.springframework.web.bind.annotation.RequestPart;
50
import org.springframework.web.bind.annotation.RequestPart;
49
import org.springframework.web.multipart.MultipartFile;
51
import org.springframework.web.multipart.MultipartFile;
50
 
52
 
51
import com.google.gson.Gson;
53
import com.google.gson.Gson;
-
 
54
import com.mongodb.MongoClient;
52
import com.spice.profitmandi.common.enumuration.MessageType;
55
import com.spice.profitmandi.common.enumuration.MessageType;
53
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
56
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
54
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
57
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
55
import com.spice.profitmandi.common.model.CustomRetailer;
58
import com.spice.profitmandi.common.model.CustomRetailer;
56
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
59
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
Line 74... Line 77...
74
import com.spice.profitmandi.dao.entity.transaction.NotifyCancel;
77
import com.spice.profitmandi.dao.entity.transaction.NotifyCancel;
75
import com.spice.profitmandi.dao.entity.transaction.NotifyColorChange;
78
import com.spice.profitmandi.dao.entity.transaction.NotifyColorChange;
76
import com.spice.profitmandi.dao.entity.transaction.NotifyMessage;
79
import com.spice.profitmandi.dao.entity.transaction.NotifyMessage;
77
import com.spice.profitmandi.dao.entity.transaction.NotifyOrder;
80
import com.spice.profitmandi.dao.entity.transaction.NotifyOrder;
78
import com.spice.profitmandi.dao.entity.transaction.Order;
81
import com.spice.profitmandi.dao.entity.transaction.Order;
-
 
82
import com.spice.profitmandi.dao.model.ContentPojo;
79
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
83
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
80
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
84
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
81
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
85
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
82
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
86
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
-
 
87
import com.spice.profitmandi.dao.repository.dtr.Mongo;
83
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
88
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
84
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
89
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
85
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
90
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
86
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
91
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
87
import com.spice.profitmandi.dao.repository.inventory.NotifyStatus;
92
import com.spice.profitmandi.dao.repository.inventory.NotifyStatus;
Line 96... Line 101...
96
import com.spice.profitmandi.service.user.RetailerService;
101
import com.spice.profitmandi.service.user.RetailerService;
97
import com.spice.profitmandi.web.model.LoginDetails;
102
import com.spice.profitmandi.web.model.LoginDetails;
98
import com.spice.profitmandi.web.util.CookiesProcessor;
103
import com.spice.profitmandi.web.util.CookiesProcessor;
99
import com.spice.profitmandi.web.util.MVCResponseSender;
104
import com.spice.profitmandi.web.util.MVCResponseSender;
100
 
105
 
101
 
-
 
102
 
-
 
103
import in.shop2020.model.v1.order.OrderStatus;
106
import in.shop2020.model.v1.order.OrderStatus;
104
import in.shop2020.model.v1.order.TransactionServiceException;
107
import in.shop2020.model.v1.order.TransactionServiceException;
105
 
108
 
106
@Controller
109
@Controller
107
@Transactional(rollbackFor = Throwable.class)
110
@Transactional(rollbackFor = Throwable.class)
108
public class InventoryController {
111
public class InventoryController {
109
 
112
 
110
	private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
113
	private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
111
	
114
 
112
	private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy H:m:s");
115
	private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy H:m:s");
113
 
116
 
114
	@Autowired
117
	@Autowired
115
	private CookiesProcessor cookiesProcessor;
118
	private CookiesProcessor cookiesProcessor;
116
 
119
 
Line 179... Line 182...
179
	JavaMailSender mailSender;
182
	JavaMailSender mailSender;
180
 
183
 
181
	@Autowired
184
	@Autowired
182
	private NotifyCancelOrderRepository notifyCancelOrderRepository;
185
	private NotifyCancelOrderRepository notifyCancelOrderRepository;
183
 
186
 
-
 
187
	@Autowired
-
 
188
	private Mongo mongoClient;
-
 
189
 
184
	@RequestMapping(value = "/getCurrentInventorySnapshot")
190
	@RequestMapping(value = "/getCurrentInventorySnapshot")
185
	public String getCurrentAvailability(HttpServletRequest request,
191
	public String getCurrentAvailability(HttpServletRequest request,
186
			@RequestParam(name = "offset", defaultValue = "0") int offset,
192
			@RequestParam(name = "offset", defaultValue = "0") int offset,
187
			@RequestParam(name = "limit", defaultValue = "10") int limit,
193
			@RequestParam(name = "limit", defaultValue = "10") int limit,
188
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
194
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
Line 478... Line 484...
478
	}
484
	}
479
 
485
 
480
	@PostMapping(value = "/imei/upload")
486
	@PostMapping(value = "/imei/upload")
481
	public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
487
	public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
482
			throws Exception {
488
			throws Exception {
-
 
489
		/*
483
		/*if(brand==null) {
490
		 * if(brand==null) { throw new
484
			throw new ProfitMandiBusinessException("Please select brand", "Brand empty", "Brand required");
491
		 * ProfitMandiBusinessException("Please select brand", "Brand empty",
-
 
492
		 * "Brand required"); }
485
		}*/
493
		 */
486
		List<CSVRecord> masterDataList = readFile(file);
494
		List<CSVRecord> masterDataList = readFile(file);
487
		
-
 
488
 
495
 
489
		Map<String, LocalDateTime> imeisActivationMap = masterDataList.stream().collect(Collectors.toMap(
496
		Map<String, LocalDateTime> imeisActivationMap = masterDataList.stream()
490
				x->x.get(0).trim(),
497
				.collect(Collectors.toMap(x -> x.get(0).trim(), x -> {
491
				x-> {
-
 
492
					if(!StringUtils.isEmpty(x.get(1).trim())) {
498
					if (!StringUtils.isEmpty(x.get(1).trim())) {
493
						return LocalDateTime.parse((String)(x.get(1).trim()), formatter);
499
						return LocalDateTime.parse((String) (x.get(1).trim()), formatter);
494
					} else {
500
					} else {
495
						return null;
501
						return null;
496
					}
502
					}
497
				}));
503
				}));
498
		inventoryService.addActivatedImeis(imeisActivationMap);
504
		inventoryService.addActivatedImeis(imeisActivationMap);
Line 506... Line 512...
506
			records = parser.getRecords();
512
			records = parser.getRecords();
507
			if (records.size() < 2) {
513
			if (records.size() < 2) {
508
				throw new ProfitMandiBusinessException("Uploaded File", "", "No records Found");
514
				throw new ProfitMandiBusinessException("Uploaded File", "", "No records Found");
509
			}
515
			}
510
			records.remove(0);
516
			records.remove(0);
511
		} catch(Exception e) {
517
		} catch (Exception e) {
512
			throw new ProfitMandiBusinessException("Parsing Failed", "parse failed", "file parse failed");
518
			throw new ProfitMandiBusinessException("Parsing Failed", "parse failed", "file parse failed");
513
		}
519
		}
514
		return records;
520
		return records;
515
	}
521
	}
516
 
522
 
Line 742... Line 748...
742
		sendNotificationModel.setCampaignName("Order Cancellation");
748
		sendNotificationModel.setCampaignName("Order Cancellation");
743
		sendNotificationModel.setTitle(String.format("Order %s %d(Pcs) cancelled", item.getItemDescription(),
749
		sendNotificationModel.setTitle(String.format("Order %s %d(Pcs) cancelled", item.getItemDescription(),
744
				order.getLineItem().getQuantity()));
750
				order.getLineItem().getQuantity()));
745
		sendNotificationModel.setType("url");
751
		sendNotificationModel.setType("url");
746
		sendNotificationModel.setMessage(reason);
752
		sendNotificationModel.setMessage(reason);
747
		sendNotificationModel.setUrl("http://app.smartdukaan.com/pages/home/orderDetails");
753
		sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/orderDetails");
748
		sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
754
		sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
749
		sendNotificationModel.setMessageType(MessageType.notification);
755
		sendNotificationModel.setMessageType(MessageType.notification);
750
		int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
756
		int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
751
		sendNotificationModel.setUserIds(Arrays.asList(userId));
757
		sendNotificationModel.setUserIds(Arrays.asList(userId));
752
		notificationService.sendNotification(sendNotificationModel);
758
		notificationService.sendNotification(sendNotificationModel);
Line 972... Line 978...
972
			SendNotificationModel sendNotificationModel = new SendNotificationModel();
978
			SendNotificationModel sendNotificationModel = new SendNotificationModel();
973
			sendNotificationModel.setCampaignName("Notify Partner");
979
			sendNotificationModel.setCampaignName("Notify Partner");
974
			sendNotificationModel.setMessage(notifyOrderModel.getMessage());
980
			sendNotificationModel.setMessage(notifyOrderModel.getMessage());
975
			sendNotificationModel.setType("url");
981
			sendNotificationModel.setType("url");
976
			sendNotificationModel.setTitle("Alert");
982
			sendNotificationModel.setTitle("Alert");
977
			sendNotificationModel.setUrl("http://app.smartdukaan.com/pages/home/notifyCancelOrder");
983
			sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifyCancelOrder");
978
			sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
984
			sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
979
			sendNotificationModel.setMessageType(MessageType.notification);
985
			sendNotificationModel.setMessageType(MessageType.notification);
980
			int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
986
			int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
981
 
987
 
982
			sendNotificationModel.setUserIds(Arrays.asList(userId));
988
			sendNotificationModel.setUserIds(Arrays.asList(userId));
Line 1052... Line 1058...
1052
		}
1058
		}
1053
 
1059
 
1054
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
1060
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
1055
		return "response";
1061
		return "response";
1056
	}
1062
	}
-
 
1063
 
-
 
1064
	@RequestMapping(value = "/getProducts", method = RequestMethod.GET)
-
 
1065
	public String getProducts(HttpServletRequest request, Model model)
-
 
1066
			throws ProfitMandiBusinessException, URISyntaxException, IOException {
-
 
1067
 
-
 
1068
		return "product-detail";
-
 
1069
	}
-
 
1070
 
-
 
1071
	@RequestMapping(value = "/getProductInfo", method = RequestMethod.GET)
-
 
1072
	public String getProductInfo(HttpServletRequest request, long catalogId, Model model) throws Exception {
-
 
1073
		ContentPojo cp = mongoClient.getEntityById(catalogId);
-
 
1074
		List<String> cps = cp.getKeySpecs();
-
 
1075
		LOGGER.info("cp" + cp.getDefaultImageUrl());
-
 
1076
	     model.addAttribute("cp", cp);
-
 
1077
	     model.addAttribute("response", mvcResponseSender.createResponseString(true));
-
 
1078
		return "product-info";
-
 
1079
	}
1057
}
1080
}
1058
1081