Subversion Repositories SmartDukaan

Rev

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

Rev 21646 Rev 21894
Line 1... Line 1...
1
package com.spice.profitmandi.common.util;
1
package com.spice.profitmandi.common.util;
2
 
2
 
3
import com.spice.profitmandi.thrift.clients.TransactionClient;
-
 
4
import com.spice.profitmandi.thrift.clients.config.ConfigClient;
-
 
5
import in.shop2020.model.v1.order.RechargeOrderStatus;
-
 
6
import in.shop2020.model.v1.order.RechargePlan;
-
 
7
import in.shop2020.model.v1.order.RechargeType;
-
 
8
import in.shop2020.model.v1.order.TransactionService.Client;
-
 
9
import java.io.File;
3
import java.io.File;
10
import java.io.IOException;
4
import java.io.IOException;
11
import java.io.InputStream;
5
import java.io.InputStream;
12
import java.io.PrintStream;
-
 
13
import java.net.URI;
-
 
14
import java.net.URISyntaxException;
6
import java.net.URISyntaxException;
15
import java.net.URL;
7
import java.net.URL;
16
import java.util.Collections;
8
import java.util.Collections;
17
import java.util.HashMap;
9
import java.util.HashMap;
18
import java.util.List;
10
import java.util.List;
19
import java.util.Map;
11
import java.util.Map;
-
 
12
import java.util.Set;
-
 
13
 
20
import org.apache.commons.io.FileUtils;
14
import org.apache.commons.io.FileUtils;
21
import org.apache.commons.io.IOUtils;
15
import org.apache.commons.io.IOUtils;
22
import org.apache.http.client.utils.URIBuilder;
16
import org.apache.http.client.utils.URIBuilder;
23
import org.slf4j.Logger;
17
import org.slf4j.Logger;
24
import org.slf4j.LoggerFactory;
18
import org.slf4j.LoggerFactory;
25
 
19
 
-
 
20
import com.spice.profitmandi.common.model.GstRate;
-
 
21
import com.spice.profitmandi.thrift.clients.CatalogClient;
-
 
22
import com.spice.profitmandi.thrift.clients.InventoryClient;
-
 
23
import com.spice.profitmandi.thrift.clients.TransactionClient;
-
 
24
import com.spice.profitmandi.thrift.clients.config.ConfigClient;
-
 
25
 
-
 
26
import in.shop2020.model.v1.catalog.CatalogService;
-
 
27
import in.shop2020.model.v1.catalog.StateGstRates;
-
 
28
import in.shop2020.model.v1.inventory.InventoryService;
-
 
29
import in.shop2020.model.v1.inventory.StateInfo;
-
 
30
import in.shop2020.model.v1.order.RechargeOrderStatus;
-
 
31
import in.shop2020.model.v1.order.RechargePlan;
-
 
32
import in.shop2020.model.v1.order.RechargeType;
-
 
33
 
26
 
34
 
27
 
35
 
28
public class Utils {
36
public class Utils {
29
	
37
	
30
	private static final Logger logger = LoggerFactory.getLogger(Utils.class);
38
	private static final Logger logger = LoggerFactory.getLogger(Utils.class);
Line 204... Line 212...
204
		} else {
212
		} else {
205
			return new String[]{"true", "ERROR", "INVALID INPUT"};
213
			return new String[]{"true", "ERROR", "INVALID INPUT"};
206
		}
214
		}
207
		
215
		
208
	}
216
	}
-
 
217
	
-
 
218
	public static Map<String, GstRate> getGstRates(String stateName){
-
 
219
		try{
-
 
220
			CatalogClient client = new CatalogClient();
-
 
221
			CatalogService.Client catalogClient = client.getClient();
-
 
222
			long stateCode = getStateCode(stateName);
-
 
223
			StateGstRates stateGstRates = catalogClient.getGstRatesByState(stateCode);
-
 
224
			Map<String, in.shop2020.model.v1.catalog.GstRate> hsnCodeGstRateMap = stateGstRates.getGstRatesMap();
-
 
225
			Map<String, GstRate> gstRateMap = new HashMap<>();
-
 
226
			for(Map.Entry<String, in.shop2020.model.v1.catalog.GstRate> entry : hsnCodeGstRateMap.entrySet()){
-
 
227
				in.shop2020.model.v1.catalog.GstRate tGstRate = entry.getValue();
-
 
228
				GstRate gstRate = new GstRate();
-
 
229
				gstRate.setHsnCode(entry.getKey());
-
 
230
				gstRate.setIgstRate(Double.valueOf(tGstRate.getIgstRate()).floatValue());
-
 
231
				gstRate.setCgstRate(Double.valueOf(tGstRate.getCgstRate()).floatValue());
-
 
232
				gstRate.setSgstRate(Double.valueOf(tGstRate.getSgstRate()).floatValue());
-
 
233
				gstRateMap.put(entry.getKey(), gstRate);
-
 
234
			}
-
 
235
			return gstRateMap;
-
 
236
		}catch(Exception e){
-
 
237
			return new HashMap<>();
-
 
238
		}
-
 
239
	}
-
 
240
	
-
 
241
	public static long getStateCode(String stateName) throws Exception{
-
 
242
		try{
-
 
243
			InventoryClient client = new InventoryClient();
-
 
244
			InventoryService.Client inventoryClient = client.getClient();
-
 
245
			Map<Long, StateInfo> map = inventoryClient.getStateMaster();
-
 
246
			Set<StateInfo> stateInfos = (Set<StateInfo>)map.values();
-
 
247
			for(StateInfo stateInfo : stateInfos){
-
 
248
				if(stateName.equals(stateInfo.getStateName())){
-
 
249
					//return stateInfo.getStateCode();
-
 
250
					return stateInfo.getId();
-
 
251
				}
-
 
252
			}
-
 
253
		}catch (Exception e) {
-
 
254
			e.printStackTrace();
-
 
255
			throw e;
-
 
256
		}
-
 
257
		return 0;
-
 
258
	}
209
 
259
 
210
}
260
}