| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.controllers;
|
1 |
package in.shop2020.support.controllers;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.model.v1.catalog.Amazonlisted;
|
- |
|
| 4 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
3 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
| - |
|
4 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
| - |
|
5 |
import in.shop2020.model.v1.catalog.Item;
|
| 5 |
import in.shop2020.model.v1.catalog.SnapdealItem;
|
6 |
import in.shop2020.model.v1.catalog.SnapdealItem;
|
| - |
|
7 |
import in.shop2020.model.v1.catalog.SnapdealItemDetails;
|
| 6 |
import in.shop2020.model.v1.order.AmazonFbaSalesSnapshot;
|
8 |
import in.shop2020.model.v1.order.AmazonFbaSalesSnapshot;
|
| 7 |
import in.shop2020.model.v1.order.SnapdealOrder;
|
9 |
import in.shop2020.model.v1.order.SnapdealOrder;
|
| 8 |
import in.shop2020.support.utils.ReportsUtils;
|
10 |
import in.shop2020.support.utils.ReportsUtils;
|
| 9 |
import in.shop2020.thrift.clients.CatalogClient;
|
11 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 10 |
import in.shop2020.thrift.clients.TransactionClient;
|
12 |
import in.shop2020.thrift.clients.TransactionClient;
|
| Line 15... |
Line 17... |
| 15 |
import java.io.FileNotFoundException;
|
17 |
import java.io.FileNotFoundException;
|
| 16 |
import java.io.FileOutputStream;
|
18 |
import java.io.FileOutputStream;
|
| 17 |
import java.io.FileWriter;
|
19 |
import java.io.FileWriter;
|
| 18 |
import java.io.IOException;
|
20 |
import java.io.IOException;
|
| 19 |
import java.io.InputStream;
|
21 |
import java.io.InputStream;
|
| - |
|
22 |
import java.text.DecimalFormat;
|
| 20 |
import java.util.ArrayList;
|
23 |
import java.util.ArrayList;
|
| - |
|
24 |
import java.util.Arrays;
|
| 21 |
import java.util.HashMap;
|
25 |
import java.util.HashMap;
|
| 22 |
import java.util.List;
|
26 |
import java.util.List;
|
| 23 |
import java.util.Map;
|
27 |
import java.util.Map;
|
| 24 |
|
28 |
|
| 25 |
import javax.servlet.ServletContext;
|
29 |
import javax.servlet.ServletContext;
|
| Line 39... |
Line 43... |
| 39 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
43 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
| 40 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
44 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
| 41 |
import org.apache.struts2.util.ServletContextAware;
|
45 |
import org.apache.struts2.util.ServletContextAware;
|
| 42 |
import org.apache.thrift.TException;
|
46 |
import org.apache.thrift.TException;
|
| 43 |
import org.apache.thrift.transport.TTransportException;
|
47 |
import org.apache.thrift.transport.TTransportException;
|
| - |
|
48 |
import org.json.JSONException;
|
| - |
|
49 |
import org.json.JSONObject;
|
| 44 |
import org.slf4j.Logger;
|
50 |
import org.slf4j.Logger;
|
| 45 |
import org.slf4j.LoggerFactory;
|
51 |
import org.slf4j.LoggerFactory;
|
| 46 |
|
52 |
|
| 47 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
53 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
| 48 |
|
54 |
|
| - |
|
55 |
@SuppressWarnings("unused")
|
| - |
|
56 |
|
| - |
|
57 |
@InterceptorRefs({
|
| - |
|
58 |
@InterceptorRef("defaultStack"),
|
| - |
|
59 |
@InterceptorRef("login")
|
| - |
|
60 |
})
|
| - |
|
61 |
|
| 49 |
public class SnapdealListController extends ValidationAwareSupport implements ServletRequestAware ,ServletResponseAware, ServletContextAware{
|
62 |
public class SnapdealListController extends ValidationAwareSupport implements ServletRequestAware ,ServletResponseAware, ServletContextAware{
|
| - |
|
63 |
/**
|
| - |
|
64 |
*
|
| - |
|
65 |
*/
|
| - |
|
66 |
private static final long serialVersionUID = 1L;
|
| - |
|
67 |
|
| - |
|
68 |
|
| 50 |
private static Logger logger = LoggerFactory.getLogger(SnapdealListController.class);
|
69 |
private static Logger logger = LoggerFactory.getLogger(SnapdealListController.class);
|
| 51 |
|
70 |
|
| 52 |
|
71 |
|
| 53 |
private HttpServletRequest request;
|
72 |
private HttpServletRequest request;
|
| 54 |
private HttpServletResponse response;
|
73 |
private HttpServletResponse response;
|
| Line 61... |
Line 80... |
| 61 |
private String warehouseId;
|
80 |
private String warehouseId;
|
| 62 |
private File file;
|
81 |
private File file;
|
| 63 |
private String errMsg;
|
82 |
private String errMsg;
|
| 64 |
private String next;
|
83 |
private String next;
|
| 65 |
private String id;
|
84 |
private String id;
|
| - |
|
85 |
private String searchText;
|
| - |
|
86 |
private List<SnapdealItemDetails> snapdealItems;
|
| - |
|
87 |
private long searchCount;
|
| - |
|
88 |
private long totalCount;
|
| - |
|
89 |
private String sellingPrice;
|
| - |
|
90 |
private String transferPrice;
|
| - |
|
91 |
private String webisteMrp;
|
| - |
|
92 |
private String webisteSellingPrice;
|
| - |
|
93 |
private String isListedOnSnapdeal;
|
| - |
|
94 |
private String commission;
|
| - |
|
95 |
private String serviceTax;
|
| - |
|
96 |
private String courierCost;
|
| - |
|
97 |
private JSONObject itemObj;
|
| - |
|
98 |
private String isSuppressInventoryFeed;
|
| - |
|
99 |
private String isSuppressPriceFeed;
|
| - |
|
100 |
|
| - |
|
101 |
|
| 66 |
|
102 |
|
| 67 |
public String index() {
|
103 |
public String index() {
|
| 68 |
if (!ReportsUtils.canAccessReport((Long) session.getAttribute(ReportsUtils.ROLE),request.getServletPath())) {
|
104 |
if (!ReportsUtils.canAccessReport((Long) session.getAttribute(ReportsUtils.ROLE),request.getServletPath())) {
|
| 69 |
return "authfail";
|
105 |
return "authfail";
|
| 70 |
}
|
106 |
}
|
| 71 |
return "index";
|
107 |
return "index";
|
| 72 |
}
|
108 |
}
|
| 73 |
|
109 |
|
| - |
|
110 |
public String edit() {
|
| - |
|
111 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
|
| - |
|
112 |
return "authfail";
|
| - |
|
113 |
}
|
| - |
|
114 |
return "edit";
|
| - |
|
115 |
}
|
| - |
|
116 |
|
| - |
|
117 |
public String fetchItems() throws TException {
|
| - |
|
118 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| - |
|
119 |
if (searchText.length() == 0) {
|
| - |
|
120 |
snapdealItems = CatalogClient.getSnapdealItems(Long.valueOf(next), 10);
|
| - |
|
121 |
totalCount = CatalogClient.getCountForSnapdealItems();
|
| - |
|
122 |
setSearchCount(totalCount);
|
| - |
|
123 |
} else {
|
| - |
|
124 |
List<String> subString = Arrays.asList(searchText.split(" "));
|
| - |
|
125 |
snapdealItems = CatalogClient.searchSnapdealItems(subString,Long.valueOf(next), 10);
|
| - |
|
126 |
totalCount = CatalogClient.getCountForSnapdealItems();
|
| - |
|
127 |
searchCount = CatalogClient.getSnapdealSearchResultCount(subString);
|
| - |
|
128 |
}
|
| - |
|
129 |
return "snapdeal-item-table";
|
| - |
|
130 |
}
|
| - |
|
131 |
|
| - |
|
132 |
public SnapdealItemDetails fetchItemDetail() throws NumberFormatException, TException {
|
| - |
|
133 |
Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| - |
|
134 |
return CatalogClient.getSnapdealItemDetails(Long.valueOf(id));
|
| - |
|
135 |
}
|
| - |
|
136 |
|
| 74 |
public String uploadBulkSheet(){
|
137 |
public String uploadBulkSheet(){
|
| 75 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
138 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 76 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
139 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 77 |
return "authfail";
|
140 |
return "authfail";
|
| 78 |
}
|
141 |
}
|
| 79 |
return "snapdeal-bulk-upload";
|
142 |
return "snapdeal-bulk-upload";
|
| 80 |
}
|
143 |
}
|
| - |
|
144 |
|
| - |
|
145 |
public String update() throws NumberFormatException, TException{
|
| - |
|
146 |
Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| - |
|
147 |
SnapdealItem snapdealItem = catalogClient.getSnapdealItem(Long.valueOf(itemId));
|
| - |
|
148 |
boolean commit = false;
|
| - |
|
149 |
if (snapdealItem.getWarehouseId()!=Long.valueOf(warehouseId)){
|
| - |
|
150 |
snapdealItem.setWarehouseId(Long.valueOf(warehouseId));
|
| - |
|
151 |
commit = true;
|
| - |
|
152 |
}
|
| - |
|
153 |
if (snapdealItem.isIsListedOnSnapdeal()!=Boolean.valueOf(isListedOnSnapdeal)){
|
| - |
|
154 |
snapdealItem.setIsListedOnSnapdeal(Boolean.valueOf(isListedOnSnapdeal));
|
| - |
|
155 |
commit = true;
|
| - |
|
156 |
}
|
| - |
|
157 |
if (snapdealItem.isSuppressInventoryFeed()!=Boolean.valueOf(isSuppressInventoryFeed)){
|
| - |
|
158 |
snapdealItem.setSuppressInventoryFeed(Boolean.valueOf(isSuppressInventoryFeed));
|
| - |
|
159 |
commit = true;
|
| - |
|
160 |
}
|
| - |
|
161 |
if (snapdealItem.isSuppressPriceFeed()!=Boolean.valueOf(isSuppressPriceFeed)){
|
| - |
|
162 |
snapdealItem.setSuppressPriceFeed(Boolean.valueOf(isSuppressPriceFeed));
|
| - |
|
163 |
commit = true;
|
| - |
|
164 |
}
|
| - |
|
165 |
if (snapdealItem.getTransferPrice()!=Double.valueOf(transferPrice)){
|
| - |
|
166 |
snapdealItem.setTransferPrice(Double.valueOf(transferPrice));
|
| - |
|
167 |
commit = true;
|
| - |
|
168 |
}
|
| - |
|
169 |
if (snapdealItem.getExceptionPrice()!=Double.valueOf(exceptionPrice)){
|
| - |
|
170 |
snapdealItem.setExceptionPrice(Double.valueOf(exceptionPrice));
|
| - |
|
171 |
commit = true;
|
| - |
|
172 |
}
|
| - |
|
173 |
if (snapdealItem.getSellingPrice()!=Double.valueOf(sellingPrice)){
|
| - |
|
174 |
snapdealItem.setSellingPrice(Double.valueOf(sellingPrice));
|
| - |
|
175 |
commit = true;
|
| - |
|
176 |
}
|
| - |
|
177 |
if (snapdealItem.getCourierCost()!=Double.valueOf(courierCost)){
|
| - |
|
178 |
snapdealItem.setCourierCost(Double.valueOf(courierCost));
|
| - |
|
179 |
commit = true;
|
| - |
|
180 |
}
|
| - |
|
181 |
if (snapdealItem.getCommission()!=Double.valueOf(commission)){
|
| - |
|
182 |
snapdealItem.setCommission(Double.valueOf(commission));
|
| - |
|
183 |
commit = true;
|
| - |
|
184 |
}
|
| - |
|
185 |
if (snapdealItem.getServiceTax()!=Double.valueOf(serviceTax)){
|
| - |
|
186 |
snapdealItem.setServiceTax(Double.valueOf(serviceTax));
|
| - |
|
187 |
commit = true;
|
| - |
|
188 |
}
|
| - |
|
189 |
if (commit){
|
| - |
|
190 |
catalogClient.addOrUpdateSnapdealItem(snapdealItem);
|
| - |
|
191 |
}
|
| - |
|
192 |
return "index";
|
| - |
|
193 |
}
|
| - |
|
194 |
|
| - |
|
195 |
public String addNewItem() throws TException{
|
| - |
|
196 |
SnapdealItem snapdealItem = new SnapdealItem();
|
| - |
|
197 |
snapdealItem.setItem_id(Long.valueOf(itemId));
|
| - |
|
198 |
snapdealItem.setWarehouseId(Long.valueOf(warehouseId));
|
| - |
|
199 |
snapdealItem.setIsListedOnSnapdeal(Boolean.valueOf(isListedOnSnapdeal));
|
| - |
|
200 |
snapdealItem.setSuppressInventoryFeed(Boolean.valueOf(isSuppressInventoryFeed));
|
| - |
|
201 |
snapdealItem.setSuppressPriceFeed(Boolean.valueOf(isSuppressPriceFeed));
|
| - |
|
202 |
snapdealItem.setTransferPrice(Double.valueOf(transferPrice));
|
| - |
|
203 |
snapdealItem.setExceptionPrice(Double.valueOf(exceptionPrice));
|
| - |
|
204 |
snapdealItem.setSellingPrice(Double.valueOf(sellingPrice));
|
| - |
|
205 |
snapdealItem.setCourierCost(Double.valueOf(courierCost));
|
| - |
|
206 |
snapdealItem.setCommission(Double.valueOf(commission));
|
| - |
|
207 |
snapdealItem.setServiceTax(Double.valueOf(serviceTax));
|
| - |
|
208 |
Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| - |
|
209 |
catalogClient.addOrUpdateSnapdealItem(snapdealItem);
|
| - |
|
210 |
return "index";
|
| - |
|
211 |
}
|
| - |
|
212 |
|
| - |
|
213 |
public String getAddNewItemForm(){
|
| - |
|
214 |
return "snapdeal-add-item";
|
| - |
|
215 |
}
|
| - |
|
216 |
|
| - |
|
217 |
public String getItemDetailsInJson() throws NumberFormatException, CatalogServiceException, TException, JSONException{
|
| - |
|
218 |
Client catalogClient =new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| - |
|
219 |
SnapdealItem snapdealItem = catalogClient.getSnapdealItem(Long.valueOf(itemId));
|
| - |
|
220 |
if (snapdealItem.getItem_id()!=0){
|
| - |
|
221 |
throw new CatalogServiceException();
|
| - |
|
222 |
}
|
| - |
|
223 |
Item item = catalogClient.getItem(Long.valueOf(itemId));
|
| - |
|
224 |
if (item.getId()==0){
|
| - |
|
225 |
throw new CatalogServiceException();
|
| - |
|
226 |
}
|
| - |
|
227 |
itemObj = new JSONObject();
|
| - |
|
228 |
itemObj.put("ItemId", item.getId());
|
| - |
|
229 |
itemObj.put("Brand", item.getBrand());
|
| - |
|
230 |
itemObj.put("ModelName", item.getModelName());
|
| - |
|
231 |
itemObj.put("ModelNumber", item.getModelNumber());
|
| - |
|
232 |
itemObj.put("Color", item.getColor());
|
| - |
|
233 |
itemObj.put("Weight", item.getWeight());
|
| - |
|
234 |
itemObj.put("Risky", item.isRisky());
|
| - |
|
235 |
itemObj.put("Status", item.getItemStatus());
|
| - |
|
236 |
itemObj.put("MRP", item.getMrp());
|
| - |
|
237 |
itemObj.put("SellingPrice", item.getSellingPrice());
|
| - |
|
238 |
return "item-details-json";
|
| 81 |
|
239 |
}
|
| - |
|
240 |
|
| 82 |
public void downloadSnapdealListings() throws IOException, TException{
|
241 |
public void downloadSnapdealListings() throws IOException, TException{
|
| 83 |
File file = new File("/tmp/snapdeal-bulk-upload-template.xls");
|
242 |
File file = new File("/tmp/snapdeal-bulk-upload-template.xls");
|
| 84 |
HSSFWorkbook hwb=new HSSFWorkbook();
|
243 |
HSSFWorkbook hwb=new HSSFWorkbook();
|
| 85 |
HSSFSheet sheet = hwb.createSheet("Snapdeal-Listings");
|
244 |
HSSFSheet sheet = hwb.createSheet("Snapdeal-Listings");
|
| 86 |
HSSFRow rowhead= sheet.createRow((short)0);
|
245 |
HSSFRow rowhead= sheet.createRow((short)0);
|
| 87 |
rowhead.createCell((short) 0).setCellValue("ITEM-ID");
|
246 |
rowhead.createCell((short) 0).setCellValue("ITEM-ID");
|
| 88 |
rowhead.createCell((short) 1).setCellValue("WAREHOUSE-ID");
|
247 |
rowhead.createCell((short) 1).setCellValue("WAREHOUSE-ID");
|
| 89 |
rowhead.createCell((short) 2).setCellValue("EXCEPTIONAL-PRICE");
|
248 |
rowhead.createCell((short) 2).setCellValue("EXCEPTIONAL-PRICE");
|
| 90 |
rowhead.createCell((short) 3).setCellValue("SNAPDEAL-LISTED");
|
249 |
rowhead.createCell((short) 3).setCellValue("SNAPDEAL-LISTED");
|
| - |
|
250 |
rowhead.createCell((short) 4).setCellValue("TRANSFER-PRICE");
|
| - |
|
251 |
rowhead.createCell((short) 5).setCellValue("SELLING-PRICE");
|
| - |
|
252 |
rowhead.createCell((short) 6).setCellValue("COURIER-COST");
|
| - |
|
253 |
rowhead.createCell((short) 7).setCellValue("COMMISION");
|
| - |
|
254 |
rowhead.createCell((short) 8).setCellValue("SERVICE-TAX");
|
| 91 |
CatalogClient catalogServiceClient = null;
|
255 |
CatalogClient catalogServiceClient = null;
|
| 92 |
List<SnapdealItem> snapdealItems = null;
|
256 |
List<SnapdealItemDetails> snapdealItems = null;
|
| 93 |
try {
|
257 |
try {
|
| 94 |
//catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port");
|
258 |
catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port");
|
| 95 |
catalogServiceClient = new CatalogClient();
|
- |
|
| 96 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient= catalogServiceClient.getClient();
|
259 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient= catalogServiceClient.getClient();
|
| 97 |
snapdealItems = catalogClient.getAllSnapdealItems();
|
260 |
snapdealItems = catalogClient.getAllSnapdealItems();
|
| 98 |
} catch (Exception e) {
|
261 |
} catch (Exception e) {
|
| 99 |
// TODO Auto-generated catch block
|
- |
|
| 100 |
e.printStackTrace();
|
262 |
e.printStackTrace();
|
| 101 |
}
|
263 |
}
|
| 102 |
int iterator=1;
|
264 |
int iterator=1;
|
| 103 |
for(SnapdealItem snapdealItem:snapdealItems){
|
265 |
for(SnapdealItemDetails snapdealItem:snapdealItems){
|
| 104 |
HSSFRow row = sheet.createRow((short)iterator);
|
266 |
HSSFRow row = sheet.createRow((short)iterator);
|
| 105 |
row.createCell((short) 0).setCellValue(snapdealItem.getItem_id());
|
267 |
row.createCell((short) 0).setCellValue(snapdealItem.getItem_id());
|
| 106 |
row.createCell((short) 1).setCellValue(snapdealItem.getWarehouseId());
|
268 |
row.createCell((short) 1).setCellValue(snapdealItem.getWarehouseId());
|
| 107 |
row.createCell((short) 2).setCellValue(snapdealItem.getExceptionPrice());
|
269 |
row.createCell((short) 2).setCellValue(snapdealItem.getExceptionPrice());
|
| 108 |
if(snapdealItem.isIsListedOnSnapdeal()){
|
270 |
if(snapdealItem.isIsListedOnSnapdeal()){
|
| 109 |
row.createCell((short) 3).setCellValue(1);
|
271 |
row.createCell((short) 3).setCellValue(1);
|
| 110 |
}
|
272 |
}
|
| 111 |
else{
|
273 |
else{
|
| 112 |
row.createCell((short) 3).setCellValue(0);
|
274 |
row.createCell((short) 3).setCellValue(0);
|
| 113 |
}
|
275 |
}
|
| - |
|
276 |
row.createCell((short) 4).setCellValue(snapdealItem.getTransferPrice());
|
| - |
|
277 |
row.createCell((short) 5).setCellValue(snapdealItem.getSellingPrice());
|
| - |
|
278 |
rowhead.createCell((short) 6).setCellValue(snapdealItem.getCourierCost());
|
| - |
|
279 |
rowhead.createCell((short) 7).setCellValue(snapdealItem.getCommission());
|
| - |
|
280 |
rowhead.createCell((short) 8).setCellValue(snapdealItem.getServiceTax());
|
| 114 |
iterator++;
|
281 |
iterator++;
|
| 115 |
}
|
282 |
}
|
| 116 |
|
283 |
|
| 117 |
FileOutputStream fileOut = null;
|
284 |
FileOutputStream fileOut = null;
|
| 118 |
try {
|
285 |
try {
|
| 119 |
fileOut = new FileOutputStream(file);
|
286 |
fileOut = new FileOutputStream(file);
|
| 120 |
} catch (FileNotFoundException e) {
|
287 |
} catch (FileNotFoundException e) {
|
| 121 |
// TODO Auto-generated catch block
|
288 |
// TODO Auto-generated catch block
|
| Line 160... |
Line 327... |
| 160 |
sos.flush();
|
327 |
sos.flush();
|
| 161 |
} catch (IOException e) {
|
328 |
} catch (IOException e) {
|
| 162 |
System.out.println("Unable to stream the manifest file");
|
329 |
System.out.println("Unable to stream the manifest file");
|
| 163 |
}
|
330 |
}
|
| 164 |
|
331 |
|
| 165 |
|
332 |
|
| 166 |
}
|
333 |
}
|
| 167 |
|
334 |
|
| 168 |
public void uploadsnapdealBulkSheet() throws IOException, TException{
|
335 |
public void uploadsnapdealBulkSheet() throws IOException, TException{
|
| 169 |
File fileToCreate = new File("/tmp/", "Snapdeal-bulk-upload.xls");
|
336 |
File fileToCreate = new File("/tmp/", "Snapdeal-bulk-upload.xls");
|
| 170 |
FileUtils.copyFile(this.file, fileToCreate);
|
337 |
FileUtils.copyFile(this.file, fileToCreate);
|
| Line 172... |
Line 339... |
| 172 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
339 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
| 173 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
340 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
| 174 |
Client catalogClient=null;
|
341 |
Client catalogClient=null;
|
| 175 |
StringBuilder sb = new StringBuilder();
|
342 |
StringBuilder sb = new StringBuilder();
|
| 176 |
try {
|
343 |
try {
|
| 177 |
//catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
344 |
catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| 178 |
catalogClient = new CatalogClient().getClient();
|
- |
|
| 179 |
} catch (TTransportException e) {
|
345 |
} catch (TTransportException e) {
|
| 180 |
// TODO Auto-generated catch block
|
- |
|
| 181 |
e.printStackTrace();
|
346 |
e.printStackTrace();
|
| 182 |
}
|
347 |
}
|
| 183 |
for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
|
348 |
for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
|
| 184 |
SnapdealItem snapdealItem =null;
|
349 |
SnapdealItem snapdealItem =null;
|
| - |
|
350 |
Item item = null;
|
| 185 |
Long sku;
|
351 |
Long sku;
|
| 186 |
if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
|
352 |
if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
|
| 187 |
continue;
|
353 |
continue;
|
| 188 |
}
|
354 |
}
|
| 189 |
else {
|
355 |
else {
|
| 190 |
sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
356 |
sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
| 191 |
snapdealItem = catalogClient.getSnapdealItem(sku);
|
357 |
snapdealItem = catalogClient.getSnapdealItem(sku);
|
| - |
|
358 |
try {
|
| - |
|
359 |
item = catalogClient.getItem(sku);
|
| - |
|
360 |
if (item.getId()==0){
|
| - |
|
361 |
sb.append(sku + " Item not Present"+"\n");
|
| - |
|
362 |
continue;
|
| - |
|
363 |
}
|
| - |
|
364 |
} catch (CatalogServiceException e) {
|
| - |
|
365 |
sb.append(sku + " Item not Present"+"\n");
|
| - |
|
366 |
continue;
|
| - |
|
367 |
}
|
| 192 |
if(snapdealItem.getItem_id()==0){
|
368 |
if(snapdealItem.getItem_id()==0){
|
| 193 |
snapdealItem = new SnapdealItem();
|
369 |
snapdealItem = new SnapdealItem();
|
| 194 |
snapdealItem.setItem_id(sku);
|
370 |
snapdealItem.setItem_id(sku);
|
| 195 |
}
|
371 |
}
|
| 196 |
}
|
372 |
}
|
| 197 |
|
- |
|
| 198 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
|
373 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
|
| 199 |
long warehouseId = (long) sheet.getRow(iterator).getCell(1).getNumericCellValue();
|
374 |
long warehouseId = (long) sheet.getRow(iterator).getCell(1).getNumericCellValue();
|
| 200 |
snapdealItem.setWarehouseId(warehouseId);
|
375 |
snapdealItem.setWarehouseId(warehouseId);
|
| 201 |
}
|
376 |
}
|
| 202 |
|
377 |
|
| Line 211... |
Line 386... |
| 211 |
}
|
386 |
}
|
| 212 |
if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==0){
|
387 |
if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==0){
|
| 213 |
snapdealItem.setIsListedOnSnapdeal(false);
|
388 |
snapdealItem.setIsListedOnSnapdeal(false);
|
| 214 |
}
|
389 |
}
|
| 215 |
}
|
390 |
}
|
| - |
|
391 |
double transferPrice = 0,sellingPrice,commission,courierCost =45,serviceTax;
|
| - |
|
392 |
if (checkEmptyString(sheet.getRow(iterator).getCell(4))){
|
| - |
|
393 |
sb.append(sku + " Transfer Price cannot be empty"+"\n");
|
| - |
|
394 |
continue;
|
| - |
|
395 |
}
|
| - |
|
396 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(4))){
|
| - |
|
397 |
transferPrice = sheet.getRow(iterator).getCell(4).getNumericCellValue();
|
| - |
|
398 |
if(transferPrice==0){
|
| - |
|
399 |
sb.append(sku + " Transfer Price cannot be zero"+"\n");
|
| - |
|
400 |
continue;
|
| - |
|
401 |
}
|
| - |
|
402 |
snapdealItem.setTransferPrice(transferPrice);
|
| - |
|
403 |
}
|
| - |
|
404 |
|
| - |
|
405 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(5))){
|
| - |
|
406 |
if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==1){
|
| - |
|
407 |
snapdealItem.setSuppressPriceFeed(true);
|
| - |
|
408 |
}
|
| - |
|
409 |
if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==0){
|
| - |
|
410 |
snapdealItem.setSuppressPriceFeed(false);
|
| - |
|
411 |
}
|
| - |
|
412 |
}
|
| - |
|
413 |
|
| - |
|
414 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(6))){
|
| - |
|
415 |
if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==1){
|
| - |
|
416 |
snapdealItem.setSuppressInventoryFeed(true);
|
| - |
|
417 |
}
|
| - |
|
418 |
if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==0){
|
| - |
|
419 |
snapdealItem.setSuppressInventoryFeed(false);
|
| - |
|
420 |
}
|
| - |
|
421 |
}
|
| - |
|
422 |
double weight = item.getWeight();
|
| - |
|
423 |
|
| - |
|
424 |
/*
|
| - |
|
425 |
*TODO Uncomment this for pricing feed.
|
| - |
|
426 |
* if(weight==0){
|
| - |
|
427 |
sb.append(sku + " Please add weight"+"\n");
|
| - |
|
428 |
continue;
|
| - |
|
429 |
}*/
|
| - |
|
430 |
if (weight!=0){
|
| - |
|
431 |
int slabs = (int) ((weight - .001)/(.5));
|
| - |
|
432 |
|
| - |
|
433 |
for(int i=0;i<slabs;i++){
|
| - |
|
434 |
courierCost = courierCost + 35;
|
| - |
|
435 |
}
|
| - |
|
436 |
}
|
| - |
|
437 |
|
| - |
|
438 |
snapdealItem.setCourierCost(courierCost);
|
| - |
|
439 |
sellingPrice = roundTwoDecimals(((transferPrice + courierCost*1.1236)/(100 - 3.59*1.1236))*100);
|
| - |
|
440 |
snapdealItem.setSellingPrice(sellingPrice);
|
| - |
|
441 |
double commision_value = roundTwoDecimals(.0359*sellingPrice + courierCost);
|
| - |
|
442 |
commission = roundTwoDecimals(((.0359*sellingPrice + courierCost)/sellingPrice)*100);
|
| - |
|
443 |
snapdealItem.setCommission(commission);
|
| - |
|
444 |
serviceTax = roundTwoDecimals((commision_value * .1236));
|
| - |
|
445 |
snapdealItem.setServiceTax(serviceTax);
|
| 216 |
if(!catalogClient.addOrUpdateSnapdealItem(snapdealItem)){
|
446 |
if(!catalogClient.addOrUpdateSnapdealItem(snapdealItem)){
|
| 217 |
sb.append(sku + "\n");
|
447 |
sb.append(sku + "\n");
|
| 218 |
}
|
448 |
}
|
| 219 |
}
|
449 |
}
|
| 220 |
//logger.info("Amazon Bulk Map "+amazonBulkUpdate.toString());
|
450 |
//logger.info("Amazon Bulk Map "+amazonBulkUpdate.toString());
|
| Line 257... |
Line 487... |
| 257 |
return true;
|
487 |
return true;
|
| 258 |
}
|
488 |
}
|
| 259 |
return false;
|
489 |
return false;
|
| 260 |
}
|
490 |
}
|
| 261 |
|
491 |
|
| - |
|
492 |
double roundTwoDecimals(double d) {
|
| - |
|
493 |
DecimalFormat twoPlaces = new DecimalFormat("#.##");
|
| - |
|
494 |
return Double.valueOf(twoPlaces.format(d));
|
| - |
|
495 |
}
|
| - |
|
496 |
|
| - |
|
497 |
|
| 262 |
public String show() {
|
498 |
public String show() {
|
| 263 |
logger.info("Before fetching role");
|
499 |
logger.info("Before fetching role");
|
| 264 |
logger.info(request.getSession().toString());
|
500 |
logger.info(request.getSession().toString());
|
| 265 |
logger.info(ReportsUtils.ROLE);
|
501 |
logger.info(ReportsUtils.ROLE);
|
| 266 |
logger.info(session.getAttribute(ReportsUtils.ROLE).toString());
|
502 |
logger.info(session.getAttribute(ReportsUtils.ROLE).toString());
|
| Line 271... |
Line 507... |
| 271 |
}
|
507 |
}
|
| 272 |
|
508 |
|
| 273 |
if (StringUtils.equals(id, "snapdeal-options")){
|
509 |
if (StringUtils.equals(id, "snapdeal-options")){
|
| 274 |
return "snapdeal-options";
|
510 |
return "snapdeal-options";
|
| 275 |
}
|
511 |
}
|
| - |
|
512 |
if (StringUtils.equals(id, "item-table")){
|
| - |
|
513 |
return "snapdeal-item-table";
|
| - |
|
514 |
}
|
| 276 |
|
515 |
|
| 277 |
return "id";
|
516 |
return "id";
|
| 278 |
}
|
517 |
}
|
| 279 |
|
518 |
|
| 280 |
public void setId(String id) {
|
519 |
public void setId(String id) {
|
| 281 |
logger.info(id);
|
- |
|
| 282 |
this.id = id;
|
520 |
this.id = id;
|
| 283 |
}
|
521 |
}
|
| 284 |
|
522 |
|
| 285 |
public HttpServletRequest getRequest() {
|
523 |
public HttpServletRequest getRequest() {
|
| 286 |
logger.info("set request"+request.toString());
|
524 |
logger.info("set request"+request.toString());
|
| Line 396... |
Line 634... |
| 396 |
|
634 |
|
| 397 |
public void setServletResponse(HttpServletResponse response) {
|
635 |
public void setServletResponse(HttpServletResponse response) {
|
| 398 |
this.response = response;
|
636 |
this.response = response;
|
| 399 |
}
|
637 |
}
|
| 400 |
|
638 |
|
| - |
|
639 |
public void setSearchText(String searchText) {
|
| - |
|
640 |
this.searchText = searchText;
|
| - |
|
641 |
}
|
| - |
|
642 |
|
| - |
|
643 |
public String getSearchText() {
|
| - |
|
644 |
return searchText;
|
| - |
|
645 |
}
|
| - |
|
646 |
|
| - |
|
647 |
public long getSearchCount() {
|
| - |
|
648 |
return searchCount;
|
| - |
|
649 |
}
|
| - |
|
650 |
|
| - |
|
651 |
public long getTotalCount() {
|
| - |
|
652 |
return totalCount;
|
| - |
|
653 |
}
|
| - |
|
654 |
|
| - |
|
655 |
public void setSearchCount(long count) {
|
| - |
|
656 |
this.searchCount = count;
|
| - |
|
657 |
}
|
| - |
|
658 |
|
| - |
|
659 |
public List<SnapdealItemDetails> getSnapdealItems(){
|
| - |
|
660 |
return snapdealItems;
|
| - |
|
661 |
}
|
| - |
|
662 |
|
| - |
|
663 |
public void setSellingPrice(String sellingPrice) {
|
| - |
|
664 |
this.sellingPrice = sellingPrice;
|
| - |
|
665 |
}
|
| - |
|
666 |
|
| - |
|
667 |
public String getSellingPrice() {
|
| - |
|
668 |
return sellingPrice;
|
| - |
|
669 |
}
|
| - |
|
670 |
|
| - |
|
671 |
public void setTransferPrice(String transferPrice) {
|
| - |
|
672 |
this.transferPrice = transferPrice;
|
| - |
|
673 |
}
|
| - |
|
674 |
|
| - |
|
675 |
public String getTransferPrice() {
|
| - |
|
676 |
return transferPrice;
|
| - |
|
677 |
}
|
| - |
|
678 |
|
| - |
|
679 |
public void setWebisteMrp(String webisteMrp) {
|
| - |
|
680 |
this.webisteMrp = webisteMrp;
|
| - |
|
681 |
}
|
| - |
|
682 |
|
| - |
|
683 |
public String getWebisteMrp() {
|
| - |
|
684 |
return webisteMrp;
|
| - |
|
685 |
}
|
| - |
|
686 |
|
| - |
|
687 |
public void setWebisteSellingPrice(String webisteSellingPrice) {
|
| - |
|
688 |
this.webisteSellingPrice = webisteSellingPrice;
|
| - |
|
689 |
}
|
| - |
|
690 |
|
| - |
|
691 |
public String getWebisteSellingPrice() {
|
| - |
|
692 |
return webisteSellingPrice;
|
| - |
|
693 |
}
|
| - |
|
694 |
|
| - |
|
695 |
public void setIsListedOnSnapdeal(String isListedOnSnapdeal) {
|
| - |
|
696 |
this.isListedOnSnapdeal = isListedOnSnapdeal;
|
| - |
|
697 |
}
|
| - |
|
698 |
|
| - |
|
699 |
public String getIsSuppressInventoryFeed() {
|
| - |
|
700 |
return isSuppressInventoryFeed;
|
| - |
|
701 |
}
|
| - |
|
702 |
|
| - |
|
703 |
public void setIsSuppressInventoryFeed(String isSuppressInventoryFeed) {
|
| - |
|
704 |
this.isSuppressInventoryFeed = isSuppressInventoryFeed;
|
| - |
|
705 |
}
|
| - |
|
706 |
|
| - |
|
707 |
public String getIsSuppressPriceFeed() {
|
| - |
|
708 |
return isSuppressPriceFeed;
|
| - |
|
709 |
}
|
| - |
|
710 |
|
| - |
|
711 |
public void setIsSuppressPriceFeed(String isSuppressPriceFeed) {
|
| - |
|
712 |
this.isSuppressPriceFeed = isSuppressPriceFeed;
|
| - |
|
713 |
}
|
| - |
|
714 |
|
| - |
|
715 |
public String getIsListedOnSnapdeal() {
|
| - |
|
716 |
return isListedOnSnapdeal;
|
| - |
|
717 |
}
|
| - |
|
718 |
|
| - |
|
719 |
public void setCommission(String commission) {
|
| - |
|
720 |
this.commission = commission;
|
| - |
|
721 |
}
|
| - |
|
722 |
|
| - |
|
723 |
public String getCommission() {
|
| - |
|
724 |
return commission;
|
| - |
|
725 |
}
|
| - |
|
726 |
|
| - |
|
727 |
public void setServiceTax(String serviceTax) {
|
| - |
|
728 |
this.serviceTax = serviceTax;
|
| - |
|
729 |
}
|
| - |
|
730 |
|
| - |
|
731 |
public String getServiceTax() {
|
| - |
|
732 |
return serviceTax;
|
| - |
|
733 |
}
|
| - |
|
734 |
|
| - |
|
735 |
public void setCourierCost(String courierCost) {
|
| - |
|
736 |
this.courierCost = courierCost;
|
| - |
|
737 |
}
|
| - |
|
738 |
|
| - |
|
739 |
public String getCourierCost() {
|
| - |
|
740 |
return courierCost;
|
| - |
|
741 |
}
|
| - |
|
742 |
|
| - |
|
743 |
public String getItemDetails(){
|
| - |
|
744 |
return itemObj.toString();
|
| - |
|
745 |
}
|
| - |
|
746 |
|
| - |
|
747 |
|
| - |
|
748 |
|
| 401 |
}
|
749 |
}
|
| 402 |
|
750 |
|