| Line 28... |
Line 28... |
| 28 |
import org.apache.poi.xssf.usermodel.XSSFRow;
|
28 |
import org.apache.poi.xssf.usermodel.XSSFRow;
|
| 29 |
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
29 |
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
| 30 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
30 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| 31 |
|
31 |
|
| 32 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
32 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
33 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 33 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
34 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 34 |
import com.spice.profitmandi.common.model.InventoryItemAgingValue;
|
35 |
import com.spice.profitmandi.common.model.InventoryItemAgingValue;
|
| 35 |
import com.spice.profitmandi.common.model.ItemCompleteLedgerModel;
|
36 |
import com.spice.profitmandi.common.model.ItemCompleteLedgerModel;
|
| 36 |
import com.spice.profitmandi.common.model.PartnerTargetModel;
|
37 |
import com.spice.profitmandi.common.model.PartnerTargetModel;
|
| 37 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
38 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 38 |
import com.spice.profitmandi.common.model.SchemeModel;
|
39 |
import com.spice.profitmandi.common.model.SchemeModel;
|
| 39 |
import com.spice.profitmandi.common.model.TagListingModel;
|
40 |
import com.spice.profitmandi.common.model.TagListingModel;
|
| 40 |
|
41 |
|
| - |
|
42 |
import in.shop2020.model.v1.catalog.SalesPotential;
|
| - |
|
43 |
|
| 41 |
public class ExcelUtils {
|
44 |
public class ExcelUtils {
|
| 42 |
private static final String TAG_ID = "Tag Id";
|
45 |
private static final String TAG_ID = "Tag Id";
|
| 43 |
private static final String TAG_LABEL = "Tag Label";
|
46 |
private static final String TAG_LABEL = "Tag Label";
|
| 44 |
private static final String ITEM_ID = "Item Id";
|
47 |
private static final String ITEM_ID = "Item Id";
|
| 45 |
private static final String BRAND = "Brand";
|
48 |
private static final String BRAND = "Brand";
|
| Line 52... |
Line 55... |
| 52 |
private static final String START_DATE = "Start Date";
|
55 |
private static final String START_DATE = "Start Date";
|
| 53 |
private static final String TAG_LISTING = "Tag Listing";
|
56 |
private static final String TAG_LISTING = "Tag Listing";
|
| 54 |
private static final String FOFO_ID = "fofoId";
|
57 |
private static final String FOFO_ID = "fofoId";
|
| 55 |
private static final String STORE_NAME = "storeName";
|
58 |
private static final String STORE_NAME = "storeName";
|
| 56 |
private static final String EMAIL = "email";
|
59 |
private static final String EMAIL = "email";
|
| 57 |
private static final String TARGET_VALUE="targetValue";
|
60 |
private static final String TARGET_VALUE = "targetValue";
|
| 58 |
|
61 |
|
| 59 |
private static final Logger LOGGER = LogManager.getLogger(ExcelUtils.class);
|
62 |
private static final Logger LOGGER = LogManager.getLogger(ExcelUtils.class);
|
| 60 |
|
63 |
|
| 61 |
public static void main(String[] args) throws Throwable{
|
64 |
public static void main(String[] args) throws Throwable {
|
| 62 |
//List<Integer> intervals = Arrays.asList(5, 10, 15, 20, 25);
|
65 |
// List<Integer> intervals = Arrays.asList(5, 10, 15, 20, 25);
|
| 63 |
//writeInventoryItemAgingModels(inventoryItemAgingModels, intervals);
|
66 |
// writeInventoryItemAgingModels(inventoryItemAgingModels, intervals);
|
| 64 |
}
|
67 |
}
|
| - |
|
68 |
|
| 65 |
public static List<TagListingModel> parse(InputStream inputStream) throws Exception {
|
69 |
public static List<TagListingModel> parse(InputStream inputStream) throws Exception {
|
| 66 |
|
70 |
|
| 67 |
List<TagListingModel> tagListings = new ArrayList<>();
|
71 |
List<TagListingModel> tagListings = new ArrayList<>();
|
| 68 |
XSSFWorkbook myWorkBook = null;
|
72 |
XSSFWorkbook myWorkBook = null;
|
| 69 |
try{
|
73 |
try {
|
| - |
|
74 |
// FileInputStream fileInputStream = new
|
| 70 |
//FileInputStream fileInputStream = new FileInputStream("/home/ashikali/tag_listing1.xlsx");
|
75 |
// FileInputStream("/home/ashikali/tag_listing1.xlsx");
|
| 71 |
myWorkBook = new XSSFWorkbook (inputStream);
|
76 |
myWorkBook = new XSSFWorkbook(inputStream);
|
| 72 |
|
77 |
|
| 73 |
myWorkBook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
|
78 |
myWorkBook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
|
| 74 |
// Return first sheet from the XLSX workbook
|
79 |
// Return first sheet from the XLSX workbook
|
| 75 |
XSSFSheet mySheet = myWorkBook.getSheetAt(0);
|
80 |
XSSFSheet mySheet = myWorkBook.getSheetAt(0);
|
| 76 |
LOGGER.info("rowCellNum {}", mySheet.getLastRowNum());
|
81 |
LOGGER.info("rowCellNum {}", mySheet.getLastRowNum());
|
| 77 |
|
82 |
|
| 78 |
for(int rowNumber = 1; rowNumber <= mySheet.getLastRowNum(); rowNumber++){
|
83 |
for (int rowNumber = 1; rowNumber <= mySheet.getLastRowNum(); rowNumber++) {
|
| 79 |
XSSFRow row = mySheet.getRow(rowNumber);
|
84 |
XSSFRow row = mySheet.getRow(rowNumber);
|
| 80 |
LOGGER.info("row {}", row);
|
85 |
LOGGER.info("row {}", row);
|
| 81 |
TagListingModel tagListing = new TagListingModel();
|
86 |
TagListingModel tagListing = new TagListingModel();
|
| 82 |
if(row.getCell(0) != null && row.getCell(0).getCellTypeEnum() == CellType.NUMERIC){
|
87 |
if (row.getCell(0) != null && row.getCell(0).getCellTypeEnum() == CellType.NUMERIC) {
|
| 83 |
tagListing.setTagId((Double.valueOf(row.getCell(0).getNumericCellValue())).intValue());
|
88 |
tagListing.setTagId((Double.valueOf(row.getCell(0).getNumericCellValue())).intValue());
|
| 84 |
}else{
|
89 |
} else {
|
| 85 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(TAG_ID, row.getCell(0).toString(), "TGLSTNG_VE_1010");
|
90 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(TAG_ID,
|
| - |
|
91 |
row.getCell(0).toString(), "TGLSTNG_VE_1010");
|
| 86 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
92 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
| 87 |
throw profitMandiBusinessException;
|
93 |
throw profitMandiBusinessException;
|
| 88 |
}
|
94 |
}
|
| 89 |
|
95 |
|
| 90 |
if(row.getCell(2) != null && row.getCell(2).getCellTypeEnum() == CellType.NUMERIC){
|
96 |
if (row.getCell(2) != null && row.getCell(2).getCellTypeEnum() == CellType.NUMERIC) {
|
| 91 |
tagListing.setItemId(Double.valueOf(row.getCell(2).toString()).intValue());
|
97 |
tagListing.setItemId(Double.valueOf(row.getCell(2).toString()).intValue());
|
| 92 |
}else{
|
98 |
} else {
|
| 93 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(ITEM_ID, row.getCell(2).toString(), "TGLSTNG_VE_1010");
|
99 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
|
| - |
|
100 |
ITEM_ID, row.getCell(2).toString(), "TGLSTNG_VE_1010");
|
| 94 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
101 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
| 95 |
throw profitMandiBusinessException;
|
102 |
throw profitMandiBusinessException;
|
| 96 |
}
|
103 |
}
|
| 97 |
|
104 |
|
| 98 |
if(row.getCell(7) != null && row.getCell(7).getCellTypeEnum() == CellType.NUMERIC){
|
105 |
if (row.getCell(7) != null && row.getCell(7).getCellTypeEnum() == CellType.NUMERIC) {
|
| 99 |
tagListing.setSellingPrice(Double.valueOf(row.getCell(7).toString()).floatValue());
|
106 |
tagListing.setSellingPrice(Double.valueOf(row.getCell(7).toString()).floatValue());
|
| 100 |
}else{
|
107 |
} else {
|
| 101 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(SELLING_PRICE, row.getCell(7), "TGLSTNG_VE_1010");
|
108 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
|
| - |
|
109 |
SELLING_PRICE, row.getCell(7), "TGLSTNG_VE_1010");
|
| 102 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
110 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
| 103 |
throw profitMandiBusinessException;
|
111 |
throw profitMandiBusinessException;
|
| 104 |
}
|
112 |
}
|
| 105 |
if(row.getCell(8) != null && row.getCell(8).getCellTypeEnum() == CellType.NUMERIC){
|
113 |
if (row.getCell(8) != null && row.getCell(8).getCellTypeEnum() == CellType.NUMERIC) {
|
| 106 |
tagListing.setMop(Double.valueOf(row.getCell(8).toString()).floatValue());
|
114 |
tagListing.setMop(Double.valueOf(row.getCell(8).toString()).floatValue());
|
| 107 |
}else{
|
115 |
} else {
|
| 108 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(MOP, row.getCell(8), "TGLSTNG_VE_1010");
|
116 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(MOP,
|
| - |
|
117 |
row.getCell(8), "TGLSTNG_VE_1010");
|
| 109 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
118 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
| 110 |
throw profitMandiBusinessException;
|
119 |
throw profitMandiBusinessException;
|
| 111 |
}
|
120 |
}
|
| 112 |
if(row.getCell(9) != null && row.getCell(9).getCellTypeEnum() == CellType.NUMERIC){
|
121 |
if (row.getCell(9) != null && row.getCell(9).getCellTypeEnum() == CellType.NUMERIC) {
|
| 113 |
tagListing.setSupportPrice(Double.valueOf(row.getCell(9).toString()).floatValue());
|
122 |
tagListing.setSupportPrice(Double.valueOf(row.getCell(9).toString()).floatValue());
|
| 114 |
}else{
|
123 |
} else {
|
| 115 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(SUPPORT_PRICE, row.getCell(9).toString(), "TGLSTNG_VE_1010");
|
124 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
|
| - |
|
125 |
SUPPORT_PRICE, row.getCell(9).toString(), "TGLSTNG_VE_1010");
|
| 116 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
126 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
| 117 |
throw profitMandiBusinessException;
|
127 |
throw profitMandiBusinessException;
|
| 118 |
}
|
128 |
}
|
| 119 |
if(row.getCell(10) != null && row.getCell(10).getCellTypeEnum() == CellType.NUMERIC){
|
129 |
if (row.getCell(10) != null && row.getCell(10).getCellTypeEnum() == CellType.NUMERIC) {
|
| 120 |
tagListing.setMaxDiscountPrice(Double.valueOf(row.getCell(10).toString()).floatValue());
|
130 |
tagListing.setMaxDiscountPrice(Double.valueOf(row.getCell(10).toString()).floatValue());
|
| 121 |
}else{
|
131 |
} else {
|
| 122 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(SUPPORT_PRICE, row.getCell(10).toString(), "TGLSTNG_VE_1010");
|
132 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
|
| - |
|
133 |
SUPPORT_PRICE, row.getCell(10).toString(), "TGLSTNG_VE_1010");
|
| 123 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
134 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
| 124 |
throw profitMandiBusinessException;
|
135 |
throw profitMandiBusinessException;
|
| 125 |
}
|
136 |
}
|
| 126 |
if(row.getCell(11) != null && HSSFDateUtil.isCellDateFormatted(row.getCell(11))){
|
137 |
if (row.getCell(11) != null && HSSFDateUtil.isCellDateFormatted(row.getCell(11))) {
|
| 127 |
Date date = row.getCell(11).getDateCellValue();
|
138 |
Date date = row.getCell(11).getDateCellValue();
|
| 128 |
LocalDateTime startDate = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
|
139 |
LocalDateTime startDate = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
|
| 129 |
tagListing.setStartDate(startDate);
|
140 |
tagListing.setStartDate(startDate);
|
| 130 |
}else{
|
141 |
} else {
|
| 131 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(START_DATE, row.getCell(11).toString(), "TGLSTNG_VE_1010");
|
142 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
|
| - |
|
143 |
START_DATE, row.getCell(11).toString(), "TGLSTNG_VE_1010");
|
| 132 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
144 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
| 133 |
throw profitMandiBusinessException;
|
145 |
throw profitMandiBusinessException;
|
| 134 |
}
|
146 |
}
|
| 135 |
tagListings.add(tagListing);
|
147 |
tagListings.add(tagListing);
|
| 136 |
}
|
148 |
}
|
| 137 |
myWorkBook.close();
|
149 |
myWorkBook.close();
|
| 138 |
} catch(IOException ioException){
|
150 |
} catch (IOException ioException) {
|
| 139 |
ioException.printStackTrace();
|
151 |
ioException.printStackTrace();
|
| 140 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.EXCEL_FILE, ioException.getMessage(), "EXL_VE_1000");
|
152 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.EXCEL_FILE, ioException.getMessage(),
|
| - |
|
153 |
"EXL_VE_1000");
|
| 141 |
} finally {
|
154 |
} finally {
|
| 142 |
if(myWorkBook != null){
|
155 |
if (myWorkBook != null) {
|
| 143 |
try {
|
156 |
try {
|
| 144 |
myWorkBook.close();
|
157 |
myWorkBook.close();
|
| 145 |
} catch (IOException e) {
|
158 |
} catch (IOException e) {
|
| 146 |
// TODO Auto-generated catch block
|
159 |
// TODO Auto-generated catch block
|
| 147 |
e.printStackTrace();
|
160 |
e.printStackTrace();
|
| 148 |
}
|
161 |
}
|
| 149 |
}
|
162 |
}
|
| 150 |
}
|
163 |
}
|
| 151 |
return tagListings;
|
164 |
return tagListings;
|
| 152 |
}
|
165 |
}
|
| 153 |
|
166 |
|
| 154 |
public static void writeInventoryItemAgingModels(List<InventoryItemAgingModel> inventoryItemAgingModels, List<Integer> intervals, OutputStream outputStream){
|
167 |
public static void writeInventoryItemAgingModels(List<InventoryItemAgingModel> inventoryItemAgingModels,
|
| - |
|
168 |
List<Integer> intervals, OutputStream outputStream) {
|
| 155 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
169 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
| 156 |
|
170 |
|
| 157 |
//CreationHelper createHelper = workbook.getCreationHelper();
|
171 |
// CreationHelper createHelper = workbook.getCreationHelper();
|
| 158 |
|
172 |
|
| 159 |
SXSSFSheet sheet = workbook.createSheet("InventoryItemAging");
|
173 |
SXSSFSheet sheet = workbook.createSheet("InventoryItemAging");
|
| 160 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
|
174 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
|
| 161 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
|
175 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
|
| 162 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
|
176 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
|
| 163 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
|
177 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
|
| 164 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
|
178 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
|
| 165 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
|
179 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
|
| 166 |
sheet.trackAllColumnsForAutoSizing();
|
180 |
sheet.trackAllColumnsForAutoSizing();
|
| 167 |
|
- |
|
| 168 |
|
181 |
|
| 169 |
Row rowHeader = sheet.createRow(0);
|
182 |
Row rowHeader = sheet.createRow(0);
|
| 170 |
Cell cellItemIdHeader = rowHeader.createCell(0);
|
183 |
Cell cellItemIdHeader = rowHeader.createCell(0);
|
| 171 |
cellItemIdHeader.setCellValue("Item Id");
|
184 |
cellItemIdHeader.setCellValue("Item Id");
|
| 172 |
Cell cellBrandHeader = rowHeader.createCell(1);
|
185 |
Cell cellBrandHeader = rowHeader.createCell(1);
|
| 173 |
cellBrandHeader.setCellValue("Brand");
|
186 |
cellBrandHeader.setCellValue("Brand");
|
| 174 |
Cell cellModelNameHeader = rowHeader.createCell(2);
|
187 |
Cell cellModelNameHeader = rowHeader.createCell(2);
|
| 175 |
cellModelNameHeader.setCellValue("Model Name");
|
188 |
cellModelNameHeader.setCellValue("Model Name");
|
| Line 178... |
Line 191... |
| 178 |
Cell cellColorHeader = rowHeader.createCell(4);
|
191 |
Cell cellColorHeader = rowHeader.createCell(4);
|
| 179 |
cellColorHeader.setCellValue("Color");
|
192 |
cellColorHeader.setCellValue("Color");
|
| 180 |
Cell cellTypeHeader = rowHeader.createCell(5);
|
193 |
Cell cellTypeHeader = rowHeader.createCell(5);
|
| 181 |
cellTypeHeader.setCellValue("Item Type");
|
194 |
cellTypeHeader.setCellValue("Item Type");
|
| 182 |
Row rowPriceQuantity = sheet.createRow(1);
|
195 |
Row rowPriceQuantity = sheet.createRow(1);
|
| 183 |
for(int index = 0, colIndex = 6; index < intervals.size() + 1; index++, colIndex = colIndex + 2){
|
196 |
for (int index = 0, colIndex = 6; index < intervals.size() + 1; index++, colIndex = colIndex + 2) {
|
| 184 |
Cell cellHeader = rowHeader.createCell(colIndex);
|
197 |
Cell cellHeader = rowHeader.createCell(colIndex);
|
| 185 |
if(index == 0){
|
198 |
if (index == 0) {
|
| 186 |
cellHeader.setCellValue("Less Than "+intervals.get(index)+" Days");
|
199 |
cellHeader.setCellValue("Less Than " + intervals.get(index) + " Days");
|
| 187 |
}else if(index < intervals.size()){
|
200 |
} else if (index < intervals.size()) {
|
| 188 |
cellHeader.setCellValue(intervals.get(index - 1) + " - " + intervals.get(index) + " Days");
|
201 |
cellHeader.setCellValue(intervals.get(index - 1) + " - " + intervals.get(index) + " Days");
|
| 189 |
}else{
|
202 |
} else {
|
| 190 |
cellHeader.setCellValue("More Than "+intervals.get(index - 1)+" Days");
|
203 |
cellHeader.setCellValue("More Than " + intervals.get(index - 1) + " Days");
|
| 191 |
}
|
204 |
}
|
| 192 |
sheet.addMergedRegion(new CellRangeAddress(0, 0, colIndex, colIndex + 1));
|
205 |
sheet.addMergedRegion(new CellRangeAddress(0, 0, colIndex, colIndex + 1));
|
| 193 |
rowHeader.createCell(colIndex + 1);
|
206 |
rowHeader.createCell(colIndex + 1);
|
| 194 |
Cell cellPrice = rowPriceQuantity.createCell(colIndex);
|
207 |
Cell cellPrice = rowPriceQuantity.createCell(colIndex);
|
| 195 |
cellPrice.setCellValue("Price");
|
208 |
cellPrice.setCellValue("Price");
|
| Line 197... |
Line 210... |
| 197 |
cellQuantity.setCellValue("Quantity");
|
210 |
cellQuantity.setCellValue("Quantity");
|
| 198 |
}
|
211 |
}
|
| 199 |
Font font = workbook.createFont();
|
212 |
Font font = workbook.createFont();
|
| 200 |
CellStyle cellStyle = workbook.createCellStyle();
|
213 |
CellStyle cellStyle = workbook.createCellStyle();
|
| 201 |
font.setBold(true);
|
214 |
font.setBold(true);
|
| 202 |
//font.setFontHeight((short)16);
|
215 |
// font.setFontHeight((short)16);
|
| 203 |
cellStyle.setFont(font);
|
216 |
cellStyle.setFont(font);
|
| 204 |
for(int i = 0; i < 8 + (intervals.size() * 2); i++){
|
217 |
for (int i = 0; i < 8 + (intervals.size() * 2); i++) {
|
| 205 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
218 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
| 206 |
if(rowPriceQuantity.getCell(i) != null){
|
219 |
if (rowPriceQuantity.getCell(i) != null) {
|
| 207 |
rowPriceQuantity.getCell(i).setCellStyle(cellStyle);
|
220 |
rowPriceQuantity.getCell(i).setCellStyle(cellStyle);
|
| 208 |
}
|
221 |
}
|
| 209 |
}
|
222 |
}
|
| 210 |
|
223 |
|
| 211 |
for(int index = 0; index < inventoryItemAgingModels.size(); index++){
|
224 |
for (int index = 0; index < inventoryItemAgingModels.size(); index++) {
|
| 212 |
InventoryItemAgingModel inventoryItemAgingModel = inventoryItemAgingModels.get(index);
|
225 |
InventoryItemAgingModel inventoryItemAgingModel = inventoryItemAgingModels.get(index);
|
| 213 |
Row rowValues = sheet.createRow(index + 2);
|
226 |
Row rowValues = sheet.createRow(index + 2);
|
| 214 |
Cell cellItemId = rowValues.createCell(0);
|
227 |
Cell cellItemId = rowValues.createCell(0);
|
| 215 |
cellItemId.setCellValue(inventoryItemAgingModel.getItemId());
|
228 |
cellItemId.setCellValue(inventoryItemAgingModel.getItemId());
|
| 216 |
Cell cellBrand = rowValues.createCell(1);
|
229 |
Cell cellBrand = rowValues.createCell(1);
|
| 217 |
cellBrand.setCellValue(inventoryItemAgingModel.getBrand());
|
230 |
cellBrand.setCellValue(inventoryItemAgingModel.getBrand());
|
| 218 |
Cell cellModelName = rowValues.createCell(2);
|
231 |
Cell cellModelName = rowValues.createCell(2);
|
| 219 |
cellModelName.setCellValue(inventoryItemAgingModel.getModelName());
|
232 |
cellModelName.setCellValue(inventoryItemAgingModel.getModelName());
|
| 220 |
Cell cellModelNumber = rowValues.createCell(3);
|
233 |
Cell cellModelNumber = rowValues.createCell(3);
|
| 221 |
cellModelNumber.setCellValue(inventoryItemAgingModel.getModelNumber());
|
234 |
cellModelNumber.setCellValue(inventoryItemAgingModel.getModelNumber());
|
| 222 |
Cell cellColor = rowValues.createCell(4);
|
235 |
Cell cellColor = rowValues.createCell(4);
|
| 223 |
cellColor.setCellValue(inventoryItemAgingModel.getColor());
|
236 |
cellColor.setCellValue(inventoryItemAgingModel.getColor());
|
| 224 |
Cell cellType = rowValues.createCell(5);
|
237 |
Cell cellType = rowValues.createCell(5);
|
| 225 |
cellType.setCellValue(inventoryItemAgingModel.getItemType().toString());
|
238 |
cellType.setCellValue(inventoryItemAgingModel.getItemType().toString());
|
| 226 |
List<InventoryItemAgingValue> inventoryItemAgingValues = inventoryItemAgingModel.getValues();
|
239 |
List<InventoryItemAgingValue> inventoryItemAgingValues = inventoryItemAgingModel.getValues();
|
| 227 |
//LOGGER.info("inventoryItemAgingValues {}", inventoryItemAgingValues);
|
240 |
// LOGGER.info("inventoryItemAgingValues {}", inventoryItemAgingValues);
|
| 228 |
for(int i = 0, colIndex = 6; i < inventoryItemAgingValues.size(); i++, colIndex = colIndex + 2){
|
241 |
for (int i = 0, colIndex = 6; i < inventoryItemAgingValues.size(); i++, colIndex = colIndex + 2) {
|
| 229 |
Cell cellPrice = rowValues.createCell(colIndex);
|
242 |
Cell cellPrice = rowValues.createCell(colIndex);
|
| 230 |
InventoryItemAgingValue inventoryItemAgingValue = inventoryItemAgingValues.get(i);
|
243 |
InventoryItemAgingValue inventoryItemAgingValue = inventoryItemAgingValues.get(i);
|
| 231 |
//LOGGER.info("inventoryItemAgingValue {}", inventoryItemAgingValue);
|
244 |
// LOGGER.info("inventoryItemAgingValue {}", inventoryItemAgingValue);
|
| 232 |
Cell cellQuantity = rowValues.createCell(colIndex + 1);
|
245 |
Cell cellQuantity = rowValues.createCell(colIndex + 1);
|
| 233 |
if(inventoryItemAgingValue != null){
|
246 |
if (inventoryItemAgingValue != null) {
|
| 234 |
cellPrice.setCellValue(inventoryItemAgingValue.getPrice());
|
247 |
cellPrice.setCellValue(inventoryItemAgingValue.getPrice());
|
| 235 |
cellQuantity.setCellValue(inventoryItemAgingValue.getQuantity());
|
248 |
cellQuantity.setCellValue(inventoryItemAgingValue.getQuantity());
|
| 236 |
}else{
|
249 |
} else {
|
| 237 |
cellPrice.setCellValue("-");
|
250 |
cellPrice.setCellValue("-");
|
| 238 |
cellQuantity.setCellValue("-");
|
251 |
cellQuantity.setCellValue("-");
|
| 239 |
}
|
252 |
}
|
| 240 |
}
|
253 |
}
|
| 241 |
}
|
254 |
}
|
| 242 |
|
255 |
|
| 243 |
for(int index = 0; index < 8 + (intervals.size() * 2); index++){
|
256 |
for (int index = 0; index < 8 + (intervals.size() * 2); index++) {
|
| 244 |
sheet.autoSizeColumn(index);
|
257 |
sheet.autoSizeColumn(index);
|
| 245 |
}
|
258 |
}
|
| 246 |
|
259 |
|
| 247 |
try{
|
260 |
try {
|
| 248 |
workbook.write(outputStream);
|
261 |
workbook.write(outputStream);
|
| 249 |
workbook.close();
|
262 |
workbook.close();
|
| 250 |
}catch(IOException ioException){
|
263 |
} catch (IOException ioException) {
|
| 251 |
LOGGER.error("Unable to generate excel file", ioException);
|
264 |
LOGGER.error("Unable to generate excel file", ioException);
|
| 252 |
}
|
265 |
}
|
| 253 |
}
|
266 |
}
|
| 254 |
|
267 |
|
| 255 |
public static void writeItemCompleteLedgerModels(List<ItemCompleteLedgerModel> itemCompleteLedgerModels, OutputStream outputStream){
|
268 |
public static void writeItemCompleteLedgerModels(List<ItemCompleteLedgerModel> itemCompleteLedgerModels,
|
| - |
|
269 |
OutputStream outputStream) {
|
| 256 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
270 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
| 257 |
|
271 |
|
| 258 |
//CreationHelper createHelper = workbook.getCreationHelper();
|
272 |
// CreationHelper createHelper = workbook.getCreationHelper();
|
| 259 |
|
273 |
|
| 260 |
SXSSFSheet sheet = workbook.createSheet("ItemCompleteLeger");
|
274 |
SXSSFSheet sheet = workbook.createSheet("ItemCompleteLeger");
|
| 261 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
|
275 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
|
| 262 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
|
276 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
|
| 263 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
|
277 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
|
| 264 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
|
278 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
|
| 265 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
|
279 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
|
| 266 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
|
280 |
sheet.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
|
| 267 |
sheet.trackAllColumnsForAutoSizing();
|
281 |
sheet.trackAllColumnsForAutoSizing();
|
| 268 |
|
- |
|
| 269 |
|
282 |
|
| 270 |
Row rowHeader = sheet.createRow(0);
|
283 |
Row rowHeader = sheet.createRow(0);
|
| 271 |
Cell cellItemIdHeader = rowHeader.createCell(0);
|
284 |
Cell cellItemIdHeader = rowHeader.createCell(0);
|
| 272 |
cellItemIdHeader.setCellValue("Item Id");
|
285 |
cellItemIdHeader.setCellValue("Item Id");
|
| 273 |
Cell cellBrandHeader = rowHeader.createCell(1);
|
286 |
Cell cellBrandHeader = rowHeader.createCell(1);
|
| 274 |
cellBrandHeader.setCellValue("Brand");
|
287 |
cellBrandHeader.setCellValue("Brand");
|
| 275 |
Cell cellModelNameHeader = rowHeader.createCell(2);
|
288 |
Cell cellModelNameHeader = rowHeader.createCell(2);
|
| 276 |
cellModelNameHeader.setCellValue("Model Name");
|
289 |
cellModelNameHeader.setCellValue("Model Name");
|
| Line 287... |
Line 300... |
| 287 |
Cell cellOutwardsHeader = rowHeader.createCell(12);
|
300 |
Cell cellOutwardsHeader = rowHeader.createCell(12);
|
| 288 |
cellOutwardsHeader.setCellValue("Outwards");
|
301 |
cellOutwardsHeader.setCellValue("Outwards");
|
| 289 |
Cell cellClosingBalanceHeader = rowHeader.createCell(15);
|
302 |
Cell cellClosingBalanceHeader = rowHeader.createCell(15);
|
| 290 |
cellClosingBalanceHeader.setCellValue("Closing Balance");
|
303 |
cellClosingBalanceHeader.setCellValue("Closing Balance");
|
| 291 |
Row rowQuantityRateValue = sheet.createRow(1);
|
304 |
Row rowQuantityRateValue = sheet.createRow(1);
|
| 292 |
|
305 |
|
| 293 |
for(int index = 6; index < 18; index = index + 3){
|
306 |
for (int index = 6; index < 18; index = index + 3) {
|
| 294 |
Cell cellQuantityHeader = rowQuantityRateValue.createCell(index);
|
307 |
Cell cellQuantityHeader = rowQuantityRateValue.createCell(index);
|
| 295 |
cellQuantityHeader.setCellValue("Quantity");
|
308 |
cellQuantityHeader.setCellValue("Quantity");
|
| 296 |
Cell cellRateHeader = rowQuantityRateValue.createCell(index + 1);
|
309 |
Cell cellRateHeader = rowQuantityRateValue.createCell(index + 1);
|
| 297 |
cellRateHeader.setCellValue("Rate");
|
310 |
cellRateHeader.setCellValue("Rate");
|
| 298 |
Cell cellValueHeader = rowQuantityRateValue.createCell(index + 2);
|
311 |
Cell cellValueHeader = rowQuantityRateValue.createCell(index + 2);
|
| Line 301... |
Line 314... |
| 301 |
}
|
314 |
}
|
| 302 |
Font font = workbook.createFont();
|
315 |
Font font = workbook.createFont();
|
| 303 |
CellStyle cellStyle = workbook.createCellStyle();
|
316 |
CellStyle cellStyle = workbook.createCellStyle();
|
| 304 |
font.setBold(true);
|
317 |
font.setBold(true);
|
| 305 |
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
318 |
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
| 306 |
//font.setFontHeight((short)16);
|
319 |
// font.setFontHeight((short)16);
|
| 307 |
cellStyle.setFont(font);
|
320 |
cellStyle.setFont(font);
|
| 308 |
for(int i = 0; i < 18; i++){
|
321 |
for (int i = 0; i < 18; i++) {
|
| 309 |
if(rowHeader.getCell(i) != null){
|
322 |
if (rowHeader.getCell(i) != null) {
|
| 310 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
323 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
| 311 |
}
|
324 |
}
|
| 312 |
}
|
325 |
}
|
| 313 |
int openingQuantityTotal = 0;
|
326 |
int openingQuantityTotal = 0;
|
| 314 |
float openingValueTotal = 0;
|
327 |
float openingValueTotal = 0;
|
| Line 316... |
Line 329... |
| 316 |
float inwardsValueTotal = 0;
|
329 |
float inwardsValueTotal = 0;
|
| 317 |
int outwardsQuantityTotal = 0;
|
330 |
int outwardsQuantityTotal = 0;
|
| 318 |
float outwardsValueTotal = 0;
|
331 |
float outwardsValueTotal = 0;
|
| 319 |
int closingQuantityTotal = 0;
|
332 |
int closingQuantityTotal = 0;
|
| 320 |
float closingValueTotal = 0;
|
333 |
float closingValueTotal = 0;
|
| 321 |
for(int index = 0; index < itemCompleteLedgerModels.size(); index++){
|
334 |
for (int index = 0; index < itemCompleteLedgerModels.size(); index++) {
|
| 322 |
ItemCompleteLedgerModel itemCompleteLedgerModel = itemCompleteLedgerModels.get(index);
|
335 |
ItemCompleteLedgerModel itemCompleteLedgerModel = itemCompleteLedgerModels.get(index);
|
| 323 |
Row rowValues = sheet.createRow(index + 2);
|
336 |
Row rowValues = sheet.createRow(index + 2);
|
| 324 |
Cell cellItemId = rowValues.createCell(0);
|
337 |
Cell cellItemId = rowValues.createCell(0);
|
| 325 |
cellItemId.setCellValue(itemCompleteLedgerModel.getItemValue().getItemId());
|
338 |
cellItemId.setCellValue(itemCompleteLedgerModel.getItemValue().getItemId());
|
| 326 |
Cell cellBrand = rowValues.createCell(1);
|
339 |
Cell cellBrand = rowValues.createCell(1);
|
| 327 |
cellBrand.setCellValue(itemCompleteLedgerModel.getItemValue().getBrand());
|
340 |
cellBrand.setCellValue(itemCompleteLedgerModel.getItemValue().getBrand());
|
| 328 |
Cell cellModelName = rowValues.createCell(2);
|
341 |
Cell cellModelName = rowValues.createCell(2);
|
| 329 |
cellModelName.setCellValue(itemCompleteLedgerModel.getItemValue().getModelName());
|
342 |
cellModelName.setCellValue(itemCompleteLedgerModel.getItemValue().getModelName());
|
| 330 |
Cell cellModelNumber = rowValues.createCell(3);
|
343 |
Cell cellModelNumber = rowValues.createCell(3);
|
| 331 |
cellModelNumber.setCellValue(itemCompleteLedgerModel.getItemValue().getModelNumber());
|
344 |
cellModelNumber.setCellValue(itemCompleteLedgerModel.getItemValue().getModelNumber());
|
| 332 |
Cell cellColor = rowValues.createCell(4);
|
345 |
Cell cellColor = rowValues.createCell(4);
|
| 333 |
cellColor.setCellValue(itemCompleteLedgerModel.getItemValue().getColor());
|
346 |
cellColor.setCellValue(itemCompleteLedgerModel.getItemValue().getColor());
|
| 334 |
Cell cellType = rowValues.createCell(5);
|
347 |
Cell cellType = rowValues.createCell(5);
|
| 335 |
cellType.setCellValue(itemCompleteLedgerModel.getItemValue().getItemType().toString());
|
348 |
cellType.setCellValue(itemCompleteLedgerModel.getItemValue().getItemType().toString());
|
| 336 |
Cell cellOpeningQuantity = rowValues.createCell(6);
|
349 |
Cell cellOpeningQuantity = rowValues.createCell(6);
|
| 337 |
Cell cellOpeningRate = rowValues.createCell(7);
|
350 |
Cell cellOpeningRate = rowValues.createCell(7);
|
| 338 |
Cell cellOpeningValue = rowValues.createCell(8);
|
351 |
Cell cellOpeningValue = rowValues.createCell(8);
|
| 339 |
if(itemCompleteLedgerModel.getOpeningLedger() == null){
|
352 |
if (itemCompleteLedgerModel.getOpeningLedger() == null) {
|
| 340 |
cellOpeningQuantity.setCellValue("-");
|
353 |
cellOpeningQuantity.setCellValue("-");
|
| 341 |
cellOpeningRate.setCellValue("-");
|
354 |
cellOpeningRate.setCellValue("-");
|
| 342 |
cellOpeningValue.setCellValue("-");
|
355 |
cellOpeningValue.setCellValue("-");
|
| 343 |
}else{
|
356 |
} else {
|
| 344 |
cellOpeningQuantity.setCellValue(itemCompleteLedgerModel.getOpeningLedger().getQuantity());
|
357 |
cellOpeningQuantity.setCellValue(itemCompleteLedgerModel.getOpeningLedger().getQuantity());
|
| 345 |
cellOpeningRate.setCellValue(itemCompleteLedgerModel.getOpeningLedger().getRate());
|
358 |
cellOpeningRate.setCellValue(itemCompleteLedgerModel.getOpeningLedger().getRate());
|
| 346 |
cellOpeningValue.setCellValue(itemCompleteLedgerModel.getOpeningLedger().getValue());
|
359 |
cellOpeningValue.setCellValue(itemCompleteLedgerModel.getOpeningLedger().getValue());
|
| 347 |
openingQuantityTotal = openingQuantityTotal + itemCompleteLedgerModel.getOpeningLedger().getQuantity();
|
360 |
openingQuantityTotal = openingQuantityTotal + itemCompleteLedgerModel.getOpeningLedger().getQuantity();
|
| 348 |
openingValueTotal = openingValueTotal + itemCompleteLedgerModel.getOpeningLedger().getValue();
|
361 |
openingValueTotal = openingValueTotal + itemCompleteLedgerModel.getOpeningLedger().getValue();
|
| 349 |
}
|
362 |
}
|
| 350 |
Cell cellInwardsQuantity = rowValues.createCell(9);
|
363 |
Cell cellInwardsQuantity = rowValues.createCell(9);
|
| 351 |
Cell cellInwardsRate = rowValues.createCell(10);
|
364 |
Cell cellInwardsRate = rowValues.createCell(10);
|
| 352 |
Cell cellInwardsValue = rowValues.createCell(11);
|
365 |
Cell cellInwardsValue = rowValues.createCell(11);
|
| 353 |
if(itemCompleteLedgerModel.getInwardsLedger() == null){
|
366 |
if (itemCompleteLedgerModel.getInwardsLedger() == null) {
|
| 354 |
cellInwardsQuantity.setCellValue("-");
|
367 |
cellInwardsQuantity.setCellValue("-");
|
| 355 |
cellInwardsRate.setCellValue("-");
|
368 |
cellInwardsRate.setCellValue("-");
|
| 356 |
cellInwardsValue.setCellValue("-");
|
369 |
cellInwardsValue.setCellValue("-");
|
| 357 |
}else{
|
370 |
} else {
|
| 358 |
cellInwardsQuantity.setCellValue(itemCompleteLedgerModel.getInwardsLedger().getQuantity());
|
371 |
cellInwardsQuantity.setCellValue(itemCompleteLedgerModel.getInwardsLedger().getQuantity());
|
| 359 |
cellInwardsRate.setCellValue(itemCompleteLedgerModel.getInwardsLedger().getRate());
|
372 |
cellInwardsRate.setCellValue(itemCompleteLedgerModel.getInwardsLedger().getRate());
|
| 360 |
cellInwardsValue.setCellValue(itemCompleteLedgerModel.getInwardsLedger().getValue());
|
373 |
cellInwardsValue.setCellValue(itemCompleteLedgerModel.getInwardsLedger().getValue());
|
| 361 |
inwardsQuantityTotal = inwardsQuantityTotal + itemCompleteLedgerModel.getInwardsLedger().getQuantity();
|
374 |
inwardsQuantityTotal = inwardsQuantityTotal + itemCompleteLedgerModel.getInwardsLedger().getQuantity();
|
| 362 |
inwardsValueTotal = inwardsValueTotal + itemCompleteLedgerModel.getInwardsLedger().getValue();
|
375 |
inwardsValueTotal = inwardsValueTotal + itemCompleteLedgerModel.getInwardsLedger().getValue();
|
| 363 |
}
|
376 |
}
|
| 364 |
Cell cellOutwardsQuantity = rowValues.createCell(12);
|
377 |
Cell cellOutwardsQuantity = rowValues.createCell(12);
|
| 365 |
Cell cellOutwardsRate = rowValues.createCell(13);
|
378 |
Cell cellOutwardsRate = rowValues.createCell(13);
|
| 366 |
Cell cellOutwardsValue = rowValues.createCell(14);
|
379 |
Cell cellOutwardsValue = rowValues.createCell(14);
|
| 367 |
if(itemCompleteLedgerModel.getOutwardsLedger() == null){
|
380 |
if (itemCompleteLedgerModel.getOutwardsLedger() == null) {
|
| 368 |
cellOutwardsQuantity.setCellValue("-");
|
381 |
cellOutwardsQuantity.setCellValue("-");
|
| 369 |
cellOutwardsRate.setCellValue("-");
|
382 |
cellOutwardsRate.setCellValue("-");
|
| 370 |
cellOutwardsValue.setCellValue("-");
|
383 |
cellOutwardsValue.setCellValue("-");
|
| 371 |
}else{
|
384 |
} else {
|
| 372 |
cellOutwardsQuantity.setCellValue(itemCompleteLedgerModel.getOutwardsLedger().getQuantity());
|
385 |
cellOutwardsQuantity.setCellValue(itemCompleteLedgerModel.getOutwardsLedger().getQuantity());
|
| 373 |
cellOutwardsRate.setCellValue(itemCompleteLedgerModel.getOutwardsLedger().getRate());
|
386 |
cellOutwardsRate.setCellValue(itemCompleteLedgerModel.getOutwardsLedger().getRate());
|
| 374 |
cellOutwardsValue.setCellValue(itemCompleteLedgerModel.getOutwardsLedger().getValue());
|
387 |
cellOutwardsValue.setCellValue(itemCompleteLedgerModel.getOutwardsLedger().getValue());
|
| - |
|
388 |
outwardsQuantityTotal = outwardsQuantityTotal
|
| 375 |
outwardsQuantityTotal = outwardsQuantityTotal + itemCompleteLedgerModel.getOutwardsLedger().getQuantity();
|
389 |
+ itemCompleteLedgerModel.getOutwardsLedger().getQuantity();
|
| 376 |
outwardsValueTotal = outwardsValueTotal + itemCompleteLedgerModel.getOutwardsLedger().getValue();
|
390 |
outwardsValueTotal = outwardsValueTotal + itemCompleteLedgerModel.getOutwardsLedger().getValue();
|
| 377 |
}
|
391 |
}
|
| 378 |
Cell cellClosingQuantity = rowValues.createCell(15);
|
392 |
Cell cellClosingQuantity = rowValues.createCell(15);
|
| 379 |
Cell cellClosingRate = rowValues.createCell(16);
|
393 |
Cell cellClosingRate = rowValues.createCell(16);
|
| 380 |
Cell cellClosingValue = rowValues.createCell(17);
|
394 |
Cell cellClosingValue = rowValues.createCell(17);
|
| 381 |
if(itemCompleteLedgerModel.getClosingLedger() == null){
|
395 |
if (itemCompleteLedgerModel.getClosingLedger() == null) {
|
| 382 |
cellClosingQuantity.setCellValue("-");
|
396 |
cellClosingQuantity.setCellValue("-");
|
| 383 |
cellClosingRate.setCellValue("-");
|
397 |
cellClosingRate.setCellValue("-");
|
| 384 |
cellClosingValue.setCellValue("-");
|
398 |
cellClosingValue.setCellValue("-");
|
| 385 |
}else{
|
399 |
} else {
|
| 386 |
cellClosingQuantity.setCellValue(itemCompleteLedgerModel.getClosingLedger().getQuantity());
|
400 |
cellClosingQuantity.setCellValue(itemCompleteLedgerModel.getClosingLedger().getQuantity());
|
| 387 |
cellClosingRate.setCellValue(itemCompleteLedgerModel.getClosingLedger().getRate());
|
401 |
cellClosingRate.setCellValue(itemCompleteLedgerModel.getClosingLedger().getRate());
|
| 388 |
cellClosingValue.setCellValue(itemCompleteLedgerModel.getClosingLedger().getValue());
|
402 |
cellClosingValue.setCellValue(itemCompleteLedgerModel.getClosingLedger().getValue());
|
| 389 |
closingQuantityTotal = closingQuantityTotal + itemCompleteLedgerModel.getClosingLedger().getQuantity();
|
403 |
closingQuantityTotal = closingQuantityTotal + itemCompleteLedgerModel.getClosingLedger().getQuantity();
|
| 390 |
closingValueTotal = closingValueTotal + itemCompleteLedgerModel.getClosingLedger().getValue();
|
404 |
closingValueTotal = closingValueTotal + itemCompleteLedgerModel.getClosingLedger().getValue();
|
| 391 |
}
|
405 |
}
|
| 392 |
}
|
406 |
}
|
| 393 |
|
407 |
|
| 394 |
Row rowTotal = sheet.createRow(itemCompleteLedgerModels.size() + 2);
|
408 |
Row rowTotal = sheet.createRow(itemCompleteLedgerModels.size() + 2);
|
| 395 |
|
409 |
|
| 396 |
if(openingQuantityTotal > 0){
|
410 |
if (openingQuantityTotal > 0) {
|
| 397 |
Cell cellOpeningQuantityTotal = rowTotal.createCell(6);
|
411 |
Cell cellOpeningQuantityTotal = rowTotal.createCell(6);
|
| 398 |
cellOpeningQuantityTotal.setCellValue(openingQuantityTotal);
|
412 |
cellOpeningQuantityTotal.setCellValue(openingQuantityTotal);
|
| 399 |
Cell cellOpeningValueTotal = rowTotal.createCell(8);
|
413 |
Cell cellOpeningValueTotal = rowTotal.createCell(8);
|
| 400 |
cellOpeningValueTotal.setCellValue(openingValueTotal);
|
414 |
cellOpeningValueTotal.setCellValue(openingValueTotal);
|
| 401 |
}
|
415 |
}
|
| 402 |
|
416 |
|
| 403 |
if(inwardsQuantityTotal > 0){
|
417 |
if (inwardsQuantityTotal > 0) {
|
| 404 |
Cell cellInwardsQuantityTotal = rowTotal.createCell(9);
|
418 |
Cell cellInwardsQuantityTotal = rowTotal.createCell(9);
|
| 405 |
cellInwardsQuantityTotal.setCellValue(inwardsQuantityTotal);
|
419 |
cellInwardsQuantityTotal.setCellValue(inwardsQuantityTotal);
|
| 406 |
Cell cellInwardsValueTotal = rowTotal.createCell(11);
|
420 |
Cell cellInwardsValueTotal = rowTotal.createCell(11);
|
| 407 |
cellInwardsValueTotal.setCellValue(inwardsValueTotal);
|
421 |
cellInwardsValueTotal.setCellValue(inwardsValueTotal);
|
| 408 |
}
|
422 |
}
|
| 409 |
|
423 |
|
| 410 |
if(outwardsQuantityTotal > 0){
|
424 |
if (outwardsQuantityTotal > 0) {
|
| 411 |
Cell cellOutwardsQuantityTotal = rowTotal.createCell(12);
|
425 |
Cell cellOutwardsQuantityTotal = rowTotal.createCell(12);
|
| 412 |
cellOutwardsQuantityTotal.setCellValue(outwardsQuantityTotal);
|
426 |
cellOutwardsQuantityTotal.setCellValue(outwardsQuantityTotal);
|
| 413 |
Cell cellOutwardsValueTotal = rowTotal.createCell(14);
|
427 |
Cell cellOutwardsValueTotal = rowTotal.createCell(14);
|
| 414 |
cellOutwardsValueTotal.setCellValue(outwardsValueTotal);
|
428 |
cellOutwardsValueTotal.setCellValue(outwardsValueTotal);
|
| 415 |
}
|
429 |
}
|
| 416 |
|
430 |
|
| 417 |
if(closingQuantityTotal > 0){
|
431 |
if (closingQuantityTotal > 0) {
|
| 418 |
Cell cellClosingQuantityTotal = rowTotal.createCell(15);
|
432 |
Cell cellClosingQuantityTotal = rowTotal.createCell(15);
|
| 419 |
cellClosingQuantityTotal.setCellValue(closingQuantityTotal);
|
433 |
cellClosingQuantityTotal.setCellValue(closingQuantityTotal);
|
| 420 |
Cell cellClosingValueTotal = rowTotal.createCell(17);
|
434 |
Cell cellClosingValueTotal = rowTotal.createCell(17);
|
| 421 |
cellClosingValueTotal.setCellValue(closingValueTotal);
|
435 |
cellClosingValueTotal.setCellValue(closingValueTotal);
|
| 422 |
}
|
436 |
}
|
| 423 |
|
437 |
|
| 424 |
for(int index = 0; index < 18; index++){
|
438 |
for (int index = 0; index < 18; index++) {
|
| 425 |
sheet.autoSizeColumn(index);
|
439 |
sheet.autoSizeColumn(index);
|
| 426 |
}
|
440 |
}
|
| 427 |
|
441 |
|
| 428 |
try{
|
442 |
try {
|
| 429 |
workbook.write(outputStream);
|
443 |
workbook.write(outputStream);
|
| 430 |
workbook.close();
|
444 |
workbook.close();
|
| 431 |
}catch(IOException ioException){
|
445 |
} catch (IOException ioException) {
|
| 432 |
LOGGER.error("Unable to generate excel file", ioException);
|
446 |
LOGGER.error("Unable to generate excel file", ioException);
|
| 433 |
}
|
447 |
}
|
| 434 |
}
|
448 |
}
|
| 435 |
|
449 |
|
| 436 |
public static void writeSchemeModels(List<SchemeModel> schemeModels, OutputStream outputStream){
|
450 |
public static void writeSchemeModels(List<SchemeModel> schemeModels, OutputStream outputStream) {
|
| 437 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
451 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
| 438 |
|
452 |
|
| 439 |
//CreationHelper createHelper = workbook.getCreationHelper();
|
453 |
// CreationHelper createHelper = workbook.getCreationHelper();
|
| 440 |
|
454 |
|
| 441 |
SXSSFSheet sheet = workbook.createSheet("Schemes");
|
455 |
SXSSFSheet sheet = workbook.createSheet("Schemes");
|
| 442 |
sheet.trackAllColumnsForAutoSizing();
|
456 |
sheet.trackAllColumnsForAutoSizing();
|
| 443 |
|
- |
|
| 444 |
|
457 |
|
| 445 |
Row rowHeader = sheet.createRow(0);
|
458 |
Row rowHeader = sheet.createRow(0);
|
| 446 |
Cell cellSchemeIdHeader = rowHeader.createCell(0);
|
459 |
Cell cellSchemeIdHeader = rowHeader.createCell(0);
|
| 447 |
cellSchemeIdHeader.setCellValue("Scheme Id");
|
460 |
cellSchemeIdHeader.setCellValue("Scheme Id");
|
| 448 |
Cell cellNameHeader = rowHeader.createCell(1);
|
461 |
Cell cellNameHeader = rowHeader.createCell(1);
|
| 449 |
cellNameHeader.setCellValue("Name");
|
462 |
cellNameHeader.setCellValue("Name");
|
| 450 |
Cell cellDescriptionHeader = rowHeader.createCell(2);
|
463 |
Cell cellDescriptionHeader = rowHeader.createCell(2);
|
| 451 |
cellDescriptionHeader.setCellValue("Description");
|
464 |
cellDescriptionHeader.setCellValue("Description");
|
| Line 469... |
Line 482... |
| 469 |
cellCreatedByHeader.setCellValue("Created By");
|
482 |
cellCreatedByHeader.setCellValue("Created By");
|
| 470 |
Cell cellItemIdsHeader = rowHeader.createCell(12);
|
483 |
Cell cellItemIdsHeader = rowHeader.createCell(12);
|
| 471 |
cellItemIdsHeader.setCellValue("Item Ids");
|
484 |
cellItemIdsHeader.setCellValue("Item Ids");
|
| 472 |
Cell cellRetailerIdsHeader = rowHeader.createCell(13);
|
485 |
Cell cellRetailerIdsHeader = rowHeader.createCell(13);
|
| 473 |
cellRetailerIdsHeader.setCellValue("Retailer Ids");
|
486 |
cellRetailerIdsHeader.setCellValue("Retailer Ids");
|
| 474 |
//Row rowQuantityRateValue = sheet.createRow(1);
|
487 |
// Row rowQuantityRateValue = sheet.createRow(1);
|
| - |
|
488 |
|
| 475 |
|
489 |
/*
|
| 476 |
/*for(int index = 6; index < 18; index = index + 3){
|
490 |
* for(int index = 6; index < 18; index = index + 3){ Cell cellQuantityHeader =
|
| 477 |
Cell cellQuantityHeader = rowQuantityRateValue.createCell(index);
|
491 |
* rowQuantityRateValue.createCell(index);
|
| 478 |
cellQuantityHeader.setCellValue("Quantity");
|
492 |
* cellQuantityHeader.setCellValue("Quantity"); Cell cellRateHeader =
|
| 479 |
Cell cellRateHeader = rowQuantityRateValue.createCell(index + 1);
|
493 |
* rowQuantityRateValue.createCell(index + 1);
|
| 480 |
cellRateHeader.setCellValue("Rate");
|
494 |
* cellRateHeader.setCellValue("Rate"); Cell cellValueHeader =
|
| 481 |
Cell cellValueHeader = rowQuantityRateValue.createCell(index + 2);
|
495 |
* rowQuantityRateValue.createCell(index + 2);
|
| 482 |
cellValueHeader.setCellValue("Value");
|
496 |
* cellValueHeader.setCellValue("Value"); sheet.addMergedRegion(new
|
| 483 |
sheet.addMergedRegion(new CellRangeAddress(0, 0, index, index + 2));
|
497 |
* CellRangeAddress(0, 0, index, index + 2)); }
|
| 484 |
}*/
|
498 |
*/
|
| 485 |
Font font = workbook.createFont();
|
499 |
Font font = workbook.createFont();
|
| 486 |
CellStyle cellStyle = workbook.createCellStyle();
|
500 |
CellStyle cellStyle = workbook.createCellStyle();
|
| 487 |
font.setBold(true);
|
501 |
font.setBold(true);
|
| 488 |
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
502 |
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
| 489 |
//font.setFontHeight((short)16);
|
503 |
// font.setFontHeight((short)16);
|
| 490 |
cellStyle.setFont(font);
|
504 |
cellStyle.setFont(font);
|
| 491 |
for(int i = 0; i < 14; i++){
|
505 |
for (int i = 0; i < 14; i++) {
|
| 492 |
if(rowHeader.getCell(i) != null){
|
506 |
if (rowHeader.getCell(i) != null) {
|
| 493 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
507 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
| 494 |
}
|
508 |
}
|
| 495 |
}
|
509 |
}
|
| 496 |
|
510 |
|
| 497 |
for(int index = 0; index < schemeModels.size(); index++){
|
511 |
for (int index = 0; index < schemeModels.size(); index++) {
|
| 498 |
SchemeModel schemeModel = schemeModels.get(index);
|
512 |
SchemeModel schemeModel = schemeModels.get(index);
|
| 499 |
//ItemCompleteLedgerModel itemCompleteLedgerModel = itemCompleteLedgerModels.get(index);
|
513 |
// ItemCompleteLedgerModel itemCompleteLedgerModel =
|
| - |
|
514 |
// itemCompleteLedgerModels.get(index);
|
| 500 |
Row rowValues = sheet.createRow(index + 1);
|
515 |
Row rowValues = sheet.createRow(index + 1);
|
| 501 |
Cell cellSchemeId = rowValues.createCell(0);
|
516 |
Cell cellSchemeId = rowValues.createCell(0);
|
| 502 |
cellSchemeId.setCellValue(schemeModel.getSchemeId());
|
517 |
cellSchemeId.setCellValue(schemeModel.getSchemeId());
|
| 503 |
Cell cellName = rowValues.createCell(1);
|
518 |
Cell cellName = rowValues.createCell(1);
|
| 504 |
cellName.setCellValue(schemeModel.getName());
|
519 |
cellName.setCellValue(schemeModel.getName());
|
| 505 |
Cell cellDescription = rowValues.createCell(2);
|
520 |
Cell cellDescription = rowValues.createCell(2);
|
| 506 |
cellDescription.setCellValue(schemeModel.getDescription());
|
521 |
cellDescription.setCellValue(schemeModel.getDescription());
|
| Line 515... |
Line 530... |
| 515 |
Cell cellEndDateTime = rowValues.createCell(7);
|
530 |
Cell cellEndDateTime = rowValues.createCell(7);
|
| 516 |
cellEndDateTime.setCellValue(schemeModel.getEndDateTime());
|
531 |
cellEndDateTime.setCellValue(schemeModel.getEndDateTime());
|
| 517 |
Cell cellCreatedAt = rowValues.createCell(8);
|
532 |
Cell cellCreatedAt = rowValues.createCell(8);
|
| 518 |
cellCreatedAt.setCellValue(schemeModel.getCreateTimestamp());
|
533 |
cellCreatedAt.setCellValue(schemeModel.getCreateTimestamp());
|
| 519 |
Cell cellActive = rowValues.createCell(9);
|
534 |
Cell cellActive = rowValues.createCell(9);
|
| 520 |
if(schemeModel.getActiveTimestamp() !=null){
|
535 |
if (schemeModel.getActiveTimestamp() != null) {
|
| 521 |
cellActive.setCellValue(schemeModel.getActiveTimestamp());
|
536 |
cellActive.setCellValue(schemeModel.getActiveTimestamp());
|
| 522 |
}else{
|
537 |
} else {
|
| 523 |
cellActive.setCellValue("False");
|
538 |
cellActive.setCellValue("False");
|
| 524 |
}
|
539 |
}
|
| 525 |
Cell cellExpire = rowValues.createCell(10);
|
540 |
Cell cellExpire = rowValues.createCell(10);
|
| 526 |
if(schemeModel.getExpireTimestamp() != null){
|
541 |
if (schemeModel.getExpireTimestamp() != null) {
|
| 527 |
cellExpire.setCellValue(schemeModel.getExpireTimestamp());
|
542 |
cellExpire.setCellValue(schemeModel.getExpireTimestamp());
|
| 528 |
}else{
|
543 |
} else {
|
| 529 |
cellExpire.setCellValue("False");
|
544 |
cellExpire.setCellValue("False");
|
| 530 |
}
|
545 |
}
|
| 531 |
Cell cellCreatedBy = rowValues.createCell(11);
|
546 |
Cell cellCreatedBy = rowValues.createCell(11);
|
| 532 |
cellCreatedBy.setCellValue(schemeModel.getCreatedBy());
|
547 |
cellCreatedBy.setCellValue(schemeModel.getCreatedBy());
|
| 533 |
Cell cellItemIds = rowValues.createCell(12);
|
548 |
Cell cellItemIds = rowValues.createCell(12);
|
| 534 |
cellItemIds.setCellValue(schemeModel.getItemStringMap().toString());
|
549 |
cellItemIds.setCellValue(schemeModel.getItemStringMap().toString());
|
| 535 |
Cell cellRetailerIds = rowValues.createCell(13);
|
550 |
Cell cellRetailerIds = rowValues.createCell(13);
|
| 536 |
cellRetailerIds.setCellValue(schemeModel.getRetailerIdsString());
|
551 |
cellRetailerIds.setCellValue(schemeModel.getRetailerIdsString());
|
| 537 |
int maxHeight = Math.max(schemeModel.getItemStringMap().size(), schemeModel.getRetailerIds().size());
|
552 |
int maxHeight = Math.max(schemeModel.getItemStringMap().size(), schemeModel.getRetailerIds().size());
|
| 538 |
if(maxHeight > 1){
|
553 |
if (maxHeight > 1) {
|
| 539 |
rowValues.setHeight((short)(maxHeight * 240));
|
554 |
rowValues.setHeight((short) (maxHeight * 240));
|
| 540 |
}
|
555 |
}
|
| 541 |
}
|
556 |
}
|
| 542 |
|
557 |
|
| 543 |
for(int index = 0; index < 14; index++){
|
558 |
for (int index = 0; index < 14; index++) {
|
| 544 |
sheet.autoSizeColumn(index);
|
559 |
sheet.autoSizeColumn(index);
|
| 545 |
}
|
560 |
}
|
| 546 |
|
561 |
|
| 547 |
try{
|
562 |
try {
|
| 548 |
workbook.write(outputStream);
|
563 |
workbook.write(outputStream);
|
| 549 |
workbook.close();
|
564 |
workbook.close();
|
| 550 |
}catch(IOException ioException){
|
565 |
} catch (IOException ioException) {
|
| 551 |
LOGGER.error("Unable to generate excel file", ioException);
|
566 |
LOGGER.error("Unable to generate excel file", ioException);
|
| 552 |
}
|
567 |
}
|
| 553 |
}
|
568 |
}
|
| - |
|
569 |
|
| 554 |
public static void writePriceDrop(Map<String, String> priceDropIMEIfofoId,int itemId,OutputStream outputStream){
|
570 |
public static void writePriceDrop(Map<String, String> priceDropIMEIfofoId, int itemId, OutputStream outputStream) {
|
| 555 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
571 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
| 556 |
|
572 |
|
| 557 |
//CreationHelper createHelper = workbook.getCreationHelper();
|
573 |
// CreationHelper createHelper = workbook.getCreationHelper();
|
| 558 |
|
574 |
|
| 559 |
SXSSFSheet sheet = workbook.createSheet("Schemes");
|
575 |
SXSSFSheet sheet = workbook.createSheet("Schemes");
|
| 560 |
sheet.trackAllColumnsForAutoSizing();
|
576 |
sheet.trackAllColumnsForAutoSizing();
|
| 561 |
|
- |
|
| 562 |
|
577 |
|
| 563 |
Row rowHeader = sheet.createRow(0);
|
578 |
Row rowHeader = sheet.createRow(0);
|
| 564 |
Cell cellItemHeader = rowHeader.createCell(0);
|
579 |
Cell cellItemHeader = rowHeader.createCell(0);
|
| 565 |
cellItemHeader.setCellValue("ITEMID");
|
580 |
cellItemHeader.setCellValue("ITEMID");
|
| 566 |
Cell cellIMEIHeader = rowHeader.createCell(1);
|
581 |
Cell cellIMEIHeader = rowHeader.createCell(1);
|
| 567 |
cellIMEIHeader.setCellValue("IMEI");
|
582 |
cellIMEIHeader.setCellValue("IMEI");
|
| 568 |
Cell cellFOFOIDHeader = rowHeader.createCell(2);
|
583 |
Cell cellFOFOIDHeader = rowHeader.createCell(2);
|
| 569 |
cellFOFOIDHeader.setCellValue("RETAILERNAME");
|
584 |
cellFOFOIDHeader.setCellValue("RETAILERNAME");
|
| 570 |
//Row rowQuantityRateValue = sheet.createRow(1);
|
585 |
// Row rowQuantityRateValue = sheet.createRow(1);
|
| - |
|
586 |
|
| 571 |
|
587 |
/*
|
| 572 |
/*for(int index = 6; index < 18; index = index + 3){
|
588 |
* for(int index = 6; index < 18; index = index + 3){ Cell cellQuantityHeader =
|
| 573 |
Cell cellQuantityHeader = rowQuantityRateValue.createCell(index);
|
589 |
* rowQuantityRateValue.createCell(index);
|
| 574 |
cellQuantityHeader.setCellValue("Quantity");
|
590 |
* cellQuantityHeader.setCellValue("Quantity"); Cell cellRateHeader =
|
| 575 |
Cell cellRateHeader = rowQuantityRateValue.createCell(index + 1);
|
591 |
* rowQuantityRateValue.createCell(index + 1);
|
| 576 |
cellRateHeader.setCellValue("Rate");
|
592 |
* cellRateHeader.setCellValue("Rate"); Cell cellValueHeader =
|
| 577 |
Cell cellValueHeader = rowQuantityRateValue.createCell(index + 2);
|
593 |
* rowQuantityRateValue.createCell(index + 2);
|
| 578 |
cellValueHeader.setCellValue("Value");
|
594 |
* cellValueHeader.setCellValue("Value"); sheet.addMergedRegion(new
|
| 579 |
sheet.addMergedRegion(new CellRangeAddress(0, 0, index, index + 2));
|
595 |
* CellRangeAddress(0, 0, index, index + 2)); }
|
| 580 |
}*/
|
596 |
*/
|
| 581 |
Font font = workbook.createFont();
|
597 |
Font font = workbook.createFont();
|
| 582 |
CellStyle cellStyle = workbook.createCellStyle();
|
598 |
CellStyle cellStyle = workbook.createCellStyle();
|
| 583 |
font.setBold(true);
|
599 |
font.setBold(true);
|
| 584 |
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
600 |
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
| 585 |
//font.setFontHeight((short)16);
|
601 |
// font.setFontHeight((short)16);
|
| 586 |
cellStyle.setFont(font);
|
602 |
cellStyle.setFont(font);
|
| 587 |
for(int i = 0; i < 14; i++){
|
603 |
for (int i = 0; i < 14; i++) {
|
| 588 |
if(rowHeader.getCell(i) != null){
|
604 |
if (rowHeader.getCell(i) != null) {
|
| 589 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
605 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
| 590 |
}
|
606 |
}
|
| 591 |
}
|
607 |
}
|
| 592 |
LinkedHashMap<String,String> priceAmount=new LinkedHashMap<>(priceDropIMEIfofoId);
|
608 |
LinkedHashMap<String, String> priceAmount = new LinkedHashMap<>(priceDropIMEIfofoId);
|
| 593 |
Set<String> keyset=priceAmount.keySet();
|
609 |
Set<String> keyset = priceAmount.keySet();
|
| 594 |
int rownum = 1;
|
610 |
int rownum = 1;
|
| 595 |
for (String key : keyset) {
|
611 |
for (String key : keyset) {
|
| 596 |
Row row = sheet.createRow(rownum++);
|
612 |
Row row = sheet.createRow(rownum++);
|
| 597 |
String objArr = priceAmount.get(key);
|
613 |
String objArr = priceAmount.get(key);
|
| 598 |
int cellnum = 0;
|
614 |
int cellnum = 0;
|
| 599 |
Cell cell = row.createCell(cellnum++);
|
615 |
Cell cell = row.createCell(cellnum++);
|
| 600 |
cell.setCellValue(itemId);
|
616 |
cell.setCellValue(itemId);
|
| 601 |
Cell cell1 = row.createCell(cellnum++);
|
617 |
Cell cell1 = row.createCell(cellnum++);
|
| 602 |
cell1.setCellValue(key);
|
618 |
cell1.setCellValue(key);
|
| 603 |
Cell cell2 = row.createCell(cellnum++);
|
619 |
Cell cell2 = row.createCell(cellnum++);
|
| 604 |
cell2.setCellValue(priceAmount.get(key));
|
620 |
cell2.setCellValue(priceAmount.get(key));
|
| 605 |
}
|
- |
|
| 606 |
|
621 |
}
|
| - |
|
622 |
|
| 607 |
for(int index = 0; index < 14; index++){
|
623 |
for (int index = 0; index < 14; index++) {
|
| 608 |
sheet.autoSizeColumn(index);
|
624 |
sheet.autoSizeColumn(index);
|
| 609 |
}
|
625 |
}
|
| 610 |
|
626 |
|
| 611 |
try{
|
627 |
try {
|
| 612 |
workbook.write(outputStream);
|
628 |
workbook.write(outputStream);
|
| 613 |
workbook.close();
|
629 |
workbook.close();
|
| 614 |
}catch(IOException ioException){
|
630 |
} catch (IOException ioException) {
|
| 615 |
LOGGER.error("Unable to generate excel file", ioException);
|
631 |
LOGGER.error("Unable to generate excel file", ioException);
|
| 616 |
}
|
632 |
}
|
| 617 |
}
|
633 |
}
|
| - |
|
634 |
|
| 618 |
public static void writePriceDropForAllIMEI(Map<String,String>priceDropAmount,OutputStream outputStream){
|
635 |
public static void writePriceDropForAllIMEI(Map<String, String> priceDropAmount, OutputStream outputStream) {
|
| 619 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
636 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
| 620 |
|
637 |
|
| 621 |
//CreationHelper createHelper = workbook.getCreationHelper();
|
638 |
// CreationHelper createHelper = workbook.getCreationHelper();
|
| 622 |
|
639 |
|
| 623 |
SXSSFSheet sheet = workbook.createSheet("Schemes");
|
640 |
SXSSFSheet sheet = workbook.createSheet("Schemes");
|
| 624 |
sheet.trackAllColumnsForAutoSizing();
|
641 |
sheet.trackAllColumnsForAutoSizing();
|
| 625 |
|
- |
|
| 626 |
|
642 |
|
| 627 |
Row rowHeader = sheet.createRow(0);
|
643 |
Row rowHeader = sheet.createRow(0);
|
| 628 |
Cell cellItemHeader = rowHeader.createCell(0);
|
644 |
Cell cellItemHeader = rowHeader.createCell(0);
|
| 629 |
cellItemHeader.setCellValue("Itemdescription");
|
645 |
cellItemHeader.setCellValue("Itemdescription");
|
| 630 |
Cell cellIMEIHeader = rowHeader.createCell(1);
|
646 |
Cell cellIMEIHeader = rowHeader.createCell(1);
|
| 631 |
cellIMEIHeader.setCellValue("IMEI");
|
647 |
cellIMEIHeader.setCellValue("IMEI");
|
| 632 |
//Row rowQuantityRateValue = sheet.createRow(1);
|
648 |
// Row rowQuantityRateValue = sheet.createRow(1);
|
| - |
|
649 |
|
| 633 |
|
650 |
/*
|
| 634 |
/*for(int index = 6; index < 18; index = index + 3){
|
651 |
* for(int index = 6; index < 18; index = index + 3){ Cell cellQuantityHeader =
|
| 635 |
Cell cellQuantityHeader = rowQuantityRateValue.createCell(index);
|
652 |
* rowQuantityRateValue.createCell(index);
|
| 636 |
cellQuantityHeader.setCellValue("Quantity");
|
653 |
* cellQuantityHeader.setCellValue("Quantity"); Cell cellRateHeader =
|
| 637 |
Cell cellRateHeader = rowQuantityRateValue.createCell(index + 1);
|
654 |
* rowQuantityRateValue.createCell(index + 1);
|
| 638 |
cellRateHeader.setCellValue("Rate");
|
655 |
* cellRateHeader.setCellValue("Rate"); Cell cellValueHeader =
|
| 639 |
Cell cellValueHeader = rowQuantityRateValue.createCell(index + 2);
|
656 |
* rowQuantityRateValue.createCell(index + 2);
|
| 640 |
cellValueHeader.setCellValue("Value");
|
657 |
* cellValueHeader.setCellValue("Value"); sheet.addMergedRegion(new
|
| 641 |
sheet.addMergedRegion(new CellRangeAddress(0, 0, index, index + 2));
|
658 |
* CellRangeAddress(0, 0, index, index + 2)); }
|
| 642 |
}*/
|
659 |
*/
|
| 643 |
Font font = workbook.createFont();
|
660 |
Font font = workbook.createFont();
|
| 644 |
CellStyle cellStyle = workbook.createCellStyle();
|
661 |
CellStyle cellStyle = workbook.createCellStyle();
|
| 645 |
font.setBold(true);
|
662 |
font.setBold(true);
|
| 646 |
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
663 |
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
| 647 |
//font.setFontHeight((short)16);
|
664 |
// font.setFontHeight((short)16);
|
| 648 |
cellStyle.setFont(font);
|
665 |
cellStyle.setFont(font);
|
| 649 |
for(int i = 0; i < 14; i++){
|
666 |
for (int i = 0; i < 14; i++) {
|
| 650 |
if(rowHeader.getCell(i) != null){
|
667 |
if (rowHeader.getCell(i) != null) {
|
| 651 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
668 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
| 652 |
}
|
669 |
}
|
| 653 |
}
|
670 |
}
|
| 654 |
Set<String> keyset=priceDropAmount.keySet();
|
671 |
Set<String> keyset = priceDropAmount.keySet();
|
| 655 |
int rownum = 1;
|
672 |
int rownum = 1;
|
| 656 |
for (String key : keyset) {
|
673 |
for (String key : keyset) {
|
| 657 |
Row row = sheet.createRow(rownum++);
|
674 |
Row row = sheet.createRow(rownum++);
|
| 658 |
String objArr = priceDropAmount.get(key);
|
675 |
String objArr = priceDropAmount.get(key);
|
| 659 |
int cellnum = 0;
|
676 |
int cellnum = 0;
|
| 660 |
Cell cell = row.createCell(cellnum++);
|
677 |
Cell cell = row.createCell(cellnum++);
|
| 661 |
cell.setCellValue(priceDropAmount.get(key));
|
678 |
cell.setCellValue(priceDropAmount.get(key));
|
| 662 |
Cell cell1 = row.createCell(cellnum++);
|
679 |
Cell cell1 = row.createCell(cellnum++);
|
| 663 |
cell1.setCellValue(key);
|
680 |
cell1.setCellValue(key);
|
| 664 |
}
|
- |
|
| 665 |
|
681 |
}
|
| - |
|
682 |
|
| 666 |
for(int index = 0; index < 14; index++){
|
683 |
for (int index = 0; index < 14; index++) {
|
| 667 |
sheet.autoSizeColumn(index);
|
684 |
sheet.autoSizeColumn(index);
|
| 668 |
}
|
685 |
}
|
| 669 |
|
686 |
|
| 670 |
try{
|
687 |
try {
|
| 671 |
workbook.write(outputStream);
|
688 |
workbook.write(outputStream);
|
| 672 |
workbook.close();
|
689 |
workbook.close();
|
| 673 |
}catch(IOException ioException){
|
690 |
} catch (IOException ioException) {
|
| 674 |
LOGGER.error("Unable to generate excel file", ioException);
|
691 |
LOGGER.error("Unable to generate excel file", ioException);
|
| 675 |
}
|
692 |
}
|
| 676 |
}
|
693 |
}
|
| - |
|
694 |
|
| 677 |
public static List<PartnerTargetModel> parseFromExcel(InputStream inputStream) throws Exception {
|
695 |
public static List<PartnerTargetModel> parseFromExcel(InputStream inputStream) throws Exception {
|
| 678 |
|
696 |
|
| 679 |
List<PartnerTargetModel> partnerTargetModels = new ArrayList<>();
|
697 |
List<PartnerTargetModel> partnerTargetModels = new ArrayList<>();
|
| 680 |
XSSFWorkbook myWorkBook = null;
|
698 |
XSSFWorkbook myWorkBook = null;
|
| 681 |
try{
|
699 |
try {
|
| - |
|
700 |
// FileInputStream fileInputStream = new
|
| 682 |
//FileInputStream fileInputStream = new FileInputStream("/home/ashikali/tag_listing1.xlsx");
|
701 |
// FileInputStream("/home/ashikali/tag_listing1.xlsx");
|
| 683 |
myWorkBook = new XSSFWorkbook (inputStream);
|
702 |
myWorkBook = new XSSFWorkbook(inputStream);
|
| 684 |
|
703 |
|
| 685 |
myWorkBook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
|
704 |
myWorkBook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
|
| 686 |
// Return first sheet from the XLSX workbook
|
705 |
// Return first sheet from the XLSX workbook
|
| 687 |
XSSFSheet mySheet = myWorkBook.getSheetAt(0);
|
706 |
XSSFSheet mySheet = myWorkBook.getSheetAt(0);
|
| 688 |
LOGGER.info("rowCellNum {}", mySheet.getLastRowNum());
|
707 |
LOGGER.info("rowCellNum {}", mySheet.getLastRowNum());
|
| 689 |
|
708 |
|
| 690 |
for(int rowNumber = 1; rowNumber <= mySheet.getLastRowNum(); rowNumber++){
|
709 |
for (int rowNumber = 1; rowNumber <= mySheet.getLastRowNum(); rowNumber++) {
|
| 691 |
XSSFRow row = mySheet.getRow(rowNumber);
|
710 |
XSSFRow row = mySheet.getRow(rowNumber);
|
| 692 |
LOGGER.info("row {}", row);
|
711 |
LOGGER.info("row {}", row);
|
| 693 |
PartnerTargetModel partnerTargetModel = new PartnerTargetModel();
|
712 |
PartnerTargetModel partnerTargetModel = new PartnerTargetModel();
|
| 694 |
if(row.getCell(0) != null && row.getCell(0).getCellTypeEnum() == CellType.NUMERIC){
|
- |
|
| 695 |
partnerTargetModel.setFofoId((int) row.getCell(0).getNumericCellValue());
|
- |
|
| 696 |
}else{
|
- |
|
| 697 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(FOFO_ID, row.getCell(0).toString(), "TGLSTNG_VE_1010");
|
- |
|
| 698 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
- |
|
| 699 |
throw profitMandiBusinessException;
|
- |
|
| 700 |
}
|
- |
|
| 701 |
|
- |
|
| 702 |
if(row.getCell(1) != null && row.getCell(1).getCellTypeEnum() == CellType.STRING){
|
- |
|
| 703 |
partnerTargetModel.setStoreName(row.getCell(1).getStringCellValue());
|
- |
|
| 704 |
}else{
|
- |
|
| 705 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(STORE_NAME, row.getCell(2).toString(), "TGLSTNG_VE_1010");
|
- |
|
| 706 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
- |
|
| 707 |
throw profitMandiBusinessException;
|
- |
|
| 708 |
}
|
- |
|
| 709 |
|
713 |
|
| 710 |
if(row.getCell(2) != null && row.getCell(2).getCellTypeEnum() == CellType.STRING){
|
714 |
if (row.getCell(0) != null && row.getCell(0).getCellTypeEnum() == CellType.NUMERIC) {
|
| 711 |
partnerTargetModel.setEmail(row.getCell(2).getStringCellValue());
|
715 |
partnerTargetModel.setFofoId((int) row.getCell(0).getNumericCellValue());
|
| 712 |
}else{
|
716 |
} else {
|
| 713 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(EMAIL, row.getCell(7), "TGLSTNG_VE_1010");
|
717 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
|
| - |
|
718 |
FOFO_ID, row.getCell(0).toString(), "TGLSTNG_VE_1010");
|
| 714 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
719 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
| 715 |
throw profitMandiBusinessException;
|
720 |
throw profitMandiBusinessException;
|
| 716 |
}
|
721 |
}
|
| 717 |
if(row.getCell(3) != null && row.getCell(3).getCellTypeEnum() == CellType.NUMERIC){
|
722 |
if (row.getCell(3) != null && row.getCell(3).getCellTypeEnum() == CellType.NUMERIC) {
|
| 718 |
partnerTargetModel.setTargetValue((int) row.getCell(3).getNumericCellValue());
|
723 |
partnerTargetModel.setTargetValue((int) row.getCell(3).getNumericCellValue());
|
| 719 |
}else{
|
724 |
} else {
|
| 720 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(TARGET_VALUE, row.getCell(8), "TGLSTNG_VE_1010");
|
725 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
|
| - |
|
726 |
TARGET_VALUE, row.getCell(8), "TGLSTNG_VE_1010");
|
| 721 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
727 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
| 722 |
throw profitMandiBusinessException;
|
728 |
throw profitMandiBusinessException;
|
| 723 |
}
|
729 |
}
|
| 724 |
|
730 |
|
| 725 |
partnerTargetModels.add(partnerTargetModel);
|
731 |
partnerTargetModels.add(partnerTargetModel);
|
| 726 |
}
|
732 |
}
|
| 727 |
myWorkBook.close();
|
733 |
myWorkBook.close();
|
| 728 |
} catch(IOException ioException){
|
734 |
} catch (IOException ioException) {
|
| 729 |
ioException.printStackTrace();
|
735 |
ioException.printStackTrace();
|
| 730 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.EXCEL_FILE, ioException.getMessage(), "EXL_VE_1000");
|
736 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.EXCEL_FILE, ioException.getMessage(),
|
| - |
|
737 |
"EXL_VE_1000");
|
| 731 |
} finally {
|
738 |
} finally {
|
| 732 |
if(myWorkBook != null){
|
739 |
if (myWorkBook != null) {
|
| 733 |
try {
|
740 |
try {
|
| 734 |
myWorkBook.close();
|
741 |
myWorkBook.close();
|
| 735 |
} catch (IOException e) {
|
742 |
} catch (IOException e) {
|
| 736 |
// TODO Auto-generated catch block
|
743 |
// TODO Auto-generated catch block
|
| 737 |
e.printStackTrace();
|
744 |
e.printStackTrace();
|
| 738 |
}
|
745 |
}
|
| 739 |
}
|
746 |
}
|
| 740 |
}
|
747 |
}
|
| 741 |
return partnerTargetModels;
|
748 |
return partnerTargetModels;
|
| 742 |
}
|
749 |
}
|
| - |
|
750 |
|
| - |
|
751 |
public static void writeDailySaleReportVsTarget(Map<Integer, Float> targetValues, Map<Integer, Double> saleValues,
|
| - |
|
752 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer, Map<Integer, String> fofoIdsAndSlabNames,
|
| - |
|
753 |
Map<Integer, Double> monthlyTargetAchievementPercentage, Map<Integer, Float> dailyAverageSale,
|
| - |
|
754 |
Map<Integer, Double> remainingMonthlyTargets, Map<Integer, Double> todayAchievements,
|
| - |
|
755 |
Map<Integer, Float> todayAchievementsPercentage, OutputStream outputStream) {
|
| - |
|
756 |
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
| - |
|
757 |
|
| - |
|
758 |
// CreationHelper createHelper = workbook.getCreationHelper();
|
| - |
|
759 |
|
| - |
|
760 |
SXSSFSheet sheet = workbook.createSheet("DailySaleReports");
|
| - |
|
761 |
sheet.trackAllColumnsForAutoSizing();
|
| - |
|
762 |
|
| - |
|
763 |
Row rowHeader = sheet.createRow(0);
|
| - |
|
764 |
Cell cellFOfoId = rowHeader.createCell(0);
|
| - |
|
765 |
cellFOfoId.setCellValue("FoFoId");
|
| - |
|
766 |
Cell cellStoreName = rowHeader.createCell(1);
|
| - |
|
767 |
cellStoreName.setCellValue("Store Name");
|
| - |
|
768 |
Cell cellTargetValue = rowHeader.createCell(2);
|
| - |
|
769 |
cellTargetValue.setCellValue("MTD Target Value");
|
| - |
|
770 |
Cell cellDailyTarget = rowHeader.createCell(3);
|
| - |
|
771 |
cellDailyTarget.setCellValue("Daily Target");
|
| - |
|
772 |
Cell cellTodayAchievement = rowHeader.createCell(4);
|
| - |
|
773 |
cellTodayAchievement.setCellValue("Today Achievement");
|
| - |
|
774 |
Cell cellTodayAchievementPercentage = rowHeader.createCell(5);
|
| - |
|
775 |
cellTodayAchievementPercentage.setCellValue("Today Achievement %");
|
| - |
|
776 |
Cell cellMonthlySaleValue = rowHeader.createCell(6);
|
| - |
|
777 |
cellMonthlySaleValue.setCellValue("MTD Achievement");
|
| - |
|
778 |
Cell cellMonthlySaleValuePercentage = rowHeader.createCell(7);
|
| - |
|
779 |
cellMonthlySaleValuePercentage.setCellValue("MTD Achievement%");
|
| - |
|
780 |
Cell cellRemainingTarget = rowHeader.createCell(8);
|
| - |
|
781 |
cellRemainingTarget.setCellValue("Remaining");
|
| - |
|
782 |
Cell cellEligibility = rowHeader.createCell(9);
|
| - |
|
783 |
cellEligibility.setCellValue("Eligibility");
|
| - |
|
784 |
Font font = workbook.createFont();
|
| - |
|
785 |
CellStyle cellStyle = workbook.createCellStyle();
|
| - |
|
786 |
font.setBold(true);
|
| - |
|
787 |
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
| - |
|
788 |
// font.setFontHeight((short)16);
|
| - |
|
789 |
cellStyle.setFont(font);
|
| - |
|
790 |
for (int i = 0; i < 14; i++) {
|
| - |
|
791 |
if (rowHeader.getCell(i) != null) {
|
| - |
|
792 |
rowHeader.getCell(i).setCellStyle(cellStyle);
|
| - |
|
793 |
}
|
| - |
|
794 |
}
|
| - |
|
795 |
int rownum = 1;
|
| - |
|
796 |
for (Integer fofoId : saleValues.keySet()) {
|
| - |
|
797 |
Row row = sheet.createRow(rownum++);
|
| - |
|
798 |
int cellnum = 0;
|
| - |
|
799 |
Cell cellFofoId = row.createCell(cellnum++);
|
| - |
|
800 |
cellFofoId.setCellValue(fofoId);
|
| - |
|
801 |
Cell cellPartner = row.createCell(cellnum++);
|
| - |
|
802 |
if (fofoIdsAndCustomRetailer.get(fofoId)!= null) {
|
| - |
|
803 |
cellPartner.setCellValue(fofoIdsAndCustomRetailer.get(fofoId).getBusinessName());
|
| - |
|
804 |
} else {
|
| - |
|
805 |
cellPartner.setCellValue("Name Not Associated");
|
| - |
|
806 |
}
|
| - |
|
807 |
|
| - |
|
808 |
Cell cellMTDTargetValue = row.createCell(cellnum++);
|
| - |
|
809 |
if (targetValues.get(fofoId) != null) {
|
| - |
|
810 |
cellMTDTargetValue.setCellValue(targetValues.get(fofoId));
|
| - |
|
811 |
} else {
|
| - |
|
812 |
cellMTDTargetValue.setCellValue("Target not defined");
|
| - |
|
813 |
}
|
| - |
|
814 |
|
| - |
|
815 |
Cell cellDailyTargetValue = row.createCell(cellnum++);
|
| - |
|
816 |
if (dailyAverageSale.get(fofoId) != null) {
|
| - |
|
817 |
String formatting=FormattingUtils.formatDecimalTwoDigits(dailyAverageSale.get(fofoId));
|
| - |
|
818 |
cellDailyTargetValue.setCellValue(formatting);
|
| - |
|
819 |
} else {
|
| - |
|
820 |
cellDailyTargetValue.setCellValue(0);
|
| - |
|
821 |
}
|
| - |
|
822 |
Cell cellTodayAchieveMentSaleValue = row.createCell(cellnum++);
|
| - |
|
823 |
if (todayAchievements.get(fofoId) != null) {
|
| - |
|
824 |
cellTodayAchieveMentSaleValue.setCellValue(todayAchievements.get(fofoId));
|
| - |
|
825 |
} else {
|
| - |
|
826 |
cellTodayAchieveMentSaleValue.setCellValue(0);
|
| - |
|
827 |
}
|
| - |
|
828 |
Cell cellTodayAchieveMentSaleValuePercentage = row.createCell(cellnum++);
|
| - |
|
829 |
if (todayAchievementsPercentage.get(fofoId) != null) {
|
| - |
|
830 |
cellTodayAchieveMentSaleValuePercentage.setCellValue(todayAchievementsPercentage.get(fofoId) + "%");
|
| - |
|
831 |
} else {
|
| - |
|
832 |
cellTodayAchieveMentSaleValuePercentage.setCellValue(0 + "%");
|
| - |
|
833 |
|
| - |
|
834 |
}
|
| - |
|
835 |
Cell cellMTDAchievement = row.createCell(cellnum++);
|
| - |
|
836 |
if (saleValues.get(fofoId) != null) {
|
| - |
|
837 |
cellMTDAchievement.setCellValue(saleValues.get(fofoId));
|
| - |
|
838 |
} else {
|
| - |
|
839 |
cellMTDAchievement.setCellValue("No sale");
|
| - |
|
840 |
}
|
| - |
|
841 |
Cell cellMTDAchievementPercentage = row.createCell(cellnum++);
|
| - |
|
842 |
if (monthlyTargetAchievementPercentage.get(fofoId) != null) {
|
| - |
|
843 |
cellMTDAchievementPercentage.setCellValue(monthlyTargetAchievementPercentage.get(fofoId) + "%");
|
| - |
|
844 |
} else {
|
| - |
|
845 |
cellMTDAchievementPercentage.setCellValue(0 + "%");
|
| - |
|
846 |
}
|
| - |
|
847 |
|
| - |
|
848 |
Cell cellRemaining = row.createCell(cellnum++);
|
| - |
|
849 |
if (remainingMonthlyTargets.get(fofoId) != null) {
|
| - |
|
850 |
cellRemaining.setCellValue(remainingMonthlyTargets.get(fofoId));
|
| - |
|
851 |
} else {
|
| - |
|
852 |
cellRemaining.setCellValue("no target define");
|
| - |
|
853 |
}
|
| - |
|
854 |
|
| - |
|
855 |
Cell cellEligible = row.createCell(cellnum++);
|
| - |
|
856 |
if (fofoIdsAndSlabNames.get(fofoId) != null) {
|
| - |
|
857 |
cellEligible.setCellValue(fofoIdsAndSlabNames.get(fofoId));
|
| - |
|
858 |
} else {
|
| - |
|
859 |
cellEligible.setCellValue("No slab");
|
| - |
|
860 |
}
|
| - |
|
861 |
}
|
| - |
|
862 |
|
| - |
|
863 |
for (int index = 0; index < saleValues.size(); index++) {
|
| - |
|
864 |
sheet.autoSizeColumn(index);
|
| - |
|
865 |
}
|
| - |
|
866 |
|
| - |
|
867 |
try {
|
| - |
|
868 |
workbook.write(outputStream);
|
| - |
|
869 |
workbook.close();
|
| - |
|
870 |
} catch (IOException ioException) {
|
| - |
|
871 |
LOGGER.error("Unable to generate excel file", ioException);
|
| - |
|
872 |
}
|
| - |
|
873 |
}
|
| - |
|
874 |
|
| 743 |
}
|
875 |
}
|