Subversion Repositories SmartDukaan

Rev

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

Rev 30683 Rev 30827
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.IOException;
-
 
6
import java.io.InputStream;
-
 
7
import java.io.InputStreamReader;
-
 
8
import java.net.URISyntaxException;
-
 
9
import java.time.LocalDate;
-
 
10
import java.time.LocalDateTime;
-
 
11
import java.time.YearMonth;
-
 
12
import java.time.format.DateTimeFormatter;
-
 
13
import java.time.temporal.ChronoUnit;
-
 
14
import java.util.ArrayList;
-
 
15
import java.util.Arrays;
-
 
16
import java.util.Collection;
-
 
17
import java.util.Comparator;
-
 
18
import java.util.HashMap;
-
 
19
import java.util.HashSet;
-
 
20
import java.util.Iterator;
-
 
21
import java.util.List;
-
 
22
import java.util.Map;
-
 
23
import java.util.Optional;
-
 
24
import java.util.Set;
-
 
25
import java.util.stream.Collectors;
-
 
26
import java.util.stream.Stream;
-
 
27
 
-
 
28
import javax.servlet.http.HttpServletRequest;
-
 
29
import javax.servlet.http.HttpServletResponse;
-
 
30
 
-
 
31
import org.apache.commons.csv.CSVFormat;
-
 
32
import org.apache.commons.csv.CSVParser;
-
 
33
import org.apache.commons.csv.CSVRecord;
-
 
34
import org.apache.commons.io.FileUtils;
-
 
35
import org.apache.commons.lang3.StringUtils;
-
 
36
import org.apache.logging.log4j.LogManager;
-
 
37
import org.apache.logging.log4j.Logger;
-
 
38
import org.apache.thrift.TException;
-
 
39
import org.json.JSONObject;
-
 
40
import org.springframework.beans.factory.annotation.Autowired;
-
 
41
import org.springframework.beans.factory.annotation.Qualifier;
-
 
42
import org.springframework.beans.factory.annotation.Value;
-
 
43
import org.springframework.core.io.ByteArrayResource;
-
 
44
import org.springframework.core.io.ClassPathResource;
-
 
45
import org.springframework.core.io.InputStreamResource;
-
 
46
import org.springframework.http.HttpHeaders;
-
 
47
import org.springframework.http.HttpStatus;
-
 
48
import org.springframework.http.MediaType;
-
 
49
import org.springframework.http.ResponseEntity;
-
 
50
import org.springframework.mail.javamail.JavaMailSender;
-
 
51
import org.springframework.stereotype.Controller;
-
 
52
import org.springframework.transaction.annotation.Transactional;
-
 
53
import org.springframework.ui.Model;
-
 
54
import org.springframework.web.bind.annotation.GetMapping;
-
 
55
import org.springframework.web.bind.annotation.PostMapping;
-
 
56
import org.springframework.web.bind.annotation.RequestBody;
-
 
57
import org.springframework.web.bind.annotation.RequestMapping;
-
 
58
import org.springframework.web.bind.annotation.RequestMethod;
-
 
59
import org.springframework.web.bind.annotation.RequestParam;
-
 
60
import org.springframework.web.bind.annotation.RequestPart;
-
 
61
import org.springframework.web.multipart.MultipartFile;
-
 
62
 
-
 
63
import com.fasterxml.jackson.databind.ObjectMapper;
3
import com.fasterxml.jackson.databind.ObjectMapper;
64
import com.google.gson.Gson;
4
import com.google.gson.Gson;
65
import com.spice.profitmandi.common.enumuration.MessageType;
5
import com.spice.profitmandi.common.enumuration.MessageType;
66
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
6
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
67
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
-
 
68
import com.spice.profitmandi.common.model.CustomRetailer;
7
import com.spice.profitmandi.common.model.*;
69
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
-
 
70
import com.spice.profitmandi.common.model.InvoicePdfModel;
-
 
71
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
-
 
72
import com.spice.profitmandi.common.model.NotifyItemIdModel;
-
 
73
import com.spice.profitmandi.common.model.NotifyOrderIdModel;
-
 
74
import com.spice.profitmandi.common.model.NotifyOrderModel;
-
 
75
import com.spice.profitmandi.common.model.OrderCancellationModel;
-
 
76
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
77
import com.spice.profitmandi.common.model.SendNotificationModel;
-
 
78
import com.spice.profitmandi.common.util.ExcelUtils;
8
import com.spice.profitmandi.common.util.ExcelUtils;
79
import com.spice.profitmandi.common.util.PdfUtils;
9
import com.spice.profitmandi.common.util.PdfUtils;
80
import com.spice.profitmandi.common.util.Utils;
10
import com.spice.profitmandi.common.util.Utils;
81
import com.spice.profitmandi.common.util.Utils.Attachment;
11
import com.spice.profitmandi.common.util.Utils.Attachment;
82
import com.spice.profitmandi.dao.entity.auth.AuthUser;
12
import com.spice.profitmandi.dao.entity.auth.AuthUser;
83
import com.spice.profitmandi.dao.entity.catalog.ComboMappedModel;
-
 
84
import com.spice.profitmandi.dao.entity.catalog.ComboModel;
-
 
85
import com.spice.profitmandi.dao.entity.catalog.FocusedModelByPassRequest;
-
 
86
import com.spice.profitmandi.dao.entity.catalog.HighDemandItem;
-
 
87
import com.spice.profitmandi.dao.entity.catalog.Item;
13
import com.spice.profitmandi.dao.entity.catalog.*;
88
import com.spice.profitmandi.dao.entity.catalog.TagListing;
-
 
89
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
-
 
90
import com.spice.profitmandi.dao.entity.cs.Position;
14
import com.spice.profitmandi.dao.entity.cs.Position;
91
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
15
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
92
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
16
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
93
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
17
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
94
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
18
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
95
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
19
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
96
import com.spice.profitmandi.dao.entity.transaction.NotifyCancel;
-
 
97
import com.spice.profitmandi.dao.entity.transaction.NotifyColorChange;
-
 
98
import com.spice.profitmandi.dao.entity.transaction.NotifyMessage;
-
 
99
import com.spice.profitmandi.dao.entity.transaction.NotifyOrder;
-
 
100
import com.spice.profitmandi.dao.entity.transaction.Order;
20
import com.spice.profitmandi.dao.entity.transaction.*;
101
import com.spice.profitmandi.dao.enumuration.catalog.ByPassRequestStatus;
21
import com.spice.profitmandi.dao.enumuration.catalog.ByPassRequestStatus;
102
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
22
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
103
import com.spice.profitmandi.dao.model.BrandItemWiseTertiaryModel;
-
 
104
import com.spice.profitmandi.dao.model.BrandRegionModel;
-
 
105
import com.spice.profitmandi.dao.model.BrandWiseTertiaryModel;
-
 
106
import com.spice.profitmandi.dao.model.ContentPojo;
23
import com.spice.profitmandi.dao.model.*;
107
import com.spice.profitmandi.dao.model.ImeiActivationTimestampModel;
-
 
108
import com.spice.profitmandi.dao.model.OpenPoItemModel;
-
 
109
import com.spice.profitmandi.dao.model.OpenPoModel;
-
 
110
import com.spice.profitmandi.dao.model.OurPurchaseItemModel;
-
 
111
import com.spice.profitmandi.dao.model.OurPurchaseModel;
-
 
112
import com.spice.profitmandi.dao.model.SecondaeryOrderDateRange;
-
 
113
import com.spice.profitmandi.dao.model.SecondaryOrderBillingModel;
-
 
114
import com.spice.profitmandi.dao.model.SecondaryOrderItemBillingModel;
-
 
115
import com.spice.profitmandi.dao.model.SecondaryWarehouseWiseOrderBilllingModel;
-
 
116
import com.spice.profitmandi.dao.model.Specification;
-
 
117
import com.spice.profitmandi.dao.model.SpecificationGroup;
-
 
118
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
24
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
119
import com.spice.profitmandi.dao.repository.catalog.ComboMappedModelRepository;
-
 
120
import com.spice.profitmandi.dao.repository.catalog.ComboModelRepository;
-
 
121
import com.spice.profitmandi.dao.repository.catalog.FocusedModelByPassRepository;
-
 
122
import com.spice.profitmandi.dao.repository.catalog.HighDemandItemsRepository;
-
 
123
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
25
import com.spice.profitmandi.dao.repository.catalog.*;
124
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
-
 
125
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
-
 
126
import com.spice.profitmandi.dao.repository.cs.CsService;
26
import com.spice.profitmandi.dao.repository.cs.CsService;
127
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
27
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
128
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
28
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
129
import com.spice.profitmandi.dao.repository.dtr.Mongo;
29
import com.spice.profitmandi.dao.repository.dtr.Mongo;
130
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
30
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
131
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
31
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
132
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
-
 
133
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
-
 
134
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
32
import com.spice.profitmandi.dao.repository.fofo.*;
135
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
-
 
136
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
-
 
137
import com.spice.profitmandi.dao.repository.inventory.NotifyStatus;
33
import com.spice.profitmandi.dao.repository.inventory.NotifyStatus;
138
import com.spice.profitmandi.dao.repository.transaction.NotifyCancelOrderRepository;
-
 
139
import com.spice.profitmandi.dao.repository.transaction.NotifyColorChangeRepository;
-
 
140
import com.spice.profitmandi.dao.repository.transaction.NotifyItemRepository;
-
 
141
import com.spice.profitmandi.dao.repository.transaction.NotifyMessageRepository;
-
 
142
import com.spice.profitmandi.dao.repository.transaction.NotifyOrderRespository;
-
 
143
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
34
import com.spice.profitmandi.dao.repository.transaction.*;
144
import com.spice.profitmandi.dao.repository.warehouse.WarehousePurchaseOrderRepository;
35
import com.spice.profitmandi.dao.repository.warehouse.WarehousePurchaseOrderRepository;
145
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
36
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
146
import com.spice.profitmandi.service.NotificationService;
37
import com.spice.profitmandi.service.NotificationService;
147
import com.spice.profitmandi.service.inventory.Combo;
38
import com.spice.profitmandi.service.inventory.Combo;
148
import com.spice.profitmandi.service.inventory.InventoryService;
39
import com.spice.profitmandi.service.inventory.InventoryService;
Line 150... Line 41...
150
import com.spice.profitmandi.service.order.OrderService;
41
import com.spice.profitmandi.service.order.OrderService;
151
import com.spice.profitmandi.service.user.RetailerService;
42
import com.spice.profitmandi.service.user.RetailerService;
152
import com.spice.profitmandi.web.model.LoginDetails;
43
import com.spice.profitmandi.web.model.LoginDetails;
153
import com.spice.profitmandi.web.util.CookiesProcessor;
44
import com.spice.profitmandi.web.util.CookiesProcessor;
154
import com.spice.profitmandi.web.util.MVCResponseSender;
45
import com.spice.profitmandi.web.util.MVCResponseSender;
155
 
-
 
156
import in.shop2020.model.v1.order.OrderStatus;
46
import in.shop2020.model.v1.order.OrderStatus;
157
import in.shop2020.model.v1.order.TransactionServiceException;
47
import in.shop2020.model.v1.order.TransactionServiceException;
-
 
48
import org.apache.commons.csv.CSVFormat;
-
 
49
import org.apache.commons.csv.CSVParser;
-
 
50
import org.apache.commons.csv.CSVRecord;
-
 
51
import org.apache.commons.io.FileUtils;
-
 
52
import org.apache.commons.lang3.StringUtils;
-
 
53
import org.apache.logging.log4j.LogManager;
-
 
54
import org.apache.logging.log4j.Logger;
-
 
55
import org.apache.thrift.TException;
-
 
56
import org.json.JSONObject;
-
 
57
import org.springframework.beans.factory.annotation.Autowired;
-
 
58
import org.springframework.beans.factory.annotation.Qualifier;
-
 
59
import org.springframework.beans.factory.annotation.Value;
-
 
60
import org.springframework.core.io.ByteArrayResource;
-
 
61
import org.springframework.core.io.ClassPathResource;
-
 
62
import org.springframework.core.io.InputStreamResource;
-
 
63
import org.springframework.http.HttpHeaders;
-
 
64
import org.springframework.http.HttpStatus;
-
 
65
import org.springframework.http.MediaType;
-
 
66
import org.springframework.http.ResponseEntity;
-
 
67
import org.springframework.mail.javamail.JavaMailSender;
-
 
68
import org.springframework.stereotype.Controller;
-
 
69
import org.springframework.transaction.annotation.Transactional;
-
 
70
import org.springframework.ui.Model;
-
 
71
import org.springframework.web.bind.annotation.*;
-
 
72
import org.springframework.web.multipart.MultipartFile;
-
 
73
 
-
 
74
import javax.servlet.http.HttpServletRequest;
-
 
75
import javax.servlet.http.HttpServletResponse;
-
 
76
import java.io.*;
-
 
77
import java.net.URISyntaxException;
-
 
78
import java.time.LocalDate;
-
 
79
import java.time.LocalDateTime;
-
 
80
import java.time.YearMonth;
-
 
81
import java.time.format.DateTimeFormatter;
-
 
82
import java.time.temporal.ChronoUnit;
-
 
83
import java.util.*;
-
 
84
import java.util.stream.Collectors;
-
 
85
import java.util.stream.Stream;
158
 
86
 
159
@Controller
87
@Controller
160
@Transactional(rollbackFor = Throwable.class)
88
@Transactional(rollbackFor = Throwable.class)
161
public class InventoryController {
89
public class InventoryController {
162
 
90
 
Line 1374... Line 1302...
1374
		long poSevendaysValue = 0;
1302
		long poSevendaysValue = 0;
1375
		long poTodayQty = 0;
1303
		long poTodayQty = 0;
1376
		long poThreedaysQty = 0;
1304
		long poThreedaysQty = 0;
1377
		long poSevendaysQty = 0;
1305
		long poSevendaysQty = 0;
1378
 
1306
 
1379
		List<OpenPoModel> openPO = warehousePurchaseOrderRepository.selectOpenPol(warehouseIds);
1307
		List<OpenPoModel> openPO = warehousePurchaseOrderRepository.selectOpenPo(warehouseIds);
1380
		for (OpenPoModel po : openPO) {
1308
		for (OpenPoModel po : openPO) {
1381
			poTodayValue += po.getTodayValue();
1309
			poTodayValue += po.getTodayValue();
1382
			poThreedaysValue += po.getThreedaysValue();
1310
			poThreedaysValue += po.getThreedaysValue();
1383
			poSevendaysValue += po.getSevendaysValue();
1311
			poSevendaysValue += po.getSevendaysValue();
1384
			poTodayQty += po.getTodayQty();
1312
			poTodayQty += po.getTodayQty();
Line 1531... Line 1459...
1531
			warehouseIds.addAll(warehouseMap.keySet());
1459
			warehouseIds.addAll(warehouseMap.keySet());
1532
		}
1460
		}
1533
		LOGGER.info("brand" + brand);
1461
		LOGGER.info("brand" + brand);
1534
 
1462
 
1535
		if (brand.contains("Total Values")) {
1463
		if (brand.contains("Total Values")) {
1536
			List<String> poBrands = warehousePurchaseOrderRepository.selectOpenPol(warehouseIds).stream()
1464
			List<String> poBrands = warehousePurchaseOrderRepository.selectOpenPo(warehouseIds).stream()
1537
					.map(x -> x.getBrand()).collect(Collectors.toList());
1465
					.map(x -> x.getBrand()).collect(Collectors.toList());
1538
 
1466
 
1539
			brand.addAll(poBrands);
1467
			brand.addAll(poBrands);
1540
		}
1468
		}
1541
 
1469