Subversion Repositories SmartDukaan

Rev

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

Rev 7876 Rev 7888
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
import java.util.GregorianCalendar;
2
import java.util.GregorianCalendar;
3
import java.text.SimpleDateFormat;
3
import java.text.SimpleDateFormat;
4
import java.util.Calendar;
4
import java.util.Calendar;
5
import java.util.HashMap;
5
import java.util.HashMap;
6
import java.util.List;
-
 
7
import java.util.Map;
6
import java.util.Map;
8
import java.util.StringTokenizer;
7
import java.util.StringTokenizer;
9
 
8
 
10
import in.shop2020.datalogger.EventType;
9
import in.shop2020.datalogger.EventType;
11
import in.shop2020.logistics.LogisticsInfo;
10
import in.shop2020.logistics.LogisticsInfo;
Line 90... Line 89...
90
			log.warn(e.getMessage()+"pincode : "+ pincode + " Actual referer : " + request.getHeader("referer") + e.getStackTrace());
89
			log.warn(e.getMessage()+"pincode : "+ pincode + " Actual referer : " + request.getHeader("referer") + e.getStackTrace());
91
		}
90
		}
92
    	return new DefaultHttpHeaders("index");
91
    	return new DefaultHttpHeaders("index");
93
    }
92
    }
94
    
93
    
95
    
-
 
96
    public static String getDeliveryDateString(int days, DeliveryType type) throws TException {
94
    public static String getDeliveryDateString(int days, DeliveryType type) throws TException {
97
    	Calendar now = new GregorianCalendar();
95
    	Calendar now = new GregorianCalendar();
98
    	int hour = now.get(Calendar.HOUR_OF_DAY);
96
    	int hour = now.get(Calendar.HOUR_OF_DAY);
99
    	if(type == DeliveryType.COD && hour < 15){
97
    	if(type == DeliveryType.COD && hour < 15){
100
			days = days + 1;
98
			days = days + 1;
Line 104... Line 102...
104
    			return businessDayToActualDateMap.get(days);
102
    			return businessDayToActualDateMap.get(days);
105
    		}
103
    		}
106
    		businessDayToActualDateMap.clear();
104
    		businessDayToActualDateMap.clear();
107
		}
105
		}
108
    	
106
    	
-
 
107
    	now.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
109
    	
108
    
110
    	now.add(Calendar.DAY_OF_MONTH, days);
-
 
111
		Calendar to_range = new GregorianCalendar();
-
 
112
		to_range.add(Calendar.DAY_OF_MONTH, 30);
-
 
113
 
-
 
114
    	LogisticsClient logisticsServiceClient = null;
109
    	LogisticsClient logisticsServiceClient = null;
115
	
-
 
116
		logisticsServiceClient = new LogisticsClient();
110
		logisticsServiceClient = new LogisticsClient();
117
		Client logisticsClient = logisticsServiceClient.getClient();
111
		Client logisticsClient = logisticsServiceClient.getClient();
118
		
112
		
119
    	List<Long> holidays = logisticsClient.getHolidays(now.getTimeInMillis(), to_range.getTimeInMillis());
113
    	days = (int) logisticsClient.adjustDeliveryDays(now.getTimeInMillis(), days);
-
 
114
    	now.add(Calendar.DAY_OF_MONTH, days);
120
    	
115
    	
121
    	boolean tomorrow = true;
-
 
122
    	boolean check= true;
-
 
123
    	outer:while(check){
-
 
124
    		if(Calendar.SUNDAY==now.get(Calendar.DAY_OF_WEEK)){
-
 
125
    			now.add(Calendar.DAY_OF_MONTH, 1);
-
 
126
    			tomorrow = false;
-
 
127
    			check = true;
-
 
128
    			continue outer;
-
 
129
    		}
-
 
130
    		for(int i=0; i<holidays.size(); i++){
-
 
131
    			long now_in_long= now.getTimeInMillis();
-
 
132
    			if(now_in_long==holidays.get(i)){
-
 
133
    				now.add(Calendar.DAY_OF_MONTH, 1);
-
 
134
    				tomorrow = false;
-
 
135
    				check = true;
-
 
136
    				continue outer;
-
 
137
    			}
-
 
138
    		}
-
 
139
        	
-
 
140
    		tomorrow = tomorrow && days == 1;	
-
 
141
    		check= false;
-
 
142
    		SimpleDateFormat dateformat = new SimpleDateFormat("EEE dd-MMM-yy");
116
    	SimpleDateFormat dateformat = new SimpleDateFormat("EEE dd-MMM-yy");
143
    		if(tomorrow){
117
    	if(days == 1){
144
    			businessDayToActualDateMap.put(days, "Tomorrow, " + dateformat.format(now.getTime()));
118
    		businessDayToActualDateMap.put(days, "Tomorrow, " + dateformat.format(now.getTime()));
145
    		}else{
119
    	}else{
146
    			businessDayToActualDateMap.put(days, dateformat.format(now.getTime()));
120
    		businessDayToActualDateMap.put(days, dateformat.format(now.getTime()));
147
    		}
-
 
148
    	}
121
    	}
149
    	return businessDayToActualDateMap.get(days);
122
    	return businessDayToActualDateMap.get(days);
150
	}
123
	}
151
    
124
    
152
    /**
125
    /**