| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import in.shop2020.model.v1.catalog.InventoryServiceException;
|
3 |
import in.shop2020.model.v1.catalog.InventoryServiceException;
|
| 4 |
import in.shop2020.model.v1.catalog.Warehouse;
|
4 |
import in.shop2020.model.v1.catalog.Warehouse;
|
| 5 |
import in.shop2020.model.v1.order.LineItem;
|
5 |
import in.shop2020.model.v1.order.LineItem;
|
| 6 |
import in.shop2020.model.v1.order.Order;
|
6 |
import in.shop2020.model.v1.order.Order;
|
| - |
|
7 |
import in.shop2020.model.v1.order.ReturnOrder;
|
| 7 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
8 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 8 |
import in.shop2020.support.utils.ReportsUtils;
|
9 |
import in.shop2020.support.utils.ReportsUtils;
|
| 9 |
import in.shop2020.thrift.clients.CatalogClient;
|
10 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 10 |
import in.shop2020.thrift.clients.TransactionClient;
|
11 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 11 |
|
12 |
|
| Line 27... |
Line 28... |
| 27 |
|
28 |
|
| 28 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
29 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
| 29 |
import org.apache.poi.ss.usermodel.Cell;
|
30 |
import org.apache.poi.ss.usermodel.Cell;
|
| 30 |
import org.apache.poi.ss.usermodel.CellStyle;
|
31 |
import org.apache.poi.ss.usermodel.CellStyle;
|
| 31 |
import org.apache.poi.ss.usermodel.Font;
|
32 |
import org.apache.poi.ss.usermodel.Font;
|
| - |
|
33 |
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
| 32 |
import org.apache.poi.ss.usermodel.Row;
|
34 |
import org.apache.poi.ss.usermodel.Row;
|
| 33 |
import org.apache.poi.ss.usermodel.Sheet;
|
35 |
import org.apache.poi.ss.usermodel.Sheet;
|
| 34 |
import org.apache.poi.ss.usermodel.Workbook;
|
36 |
import org.apache.poi.ss.usermodel.Workbook;
|
| 35 |
import org.apache.poi.ss.util.CellRangeAddress;
|
37 |
import org.apache.poi.ss.util.CellRangeAddress;
|
| 36 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
38 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
| Line 64... |
Line 66... |
| 64 |
})
|
66 |
})
|
| 65 |
public class HotspotReconciliationController implements ServletResponseAware, ServletRequestAware, ServletContextAware {
|
67 |
public class HotspotReconciliationController implements ServletResponseAware, ServletRequestAware, ServletContextAware {
|
| 66 |
|
68 |
|
| 67 |
private static Logger logger = LoggerFactory.getLogger(HotspotReconciliationController.class);
|
69 |
private static Logger logger = LoggerFactory.getLogger(HotspotReconciliationController.class);
|
| 68 |
|
70 |
|
| 69 |
private enum ReportColumn{
|
71 |
private enum OrderReportColumn {
|
| 70 |
ORDER_ID(0),
|
72 |
ORDER_ID(0),
|
| 71 |
BILLING_NUMBER(1),
|
73 |
BILLING_NUMBER(1),
|
| 72 |
BILLING_DATE(2),
|
74 |
BILLING_DATE(2),
|
| 73 |
CUSTOMER_NAME(3),
|
75 |
CUSTOMER_NAME(3),
|
| 74 |
BRAND(4),
|
76 |
BRAND(4),
|
| Line 78... |
Line 80... |
| 78 |
XFER_PRICE(8),
|
80 |
XFER_PRICE(8),
|
| 79 |
SELLING_PRICE(9);
|
81 |
SELLING_PRICE(9);
|
| 80 |
|
82 |
|
| 81 |
private int value;
|
83 |
private int value;
|
| 82 |
|
84 |
|
| 83 |
ReportColumn(int value) {
|
85 |
OrderReportColumn(int value) {
|
| - |
|
86 |
this.value = value;
|
| - |
|
87 |
}
|
| - |
|
88 |
public int getValue(){
|
| - |
|
89 |
return this.value;
|
| - |
|
90 |
}
|
| - |
|
91 |
}
|
| - |
|
92 |
|
| - |
|
93 |
private enum ReturnOrderReportColumn {
|
| - |
|
94 |
ORDER_ID(0),
|
| - |
|
95 |
WAREHOUSE_ID(1),
|
| - |
|
96 |
INVOICE_NUMBER(2),
|
| - |
|
97 |
PRODUCT_GROUP(3),
|
| - |
|
98 |
BRAND(4),
|
| - |
|
99 |
MODEL_NUMBER(5),
|
| - |
|
100 |
COLOR(6),
|
| - |
|
101 |
CREATED_ON(7),
|
| - |
|
102 |
XFER_PRICE(8);
|
| - |
|
103 |
|
| - |
|
104 |
private int value;
|
| - |
|
105 |
|
| - |
|
106 |
ReturnOrderReportColumn(int value) {
|
| 84 |
this.value = value;
|
107 |
this.value = value;
|
| 85 |
}
|
108 |
}
|
| 86 |
public int getValue(){
|
109 |
public int getValue(){
|
| 87 |
return this.value;
|
110 |
return this.value;
|
| 88 |
}
|
111 |
}
|
| Line 95... |
Line 118... |
| 95 |
private HttpServletResponse response;
|
118 |
private HttpServletResponse response;
|
| 96 |
private HttpSession session;
|
119 |
private HttpSession session;
|
| 97 |
private ServletContext context;
|
120 |
private ServletContext context;
|
| 98 |
private String id;
|
121 |
private String id;
|
| 99 |
|
122 |
|
| - |
|
123 |
private final DateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy");
|
| - |
|
124 |
|
| 100 |
public HotspotReconciliationController(){
|
125 |
public HotspotReconciliationController(){
|
| 101 |
|
126 |
|
| 102 |
}
|
127 |
}
|
| 103 |
|
128 |
|
| 104 |
public String index() {
|
129 |
public String index() {
|
| Line 122... |
Line 147... |
| 122 |
List<Warehouse> warehouses = catalogClient.getAllWarehouses(true);
|
147 |
List<Warehouse> warehouses = catalogClient.getAllWarehouses(true);
|
| 123 |
|
148 |
|
| 124 |
TransactionClient transactionServiceClient = new TransactionClient();
|
149 |
TransactionClient transactionServiceClient = new TransactionClient();
|
| 125 |
in.shop2020.model.v1.order.TransactionService.Client client = transactionServiceClient.getClient();
|
150 |
in.shop2020.model.v1.order.TransactionService.Client client = transactionServiceClient.getClient();
|
| 126 |
|
151 |
|
| 127 |
List <Order> orders = new ArrayList<Order>();
|
152 |
List<Order> orders = new ArrayList<Order>();
|
| - |
|
153 |
List<ReturnOrder> returnOrders = new ArrayList<ReturnOrder>();
|
| 128 |
|
154 |
|
| 129 |
//Retrieving all the orders across all the warehouses
|
155 |
//Retrieving all the orders across all the warehouses
|
| - |
|
156 |
long fromTime = startDate.getTime();
|
| - |
|
157 |
long toTime = endDate.getTime();
|
| 130 |
for(Warehouse warehouse : warehouses) {
|
158 |
for(Warehouse warehouse : warehouses) {
|
| 131 |
orders.addAll(client.getOrdersByBillingDate(null, startDate.getTime(), endDate.getTime(), warehouse.getId()));
|
159 |
orders.addAll(client.getOrdersByBillingDate(null, fromTime, toTime, warehouse.getId()));
|
| - |
|
160 |
returnOrders.addAll(client.getReturnOrders(warehouse.getId(), fromTime, toTime));
|
| 132 |
}
|
161 |
}
|
| 133 |
logger.debug("Total number of Orders: " + orders.size());
|
162 |
logger.debug("Total number of Orders: " + orders.size());
|
| 134 |
|
163 |
|
| 135 |
// Preparing XLS file for output
|
164 |
// Preparing XLS file for output
|
| 136 |
response.setContentType("application/vnd.ms-excel");
|
165 |
response.setContentType("application/vnd.ms-excel");
|
| 137 |
|
166 |
|
| 138 |
|
- |
|
| 139 |
DateFormat dateFormatForFile = new SimpleDateFormat("dd.MM.yyyy");
|
167 |
DateFormat dateFormatForFile = new SimpleDateFormat("dd.MM.yyyy");
|
| 140 |
response.setHeader("Content-disposition", "inline; filename=hotspot-reconciliation-from-" + dateFormatForFile.format(startDate) + "-" + dateFormatForFile.format(endDate) + ".xls");
|
168 |
response.setHeader("Content-disposition", "inline; filename=hotspot-reconciliation-from-" + dateFormatForFile.format(startDate) + "-" + dateFormatForFile.format(endDate) + ".xls");
|
| 141 |
|
169 |
|
| 142 |
ServletOutputStream sos;
|
170 |
ServletOutputStream sos;
|
| 143 |
try {
|
171 |
try {
|
| 144 |
ByteArrayOutputStream baos = getSpreadSheetData(orders, startDate, endDate);
|
172 |
ByteArrayOutputStream baos = getReconciliationReport(orders, returnOrders, startDate, endDate);
|
| 145 |
sos = response.getOutputStream();
|
173 |
sos = response.getOutputStream();
|
| 146 |
baos.writeTo(sos);
|
174 |
baos.writeTo(sos);
|
| 147 |
sos.flush();
|
175 |
sos.flush();
|
| 148 |
} catch (IOException e) {
|
176 |
} catch (IOException e) {
|
| 149 |
logger.error("Error while streaming the hotspot reconciliation report", e);
|
177 |
logger.error("Error while streaming the hotspot reconciliation report", e);
|
| Line 162... |
Line 190... |
| 162 |
}
|
190 |
}
|
| 163 |
return new DefaultHttpHeaders("report");
|
191 |
return new DefaultHttpHeaders("report");
|
| 164 |
}
|
192 |
}
|
| 165 |
|
193 |
|
| 166 |
// Prepares the XLS worksheet object and fills in the data with proper formatting
|
194 |
// Prepares the XLS worksheet object and fills in the data with proper formatting
|
| 167 |
private ByteArrayOutputStream getSpreadSheetData(List <Order> orders, Date startDate, Date endDate) {
|
195 |
private ByteArrayOutputStream getReconciliationReport(List<Order> orders, List<ReturnOrder> returnOrders, Date startDate, Date endDate) {
|
| 168 |
ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
|
196 |
ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
|
| 169 |
|
197 |
|
| 170 |
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
- |
|
| 171 |
|
- |
|
| 172 |
Workbook wb = new HSSFWorkbook();
|
198 |
Workbook wb = new HSSFWorkbook();
|
| 173 |
Sheet sheet = wb.createSheet("new sheet");
|
- |
|
| 174 |
short serialNo = 0;
|
- |
|
| 175 |
|
199 |
|
| 176 |
// Create the header row and put all the titles in it. Rows are 0 based.
|
200 |
//Create the style for the title row
|
| 177 |
Font font = wb.createFont();
|
201 |
Font font = wb.createFont();
|
| 178 |
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
202 |
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
| 179 |
CellStyle style = wb.createCellStyle();
|
203 |
CellStyle boldStyle = wb.createCellStyle();
|
| 180 |
style.setFont(font);
|
204 |
boldStyle.setFont(font);
|
| - |
|
205 |
|
| - |
|
206 |
CellStyle rightAlignStyle = wb.createCellStyle();
|
| - |
|
207 |
rightAlignStyle.setAlignment(CellStyle.ALIGN_RIGHT);
|
| 181 |
|
208 |
|
| - |
|
209 |
Sheet orderSheet = wb.createSheet("Orders");
|
| - |
|
210 |
Sheet returnSheet = wb.createSheet("Returns");
|
| - |
|
211 |
|
| - |
|
212 |
populateOrderSheet(orders, startDate, endDate, orderSheet, boldStyle, rightAlignStyle);
|
| - |
|
213 |
populateReturnOrderSheet(returnOrders, startDate, endDate, returnSheet, boldStyle, rightAlignStyle);
|
| - |
|
214 |
|
| - |
|
215 |
// Write the workbook to the output stream
|
| - |
|
216 |
try {
|
| - |
|
217 |
wb.write(baosXLS);
|
| - |
|
218 |
baosXLS.close();
|
| - |
|
219 |
} catch (IOException e) {
|
| - |
|
220 |
logger.error("Unable to write the hotspot reconciliation report to the byte array", e);
|
| - |
|
221 |
}
|
| - |
|
222 |
return baosXLS;
|
| - |
|
223 |
}
|
| - |
|
224 |
|
| - |
|
225 |
private void populateOrderSheet(List<Order> orders, Date startDate, Date endDate, Sheet sheet, CellStyle style, CellStyle rightAlignStyle) {
|
| - |
|
226 |
short serialNo = 0;
|
| - |
|
227 |
|
| - |
|
228 |
// Create the title row and put all the titles in it. Rows are 0 based.
|
| 182 |
Row titleRow = sheet.createRow(serialNo ++);
|
229 |
Row titleRow = sheet.createRow(serialNo ++);
|
| 183 |
Cell titleCell = titleRow.createCell(0);
|
230 |
Cell titleCell = titleRow.createCell(0);
|
| 184 |
titleCell.setCellValue("HotSpot Reconciliation Report (" + dateFormat.format(startDate) + " - " + dateFormat.format(endDate) + ")");
|
231 |
titleCell.setCellValue("Order Reconciliation Report (" + DATE_FORMAT.format(startDate) + " - " + DATE_FORMAT.format(endDate) + ")");
|
| 185 |
titleCell.setCellStyle(style);
|
232 |
titleCell.setCellStyle(style);
|
| 186 |
|
233 |
|
| 187 |
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
|
234 |
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
|
| 188 |
|
235 |
|
| 189 |
sheet.createRow(serialNo ++);
|
236 |
sheet.createRow(serialNo ++);
|
| 190 |
|
237 |
|
| 191 |
Row headerRow = sheet.createRow(serialNo ++);
|
238 |
Row headerRow = sheet.createRow(serialNo ++);
|
| 192 |
headerRow.createCell(ReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
|
239 |
headerRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
|
| 193 |
headerRow.createCell(ReportColumn.BILLING_NUMBER.getValue()).setCellValue("Billing Number");
|
240 |
headerRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue("Billing Number");
|
| 194 |
headerRow.createCell(ReportColumn.BILLING_DATE.getValue()).setCellValue("Billing Date");
|
241 |
headerRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue("Billing Date");
|
| 195 |
headerRow.createCell(ReportColumn.CUSTOMER_NAME.getValue()).setCellValue("Customer Name");
|
242 |
headerRow.createCell(OrderReportColumn.CUSTOMER_NAME.getValue()).setCellValue("Customer Name");
|
| 196 |
headerRow.createCell(ReportColumn.BRAND.getValue()).setCellValue("Brand");
|
243 |
headerRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue("Brand");
|
| 197 |
headerRow.createCell(ReportColumn.MODEL_NAME.getValue()).setCellValue("Model Name");
|
244 |
headerRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue("Model Name");
|
| 198 |
headerRow.createCell(ReportColumn.MODEL_NUMBER.getValue()).setCellValue("Model Number");
|
245 |
headerRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue("Model Number");
|
| 199 |
headerRow.createCell(ReportColumn.COLOR.getValue()).setCellValue("Color");
|
246 |
headerRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue("Color");
|
| 200 |
headerRow.createCell(ReportColumn.XFER_PRICE.getValue()).setCellValue("Transfer Price");
|
247 |
headerRow.createCell(OrderReportColumn.XFER_PRICE.getValue()).setCellValue("Transfer Price");
|
| 201 |
headerRow.createCell(ReportColumn.SELLING_PRICE.getValue()).setCellValue("Selling Price");
|
248 |
headerRow.createCell(OrderReportColumn.SELLING_PRICE.getValue()).setCellValue("Selling Price");
|
| 202 |
|
249 |
|
| 203 |
sheet.createRow(serialNo ++);
|
250 |
sheet.createRow(serialNo ++);
|
| 204 |
double totalTransferPrice = 0.0;
|
251 |
double totalTransferPrice = 0.0;
|
| 205 |
double totalSellingPrice = 0.0;
|
252 |
double totalSellingPrice = 0.0;
|
| 206 |
|
253 |
|
| 207 |
for(int i = 0; i < orders.size(); i ++) {
|
- |
|
| 208 |
Order order = orders.get(i);
|
254 |
for(Order order : orders) {
|
| 209 |
|
- |
|
| 210 |
Row contentRow = sheet.createRow(serialNo++);
|
255 |
Row contentRow = sheet.createRow(serialNo++);
|
| 211 |
|
256 |
|
| 212 |
LineItem lineItem = order.getLineitems().get(0);
|
257 |
LineItem lineItem = order.getLineitems().get(0);
|
| 213 |
double transferPrice = lineItem.getTransfer_price();
|
258 |
double transferPrice = lineItem.getTransfer_price();
|
| 214 |
totalTransferPrice += transferPrice;
|
259 |
totalTransferPrice += transferPrice;
|
| 215 |
|
260 |
|
| 216 |
double sellingPrice = lineItem.getTotal_price();
|
261 |
double sellingPrice = lineItem.getTotal_price();
|
| 217 |
totalSellingPrice += sellingPrice;
|
262 |
totalSellingPrice += sellingPrice;
|
| 218 |
|
263 |
|
| 219 |
contentRow.createCell(ReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
264 |
contentRow.createCell(OrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getId());
|
| 220 |
contentRow.createCell(ReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
265 |
contentRow.createCell(OrderReportColumn.BILLING_NUMBER.getValue()).setCellValue(order.getInvoice_number());
|
| 221 |
contentRow.createCell(ReportColumn.BILLING_DATE.getValue()).setCellValue(dateFormat.format(new Date(order.getBilling_timestamp())));
|
266 |
contentRow.createCell(OrderReportColumn.BILLING_DATE.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getBilling_timestamp())));
|
| 222 |
contentRow.createCell(ReportColumn.CUSTOMER_NAME.getValue()).setCellValue(order.getCustomer_name());
|
267 |
contentRow.createCell(OrderReportColumn.CUSTOMER_NAME.getValue()).setCellValue(order.getCustomer_name());
|
| 223 |
contentRow.createCell(ReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
268 |
contentRow.createCell(OrderReportColumn.BRAND.getValue()).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
| 224 |
contentRow.createCell(ReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
269 |
contentRow.createCell(OrderReportColumn.MODEL_NAME.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
| 225 |
contentRow.createCell(ReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
270 |
contentRow.createCell(OrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
| 226 |
contentRow.createCell(ReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
271 |
contentRow.createCell(OrderReportColumn.COLOR.getValue()).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
| 227 |
contentRow.createCell(ReportColumn.XFER_PRICE.getValue()).setCellValue(transferPrice);
|
272 |
contentRow.createCell(OrderReportColumn.XFER_PRICE.getValue()).setCellValue(transferPrice);
|
| 228 |
contentRow.createCell(ReportColumn.SELLING_PRICE.getValue()).setCellValue(sellingPrice);
|
273 |
contentRow.createCell(OrderReportColumn.SELLING_PRICE.getValue()).setCellValue(sellingPrice);
|
| 229 |
}
|
274 |
}
|
| 230 |
sheet.createRow(serialNo ++);
|
275 |
sheet.createRow(serialNo ++);
|
| 231 |
Row contentRow = sheet.createRow(serialNo);
|
276 |
Row contentRow = sheet.createRow(serialNo);
|
| 232 |
contentRow.createCell(0).setCellValue("Total Transfer Price");
|
277 |
contentRow.createCell(0).setCellValue("Total Transfer Price");
|
| 233 |
contentRow.createCell(ReportColumn.XFER_PRICE.getValue()).setCellValue(totalTransferPrice);
|
278 |
contentRow.createCell(OrderReportColumn.XFER_PRICE.getValue()).setCellValue(totalTransferPrice);
|
| 234 |
contentRow.createCell(ReportColumn.SELLING_PRICE.getValue()).setCellValue(totalSellingPrice);
|
279 |
contentRow.createCell(OrderReportColumn.SELLING_PRICE.getValue()).setCellValue(totalSellingPrice);
|
| 235 |
sheet.addMergedRegion(new CellRangeAddress(serialNo, serialNo, 0, 5));
|
280 |
sheet.addMergedRegion(new CellRangeAddress(serialNo, serialNo, 0, 5));
|
| - |
|
281 |
}
|
| - |
|
282 |
|
| - |
|
283 |
private void populateReturnOrderSheet(List<ReturnOrder> returnOrders, Date startDate, Date endDate, Sheet sheet, CellStyle titleStyle, CellStyle rightAlignStyle) {
|
| - |
|
284 |
short serialNo = 0;
|
| - |
|
285 |
|
| - |
|
286 |
// Create the title row and put all the titles in it. Rows are 0 based.
|
| - |
|
287 |
Row titleRow = sheet.createRow(serialNo ++);
|
| - |
|
288 |
Cell titleCell = titleRow.createCell(0);
|
| - |
|
289 |
titleCell.setCellValue("Return Orders Reconciliation Report (" + DATE_FORMAT.format(startDate) + " - " + DATE_FORMAT.format(endDate) + ")");
|
| - |
|
290 |
titleCell.setCellStyle(titleStyle);
|
| - |
|
291 |
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
|
| - |
|
292 |
|
| - |
|
293 |
// Create the header row
|
| - |
|
294 |
sheet.createRow(serialNo ++);
|
| - |
|
295 |
Row headerRow = sheet.createRow(serialNo ++);
|
| - |
|
296 |
headerRow.createCell(ReturnOrderReportColumn.ORDER_ID.getValue()).setCellValue("Order Id");
|
| - |
|
297 |
headerRow.createCell(ReturnOrderReportColumn.WAREHOUSE_ID.getValue()).setCellValue("Warehouse Id");
|
| - |
|
298 |
headerRow.createCell(ReturnOrderReportColumn.INVOICE_NUMBER.getValue()).setCellValue("Invoice Number");
|
| - |
|
299 |
headerRow.createCell(ReturnOrderReportColumn.PRODUCT_GROUP.getValue()).setCellValue("Product Group");
|
| - |
|
300 |
headerRow.createCell(ReturnOrderReportColumn.BRAND.getValue()).setCellValue("Brand");
|
| - |
|
301 |
headerRow.createCell(ReturnOrderReportColumn.MODEL_NUMBER.getValue()).setCellValue("Model Number");
|
| - |
|
302 |
headerRow.createCell(ReturnOrderReportColumn.COLOR.getValue()).setCellValue("Color");
|
| - |
|
303 |
headerRow.createCell(ReturnOrderReportColumn.CREATED_ON.getValue()).setCellValue("Created On");
|
| - |
|
304 |
headerRow.createCell(ReturnOrderReportColumn.XFER_PRICE.getValue()).setCellValue("Transfer Price");
|
| - |
|
305 |
|
| - |
|
306 |
|
| - |
|
307 |
// Create an empty row
|
| - |
|
308 |
sheet.createRow(serialNo ++);
|
| - |
|
309 |
|
| - |
|
310 |
double totalTransferPrice = 0.0;
|
| - |
|
311 |
for(ReturnOrder order : returnOrders) {
|
| - |
|
312 |
Row contentRow = sheet.createRow(serialNo++);
|
| - |
|
313 |
double transferPrice = order.getTransferPrice();
|
| - |
|
314 |
totalTransferPrice += transferPrice;
|
| - |
|
315 |
|
| - |
|
316 |
contentRow.createCell(ReturnOrderReportColumn.ORDER_ID.getValue()).setCellValue(order.getOrderId());
|
| - |
|
317 |
contentRow.createCell(ReturnOrderReportColumn.WAREHOUSE_ID.getValue()).setCellValue(order.getWarehouseId());
|
| - |
|
318 |
contentRow.createCell(ReturnOrderReportColumn.INVOICE_NUMBER.getValue()).setCellValue(order.getInvoiceNumber());
|
| - |
|
319 |
contentRow.createCell(ReturnOrderReportColumn.PRODUCT_GROUP.getValue()).setCellValue(order.getProductGroup());
|
| - |
|
320 |
contentRow.createCell(ReturnOrderReportColumn.BRAND.getValue()).setCellValue(order.getBrand());
|
| - |
|
321 |
contentRow.createCell(ReturnOrderReportColumn.MODEL_NUMBER.getValue()).setCellValue(order.getModelNumber());
|
| - |
|
322 |
contentRow.createCell(ReturnOrderReportColumn.COLOR.getValue()).setCellValue(order.getColor());
|
| - |
|
323 |
contentRow.createCell(ReturnOrderReportColumn.CREATED_ON.getValue()).setCellValue(DATE_FORMAT.format(new Date(order.getCreatedAt())));
|
| - |
|
324 |
contentRow.createCell(ReturnOrderReportColumn.XFER_PRICE.getValue()).setCellValue(transferPrice);
|
| - |
|
325 |
}
|
| - |
|
326 |
sheet.createRow(serialNo ++);
|
| - |
|
327 |
Row contentRow = sheet.createRow(serialNo);
|
| - |
|
328 |
Cell totalCell = contentRow.createCell(0);
|
| - |
|
329 |
totalCell.setCellValue("Total Transfer Price");
|
| - |
|
330 |
totalCell.setCellStyle(rightAlignStyle);
|
| 236 |
|
331 |
|
| 237 |
// Write the workbook to the output stream
|
332 |
contentRow.createCell(ReturnOrderReportColumn.XFER_PRICE.getValue()).setCellValue(totalTransferPrice);
|
| 238 |
try {
|
- |
|
| 239 |
wb.write(baosXLS);
|
- |
|
| 240 |
baosXLS.close();
|
- |
|
| 241 |
} catch (IOException e) {
|
- |
|
| 242 |
logger.error("Unable to write the hotspot reconciliation report to the byte array", e);
|
333 |
sheet.addMergedRegion(new CellRangeAddress(serialNo, serialNo, 0, ReturnOrderReportColumn.CREATED_ON.getValue()));
|
| 243 |
}
|
- |
|
| 244 |
return baosXLS;
|
- |
|
| 245 |
}
|
334 |
}
|
| 246 |
|
335 |
|
| 247 |
public String getId(){
|
336 |
public String getId(){
|
| 248 |
return id;
|
337 |
return id;
|
| 249 |
}
|
338 |
}
|