Subversion Repositories SmartDukaan

Rev

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

Rev 21894 Rev 21902
Line 3... Line 3...
3
import java.io.File;
3
import java.io.File;
4
import java.io.IOException;
4
import java.io.IOException;
5
import java.io.InputStream;
5
import java.io.InputStream;
6
import java.net.URISyntaxException;
6
import java.net.URISyntaxException;
7
import java.net.URL;
7
import java.net.URL;
-
 
8
import java.util.ArrayList;
8
import java.util.Collections;
9
import java.util.Collections;
9
import java.util.HashMap;
10
import java.util.HashMap;
10
import java.util.List;
11
import java.util.List;
11
import java.util.Map;
12
import java.util.Map;
12
import java.util.Set;
-
 
13
 
13
 
14
import org.apache.commons.io.FileUtils;
14
import org.apache.commons.io.FileUtils;
15
import org.apache.commons.io.IOUtils;
15
import org.apache.commons.io.IOUtils;
16
import org.apache.http.client.utils.URIBuilder;
16
import org.apache.http.client.utils.URIBuilder;
17
import org.slf4j.Logger;
17
import org.slf4j.Logger;
Line 217... Line 217...
217
	
217
	
218
	public static Map<String, GstRate> getGstRates(String stateName){
218
	public static Map<String, GstRate> getGstRates(String stateName){
219
		try{
219
		try{
220
			CatalogClient client = new CatalogClient();
220
			CatalogClient client = new CatalogClient();
221
			CatalogService.Client catalogClient = client.getClient();
221
			CatalogService.Client catalogClient = client.getClient();
222
			long stateCode = getStateCode(stateName);
222
			long stateCode = getStateId(stateName);
223
			StateGstRates stateGstRates = catalogClient.getGstRatesByState(stateCode);
223
			StateGstRates stateGstRates = catalogClient.getGstRatesByState(stateCode);
224
			Map<String, in.shop2020.model.v1.catalog.GstRate> hsnCodeGstRateMap = stateGstRates.getGstRatesMap();
224
			Map<String, in.shop2020.model.v1.catalog.GstRate> hsnCodeGstRateMap = stateGstRates.getGstRatesMap();
225
			Map<String, GstRate> gstRateMap = new HashMap<>();
225
			Map<String, GstRate> gstRateMap = new HashMap<>();
226
			for(Map.Entry<String, in.shop2020.model.v1.catalog.GstRate> entry : hsnCodeGstRateMap.entrySet()){
226
			for(Map.Entry<String, in.shop2020.model.v1.catalog.GstRate> entry : hsnCodeGstRateMap.entrySet()){
227
				in.shop2020.model.v1.catalog.GstRate tGstRate = entry.getValue();
227
				in.shop2020.model.v1.catalog.GstRate tGstRate = entry.getValue();
Line 236... Line 236...
236
		}catch(Exception e){
236
		}catch(Exception e){
237
			return new HashMap<>();
237
			return new HashMap<>();
238
		}
238
		}
239
	}
239
	}
240
	
240
	
-
 
241
	public static String getStateCode(String stateName) throws Exception{
-
 
242
		return getStateInfo(stateName).getStateCode();
-
 
243
	}
-
 
244
	
241
	public static long getStateCode(String stateName) throws Exception{
245
	public static long getStateId(String stateName) throws Exception{
-
 
246
		return getStateInfo(stateName).getId();
-
 
247
	}
-
 
248
	
-
 
249
	public static StateInfo getStateInfo(String stateName) throws Exception{
242
		try{
250
		try{
243
			InventoryClient client = new InventoryClient();
251
			InventoryClient client = new InventoryClient();
244
			InventoryService.Client inventoryClient = client.getClient();
252
			InventoryService.Client inventoryClient = client.getClient();
245
			Map<Long, StateInfo> map = inventoryClient.getStateMaster();
253
			Map<Long, StateInfo> map = inventoryClient.getStateMaster();
246
			Set<StateInfo> stateInfos = (Set<StateInfo>)map.values();
254
			List<StateInfo> stateInfos = new ArrayList<>(map.values());
247
			for(StateInfo stateInfo : stateInfos){
255
			for(StateInfo stateInfo : stateInfos){
248
				if(stateName.equals(stateInfo.getStateName())){
256
				if(stateName.equals(stateInfo.getStateName())){
249
					//return stateInfo.getStateCode();
-
 
250
					return stateInfo.getId();
257
					return stateInfo;
251
				}
258
				}
252
			}
259
			}
-
 
260
			throw new Exception("Not found");
253
		}catch (Exception e) {
261
		}catch (Exception e) {
254
			e.printStackTrace();
262
			e.printStackTrace();
255
			throw e;
263
			throw e;
256
		}
264
		}
257
		return 0;
-
 
258
	}
265
	}
259
 
266
 
260
}
267
}