Subversion Repositories SmartDukaan

Rev

Rev 462 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 462 Rev 507
Line 1... Line 1...
1
/**
1
/**
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.serving.controllers;
4
package in.shop2020.serving.controllers;
5
 
5
 
-
 
6
import java.util.StringTokenizer;
-
 
7
 
-
 
8
import in.shop2020.logistics.LogisticsService.Client;
-
 
9
import in.shop2020.thrift.clients.LogisticsServiceClient;
-
 
10
 
6
import org.apache.juli.logging.Log;
11
import org.apache.juli.logging.Log;
7
import org.apache.juli.logging.LogFactory;
12
import org.apache.juli.logging.LogFactory;
8
import org.apache.struts2.rest.DefaultHttpHeaders;
13
import org.apache.struts2.rest.DefaultHttpHeaders;
9
import org.apache.struts2.rest.HttpHeaders;
14
import org.apache.struts2.rest.HttpHeaders;
10
 
15
 
Line 18... Line 23...
18
	 * 
23
	 * 
19
	 */
24
	 */
20
	private static Log log = LogFactory.getLog(EstimateController.class);
25
	private static Log log = LogFactory.getLog(EstimateController.class);
21
	
26
	
22
	private String id;
27
	private String id;
23
	
28
	private long itemId;
-
 
29
	private String pincode;
-
 
30
	private long hours = 72;
24
	public EstimateController() {
31
	public EstimateController() {
25
		super();
32
		super();
26
	}
33
	}
27
    
34
    
28
    // GET /logout
35
    // GET /logout
29
    public HttpHeaders show() throws Exception {
36
    public HttpHeaders show() throws Exception {
-
 
37
    	LogisticsServiceClient logisticsServiceClient;
-
 
38
    	try {
-
 
39
			logisticsServiceClient = new LogisticsServiceClient();
-
 
40
			Client logisticsClient = logisticsServiceClient.getClient();
-
 
41
			hours = logisticsClient.getLogisticsEstimation(itemId, pincode, 1).getShippingTime();
-
 
42
		} catch (Exception e) {
-
 
43
			// TODO Auto-generated catch block
-
 
44
			e.printStackTrace();
30
    	
45
		}    	
31
    	return new DefaultHttpHeaders("index");
46
    	return new DefaultHttpHeaders("index");
32
    }
47
    }
33
        
48
        
34
    /**
49
    /**
35
     * 
50
     * 
36
     * @param id
51
     * @param id
37
     */
52
     */
38
    public void setId(String id) {
53
    public void setId(String id) {
39
        this.id = id;
54
        this.id = id;
-
 
55
        StringTokenizer tokenizer = new StringTokenizer(id, "_");
-
 
56
        this.pincode = tokenizer.nextToken();
-
 
57
        this.itemId = Long.parseLong(tokenizer.nextToken());
40
    }
58
    }
41
 
59
 
42
    public long getEstimatedTime() {
60
    public long getEstimatedTime() {
43
    	if(Long.parseLong(id) == 560001){
-
 
44
    		return 48;
-
 
45
    	}else{
-
 
46
    		return 48+24;
61
    	return hours;
47
    	}
-
 
48
    }
62
    }
49
}
63
}