Subversion Repositories SmartDukaan

Rev

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

Rev 22472 Rev 22486
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
-
 
3
import java.io.ByteArrayInputStream;
-
 
4
import java.io.ByteArrayOutputStream;
-
 
5
import java.io.InputStream;
3
import java.time.LocalDateTime;
6
import java.time.LocalDateTime;
4
import java.util.ArrayList;
7
import java.util.ArrayList;
5
import java.util.HashMap;
8
import java.util.HashMap;
6
import java.util.HashSet;
9
import java.util.HashSet;
7
import java.util.Iterator;
10
import java.util.Iterator;
Line 15... Line 18...
15
import org.json.JSONObject;
18
import org.json.JSONObject;
16
import org.slf4j.Logger;
19
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
20
import org.slf4j.LoggerFactory;
18
import org.springframework.beans.factory.annotation.Autowired;
21
import org.springframework.beans.factory.annotation.Autowired;
19
import org.springframework.beans.factory.annotation.Value;
22
import org.springframework.beans.factory.annotation.Value;
-
 
23
import org.springframework.core.io.InputStreamResource;
-
 
24
import org.springframework.http.HttpHeaders;
-
 
25
import org.springframework.http.HttpStatus;
-
 
26
import org.springframework.http.MediaType;
20
import org.springframework.http.ResponseEntity;
27
import org.springframework.http.ResponseEntity;
21
import org.springframework.stereotype.Controller;
28
import org.springframework.stereotype.Controller;
22
import org.springframework.transaction.annotation.Transactional;
29
import org.springframework.transaction.annotation.Transactional;
23
import org.springframework.ui.Model;
30
import org.springframework.ui.Model;
24
import org.springframework.web.bind.annotation.RequestBody;
31
import org.springframework.web.bind.annotation.RequestBody;
Line 490... Line 497...
490
			LOGGER.error("Unable to get valid interval values", e);
497
			LOGGER.error("Unable to get valid interval values", e);
491
			return responseSender.badRequest(e);
498
			return responseSender.badRequest(e);
492
		}
499
		}
493
		List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryItemAgingService.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
500
		List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryItemAgingService.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
494
		//return responseSender.ok(inventoryItemAgingModels);
501
		//return responseSender.ok(inventoryItemAgingModels);
-
 
502
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
495
		ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals);
503
		ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
-
 
504
		
-
 
505
		final HttpHeaders headers=new HttpHeaders();
-
 
506
		//private static final String CONTENT_TYPE_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
-
 
507
        headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
-
 
508
        //headers.set("Content-Type", "application/vnd.ms-excel");
-
 
509
		headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
-
 
510
        headers.setContentLength(byteArrayOutputStream.toByteArray().length);
-
 
511
        final InputStream inputStream=new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
-
 
512
        final InputStreamResource inputStreamResource=new InputStreamResource(inputStream);
-
 
513
        return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
-
 
514
		
496
		return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
515
		//return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
497
	}
516
	}
498
	
517
	
499
	
518
	
500
	private void validateIntervals(List<Integer> intervals)throws ProfitMandiBusinessException{
519
	private void validateIntervals(List<Integer> intervals)throws ProfitMandiBusinessException{
501
		if(intervals.isEmpty()){
520
		if(intervals.isEmpty()){