Subversion Repositories SmartDukaan

Rev

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

Rev 5766 Rev 5945
Line 1... Line 1...
1
package in.shop2020.support.services;
1
package in.shop2020.support.services;
2
 
2
 
-
 
3
import in.shop2020.logistics.LogisticsServiceException;
-
 
4
import in.shop2020.logistics.PickUpType;
-
 
5
import in.shop2020.logistics.PickupStore;
-
 
6
import in.shop2020.logistics.Provider;
-
 
7
import in.shop2020.model.v1.inventory.InventoryServiceException;
-
 
8
import in.shop2020.model.v1.inventory.Warehouse;
-
 
9
import in.shop2020.model.v1.order.LineItem;
-
 
10
import in.shop2020.model.v1.order.Order;
-
 
11
import in.shop2020.model.v1.order.OrderStatus;
-
 
12
import in.shop2020.model.v1.order.TransactionServiceException;
-
 
13
import in.shop2020.thrift.clients.InventoryClient;
-
 
14
import in.shop2020.thrift.clients.LogisticsClient;
-
 
15
import in.shop2020.thrift.clients.TransactionClient;
-
 
16
 
3
import java.io.ByteArrayOutputStream;
17
import java.io.ByteArrayOutputStream;
4
import java.io.File;
18
import java.io.File;
5
import java.io.FileOutputStream;
19
import java.io.FileOutputStream;
6
import java.io.IOException;
20
import java.io.IOException;
7
import java.net.MalformedURLException;
21
import java.net.MalformedURLException;
Line 17... Line 31...
17
 
31
 
18
import com.itextpdf.text.Document;
32
import com.itextpdf.text.Document;
19
import com.itextpdf.text.DocumentException;
33
import com.itextpdf.text.DocumentException;
20
import com.itextpdf.text.Element;
34
import com.itextpdf.text.Element;
21
import com.itextpdf.text.Font;
35
import com.itextpdf.text.Font;
-
 
36
import com.itextpdf.text.Font.FontFamily;
22
import com.itextpdf.text.FontFactory;
37
import com.itextpdf.text.FontFactory;
23
import com.itextpdf.text.Image;
38
import com.itextpdf.text.Image;
24
import com.itextpdf.text.Paragraph;
39
import com.itextpdf.text.Paragraph;
25
import com.itextpdf.text.Phrase;
40
import com.itextpdf.text.Phrase;
26
import com.itextpdf.text.Rectangle;
41
import com.itextpdf.text.Rectangle;
27
import com.itextpdf.text.Font.FontFamily;
-
 
28
import com.itextpdf.text.pdf.PdfPCell;
42
import com.itextpdf.text.pdf.PdfPCell;
29
import com.itextpdf.text.pdf.PdfPTable;
43
import com.itextpdf.text.pdf.PdfPTable;
30
import com.itextpdf.text.pdf.PdfWriter;
44
import com.itextpdf.text.pdf.PdfWriter;
31
 
45
 
32
import in.shop2020.logistics.LogisticsServiceException;
-
 
33
import in.shop2020.logistics.PickUpType;
-
 
34
import in.shop2020.logistics.PickupStore;
-
 
35
import in.shop2020.logistics.Provider;
-
 
36
import in.shop2020.model.v1.catalog.InventoryServiceException;
-
 
37
import in.shop2020.model.v1.catalog.Warehouse;
-
 
38
import in.shop2020.model.v1.order.LineItem;
-
 
39
import in.shop2020.model.v1.order.Order;
-
 
40
import in.shop2020.model.v1.order.OrderStatus;
-
 
41
import in.shop2020.model.v1.order.TransactionServiceException;
-
 
42
import in.shop2020.thrift.clients.CatalogClient;
-
 
43
import in.shop2020.thrift.clients.LogisticsClient;
-
 
44
import in.shop2020.thrift.clients.TransactionClient;
-
 
45
 
-
 
46
public class ManifestGenerator {
46
public class ManifestGenerator {
47
    
47
    
48
    private static Logger logger = LoggerFactory.getLogger(ManifestGenerator.class);
48
    private static Logger logger = LoggerFactory.getLogger(ManifestGenerator.class);
49
    
49
    
50
	private TransactionClient tsc = null;
50
	private TransactionClient tsc = null;
51
	private CatalogClient csc = null;
51
	private InventoryClient csc = null;
52
	private LogisticsClient lsc = null;
52
	private LogisticsClient lsc = null;
53
	private DecimalFormat weightFormat = new DecimalFormat("0.000");
53
	private DecimalFormat weightFormat = new DecimalFormat("0.000");
54
	public ManifestGenerator() {
54
	public ManifestGenerator() {
55
		try {
55
		try {
56
			tsc = new TransactionClient();
56
			tsc = new TransactionClient();
57
			csc = new CatalogClient();
57
			csc = new InventoryClient();
58
			lsc = new LogisticsClient();
58
			lsc = new LogisticsClient();
59
		} catch (Exception e) {
59
		} catch (Exception e) {
60
		    logger.error("Error while initializing one of the thrift clients", e);
60
		    logger.error("Error while initializing one of the thrift clients", e);
61
		}
61
		}
62
	}
62
	}
63
 
63
 
64
	public ByteArrayOutputStream generateManifestFile(long warehouseId,	long providerId, boolean isCod, List<Long> orderIds, String runner) {
64
	public ByteArrayOutputStream generateManifestFile(long warehouseId,	long providerId, boolean isCod, List<Long> orderIds, String runner) {
65
		ByteArrayOutputStream baosPDF = null;
65
		ByteArrayOutputStream baosPDF = null;
66
		in.shop2020.model.v1.order.TransactionService.Client txnClient = tsc.getClient();
66
		in.shop2020.model.v1.order.TransactionService.Client txnClient = tsc.getClient();
67
		in.shop2020.model.v1.catalog.InventoryService.Client inventoryClient = csc.getClient();
67
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = csc.getClient();
68
		in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
68
		in.shop2020.logistics.LogisticsService.Client logisticsClient = lsc.getClient();
69
		
69
		
70
		List<OrderStatus> statuses = new ArrayList<OrderStatus>();
70
		List<OrderStatus> statuses = new ArrayList<OrderStatus>();
71
		statuses.add(OrderStatus.BILLED);
71
		statuses.add(OrderStatus.BILLED);
72
		
72