Subversion Repositories SmartDukaan

Rev

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

Rev 28825 Rev 29165
Line 28... Line 28...
28
import org.springframework.ui.Model;
28
import org.springframework.ui.Model;
29
 
29
 
30
import com.google.gson.Gson;
30
import com.google.gson.Gson;
31
import com.spice.profitmandi.common.enumuration.ReporticoProject;
31
import com.spice.profitmandi.common.enumuration.ReporticoProject;
32
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
32
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
-
 
33
import com.spice.profitmandi.common.model.ChartInvestmentModel;
33
import com.spice.profitmandi.common.model.ChartModel;
34
import com.spice.profitmandi.common.model.ChartModel;
34
import com.spice.profitmandi.common.model.CustomRetailer;
35
import com.spice.profitmandi.common.model.CustomRetailer;
-
 
36
import com.spice.profitmandi.common.model.Data;
-
 
37
import com.spice.profitmandi.common.model.DataInvestmentModel;
-
 
38
import com.spice.profitmandi.common.model.Legend;
-
 
39
import com.spice.profitmandi.common.model.OptionModel;
-
 
40
import com.spice.profitmandi.common.model.PieLables;
35
import com.spice.profitmandi.common.model.ProfitMandiConstants;
41
import com.spice.profitmandi.common.model.ProfitMandiConstants;
36
import com.spice.profitmandi.dao.entity.auth.AuthUser;
42
import com.spice.profitmandi.dao.entity.auth.AuthUser;
37
import com.spice.profitmandi.dao.entity.auth.Menu;
43
import com.spice.profitmandi.dao.entity.auth.Menu;
38
import com.spice.profitmandi.dao.entity.cs.Position;
44
import com.spice.profitmandi.dao.entity.cs.Position;
39
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
45
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
-
 
46
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
40
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
47
import com.spice.profitmandi.dao.entity.inventory.ReporticoCacheTable;
41
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
48
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
42
import com.spice.profitmandi.dao.model.BrandWiseActivatedModel;
49
import com.spice.profitmandi.dao.model.BrandWiseActivatedModel;
43
import com.spice.profitmandi.dao.model.BrandWiseModel;
50
import com.spice.profitmandi.dao.model.BrandWiseModel;
44
import com.spice.profitmandi.dao.model.PartnerDetailModel;
51
import com.spice.profitmandi.dao.model.PartnerDetailModel;
Line 179... Line 186...
179
				"Brand Wise Monthly Purchase");
186
				"Brand Wise Monthly Purchase");
180
 
187
 
181
		return cm;
188
		return cm;
182
	}
189
	}
183
 
190
 
-
 
191
	public ChartInvestmentModel getAllStatePartnerType(Map<Integer, PartnerDetailModel> fofoIdAndallValues)
-
 
192
			throws ProfitMandiBusinessException {
-
 
193
 
-
 
194
		Map<String, Float> partnerTypeCount = new HashMap<>();
-
 
195
 
-
 
196
		List<PartnerType> partnerTypes = Arrays.asList(PartnerType.values());
-
 
197
 
-
 
198
		for (PartnerType partnerType : partnerTypes) {
-
 
199
 
-
 
200
			float count = fofoIdAndallValues.entrySet().stream()
-
 
201
					.filter(x -> x.getValue().getPartnerType().equals(partnerType)).count();
-
 
202
 
-
 
203
			partnerTypeCount.put(partnerType.toString(), count);
-
 
204
 
-
 
205
		}
-
 
206
 
-
 
207
		ChartInvestmentModel cm = new ChartInvestmentModel();
-
 
208
 
-
 
209
		HashSet<String> labels = new HashSet<String>();
-
 
210
		labels.addAll(partnerTypes.stream().skip(1).map(x -> x.toString()).collect(Collectors.toList()));
-
 
211
		List<String> labelList = new ArrayList<>(labels);
-
 
212
 
-
 
213
		List<String> backgroundColor = new ArrayList<>();
-
 
214
 
-
 
215
		List<Float> values = new ArrayList<>();
-
 
216
 
-
 
217
		for (String label : labelList) {
-
 
218
			values.add(partnerTypeCount.get(label));
-
 
219
			if (label.equals("BRONZE")) {
-
 
220
				backgroundColor.add("#FFD700");
-
 
221
			}
-
 
222
			if (label.equals("SILVER")) {
-
 
223
				backgroundColor.add("silver");
-
 
224
			}
-
 
225
			if (label.equals("GOLD")) {
-
 
226
				backgroundColor.add("yellow");
-
 
227
			}
-
 
228
			if (label.equals("DIAMOND")) {
-
 
229
				backgroundColor.add("#B9F2FF");
-
 
230
			}
-
 
231
 
-
 
232
			if (label.equals("PLATINUM")) {
-
 
233
				backgroundColor.add("#e5e4e2");
-
 
234
			}
-
 
235
			if (label.equals("NEW")) {
-
 
236
				backgroundColor.add("green");
-
 
237
			}
-
 
238
			if (label.equals("ALL")) {
-
 
239
				backgroundColor.add("blue");
-
 
240
			}
-
 
241
 
-
 
242
		}
-
 
243
 
-
 
244
		LOGGER.info("valuesPartnerType" + values);
-
 
245
		LOGGER.info("partnerTypeCount" + partnerTypeCount);
-
 
246
 
-
 
247
		Data data = new Data();
-
 
248
		data.setData(values);
-
 
249
		data.setBackgroundColor(backgroundColor);
-
 
250
		data.setLabel("DataSet 1");
-
 
251
 
-
 
252
		PieLables label = new PieLables();
-
 
253
		label.setFontColor("black");
-
 
254
		label.setFontSize(22);
-
 
255
 
-
 
256
		Legend legend = new Legend();
-
 
257
		legend.setLabels(label);
-
 
258
		legend.setPosition("left");
-
 
259
 
-
 
260
		List<Data> dataList = new ArrayList<>();
-
 
261
		dataList.add(data);
-
 
262
 
-
 
263
		DataInvestmentModel datasets = new DataInvestmentModel();
-
 
264
		datasets.setDatasets(dataList);
-
 
265
		datasets.setLabels(labels);
-
 
266
 
-
 
267
		OptionModel om = new OptionModel();
-
 
268
		om.setLegend(legend);
-
 
269
		cm.setType("pie");
-
 
270
		cm.setData(datasets);
-
 
271
		cm.setOptions(om);
-
 
272
 
-
 
273
		return cm;
-
 
274
	}
-
 
275
 
184
	public Map<String, Object> getFilter(int warehouseId, String email, LocalDate date)
276
	public Map<String, Object> getFilter(int warehouseId, String email, LocalDate date)
185
			throws ProfitMandiBusinessException {
277
			throws ProfitMandiBusinessException {
186
		Map<String, Object> map = new HashMap<>();
278
		Map<String, Object> map = new HashMap<>();
187
 
279
 
188
		Map<Integer, CustomRetailer> customRetailersMap = null;
280
		Map<Integer, CustomRetailer> customRetailersMap = null;