Subversion Repositories SmartDukaan

Rev

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

Rev 5597 Rev 5684
Line 2... Line 2...
2
 
2
 
3
import in.shop2020.model.v1.catalog.InventoryService.Client;
3
import in.shop2020.model.v1.catalog.InventoryService.Client;
4
import in.shop2020.model.v1.catalog.InventoryServiceException;
4
import in.shop2020.model.v1.catalog.InventoryServiceException;
5
import in.shop2020.model.v1.catalog.Item;
5
import in.shop2020.model.v1.catalog.Item;
6
import in.shop2020.model.v1.catalog.ItemInventory;
6
import in.shop2020.model.v1.catalog.ItemInventory;
7
import in.shop2020.model.v1.catalog.ItemType;
-
 
8
import in.shop2020.model.v1.catalog.VendorItemMapping;
7
import in.shop2020.model.v1.catalog.VendorItemMapping;
9
import in.shop2020.model.v1.catalog.Warehouse;
8
import in.shop2020.model.v1.catalog.Warehouse;
10
import in.shop2020.support.models.BillingUpdate;
9
import in.shop2020.support.models.BillingUpdate;
11
import in.shop2020.support.models.InventoryUpdate;
10
import in.shop2020.support.models.InventoryUpdate;
12
import in.shop2020.support.models.PLBDetails;
11
import in.shop2020.support.models.PLBDetails;
Line 14... Line 13...
14
import in.shop2020.thrift.clients.CatalogClient;
13
import in.shop2020.thrift.clients.CatalogClient;
15
import in.shop2020.thrift.clients.TransactionClient;
14
import in.shop2020.thrift.clients.TransactionClient;
16
import in.shop2020.utils.ConfigClientKeys;
15
import in.shop2020.utils.ConfigClientKeys;
17
import in.shop2020.utils.GmailUtils;
16
import in.shop2020.utils.GmailUtils;
18
 
17
 
-
 
18
import java.io.BufferedWriter;
19
import java.io.File;
19
import java.io.File;
-
 
20
import java.io.FileWriter;
-
 
21
import java.io.IOException;
20
import java.util.ArrayList;
22
import java.util.ArrayList;
21
import java.util.HashMap;
23
import java.util.HashMap;
22
import java.util.List;
24
import java.util.List;
23
import java.util.Map;
25
import java.util.Map;
24
 
26
 
25
import javax.mail.MessagingException;
27
import javax.mail.MessagingException;
26
 
28
 
-
 
29
import org.apache.commons.lang.StringUtils;
27
import org.apache.struts2.rest.DefaultHttpHeaders;
30
import org.apache.struts2.rest.DefaultHttpHeaders;
28
import org.apache.struts2.rest.HttpHeaders;
31
import org.apache.struts2.rest.HttpHeaders;
29
import org.apache.thrift.TException;
32
import org.apache.thrift.TException;
30
import org.slf4j.Logger;
33
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
34
import org.slf4j.LoggerFactory;
Line 246... Line 249...
246
                    }
249
                    }
247
                }
250
                }
248
            }
251
            }
249
 
252
 
250
            String subject = mismatches.size() + " mismatches with PLB sync for warehouse id: " + warehouseId;
253
            String subject = mismatches.size() + " mismatches with PLB sync for warehouse id: " + warehouseId;
-
 
254
            File file = new File("mismatches.xls");
-
 
255
 
-
 
256
            try {
251
            StringBuilder body = new StringBuilder("Item Id\tBrand\tModel Name\tModel Number\tColor\tSpice Online Retail\tHotspot\n");
257
                BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
-
 
258
                bufferedWriter.write(StringUtils.join(new String[] { "Item Id",
-
 
259
                        "Brand", "Model Name", "Model Number",
-
 
260
                        "Color", "SpiceOnlineRetailStock", "HotspotStock" }, '\t'));
252
            for (Item item : mismatches.keySet()) {
261
                for (Item item : mismatches.keySet()) {
253
                Long currentSnapshotAvailability = fetchInventory(item.getId()).getAvailability().get(warehouseId);
262
                    Long currentSnapshotAvailability = fetchInventory(item.getId()).getAvailability().get(warehouseId);
254
                String plbQuantity = mismatches.get(item) == null ? "0" : mismatches.get(item).getQuantity().toString();
263
                    String plbQuantity = mismatches.get(item) == null ? "0" : mismatches.get(item).getQuantity().toString();
255
                String currentSnapshotQuantity = currentSnapshotAvailability == null ? "0" : currentSnapshotAvailability.toString();
264
                    String currentSnapshotQuantity = currentSnapshotAvailability == null ? "0" : currentSnapshotAvailability.toString();
-
 
265
                    bufferedWriter.newLine();
-
 
266
                    bufferedWriter.write(StringUtils.join(new String[] { String.valueOf(item.getId()), item.getBrand(), item.getModelName(),
256
                body.append(item.getId() + "\t" + item.getBrand() + "\t" + item.getModelName() + "\t" + item.getModelNumber() + "\t" + item.getColor() + "\t" + currentSnapshotQuantity + "\t" + plbQuantity + "\n");
267
                            item.getModelNumber(), item.getColor(),currentSnapshotQuantity, plbQuantity }, "\t"));
-
 
268
                }
-
 
269
 
-
 
270
                bufferedWriter.close();
-
 
271
            } catch (IOException e) {
-
 
272
                logger.error("Could not write mismatches to file", e);
257
            }
273
            }
258
 
274
 
259
            logger.info(body.toString());
-
 
260
            GmailUtils g = new GmailUtils();
275
            GmailUtils g = new GmailUtils();
261
            g.sendSSLMessage(new String[]{ "mandeep.dhir@shop2020.in" }, subject, body.toString(), "cnc.center@shop2020.in", "5h0p2o2o", new ArrayList<File>());
276
            g.sendSSLMessage(new String[]{ "mandeep.dhir@shop2020.in", "sandeep.sachdeva@shop2020.in", "ashutosh.saxena@shop2020.in" }, subject, 
-
 
277
                    "", "cnc.center@shop2020.in", "5h0p2o2o", file.getAbsolutePath());
262
        }
278
        }
263
    }
279
    }
264
 
280
 
265
	public int getErrorCode() {
281
	public int getErrorCode() {
266
		return errorCode;
282
		return errorCode;
Line 298... Line 314...
298
        return fullPlbSync;
314
        return fullPlbSync;
299
    }
315
    }
300
 
316
 
301
    public void setFullPlbSync(boolean fullPlbSync) {
317
    public void setFullPlbSync(boolean fullPlbSync) {
302
        this.fullPlbSync = fullPlbSync;
318
        this.fullPlbSync = fullPlbSync;
303
    }	
319
    }
304
}
320
}