| Line 36... |
Line 36... |
| 36 |
import org.apache.struts2.convention.annotation.Results;
|
36 |
import org.apache.struts2.convention.annotation.Results;
|
| 37 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
37 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
| 38 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
38 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
| 39 |
import org.apache.struts2.util.ServletContextAware;
|
39 |
import org.apache.struts2.util.ServletContextAware;
|
| 40 |
import org.apache.thrift.TException;
|
40 |
import org.apache.thrift.TException;
|
| 41 |
import org.apache.thrift.transport.TTransportException;
|
- |
|
| 42 |
import org.slf4j.Logger;
|
41 |
import org.slf4j.Logger;
|
| 43 |
import org.slf4j.LoggerFactory;
|
42 |
import org.slf4j.LoggerFactory;
|
| 44 |
|
43 |
|
| 45 |
|
44 |
|
| 46 |
@InterceptorRefs({
|
45 |
@InterceptorRefs({
|
| Line 61... |
Line 60... |
| 61 |
|
60 |
|
| 62 |
private String error = "";
|
61 |
private String error = "";
|
| 63 |
|
62 |
|
| 64 |
private Client client;
|
63 |
private Client client;
|
| 65 |
|
64 |
|
| - |
|
65 |
private List<PickupStore> stores;
|
| - |
|
66 |
|
| 66 |
public StoreCollectionController() throws TTransportException{
|
67 |
public StoreCollectionController() throws TException{
|
| 67 |
client = (new TransactionClient()).getClient();
|
68 |
client = (new TransactionClient()).getClient();
|
| - |
|
69 |
stores = (new LogisticsClient()).getClient().getAllPickupStores();
|
| 68 |
}
|
70 |
}
|
| 69 |
public String index() {
|
71 |
public String index() {
|
| 70 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getServletPath())) {
|
72 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getServletPath())) {
|
| 71 |
return "authfail";
|
73 |
return "authfail";
|
| 72 |
}
|
74 |
}
|
| Line 135... |
Line 137... |
| 135 |
Sheet collectionSheet = wb.createSheet("Collection");
|
137 |
Sheet collectionSheet = wb.createSheet("Collection");
|
| 136 |
short collectionSerialNo = 0;
|
138 |
short collectionSerialNo = 0;
|
| 137 |
|
139 |
|
| 138 |
Row headerRow = collectionSheet.createRow(collectionSerialNo++);
|
140 |
Row headerRow = collectionSheet.createRow(collectionSerialNo++);
|
| 139 |
headerRow.createCell(0).setCellValue("S.No");
|
141 |
headerRow.createCell(0).setCellValue("S.No");
|
| - |
|
142 |
headerRow.createCell(1).setCellValue("Store Id");
|
| 140 |
headerRow.createCell(1).setCellValue("Order Id");
|
143 |
headerRow.createCell(2).setCellValue("Order Id");
|
| 141 |
headerRow.createCell(2).setCellValue("Product");
|
144 |
headerRow.createCell(3).setCellValue("Product");
|
| 142 |
headerRow.createCell(3).setCellValue("Order Type");
|
145 |
headerRow.createCell(4).setCellValue("Order Type");
|
| 143 |
headerRow.createCell(4).setCellValue("Collection Date");
|
146 |
headerRow.createCell(5).setCellValue("Collection Date");
|
| 144 |
headerRow.createCell(5).setCellValue("Order Amount");
|
147 |
headerRow.createCell(6).setCellValue("Order Amount");
|
| 145 |
headerRow.createCell(6).setCellValue("Collected Amount");
|
148 |
headerRow.createCell(7).setCellValue("Collected Amount");
|
| 146 |
//headerRow.createCell(7).setCellValue("Store Margin");
|
149 |
//headerRow.createCell(7).setCellValue("Store Margin");
|
| 147 |
|
150 |
|
| 148 |
for(Order order: orders){
|
151 |
for(Order order: orders){
|
| 149 |
Row contentRow = collectionSheet.createRow(collectionSerialNo++);
|
152 |
Row contentRow = collectionSheet.createRow(collectionSerialNo++);
|
| 150 |
LineItem line = order.getLineitems().get(0);
|
153 |
LineItem line = order.getLineitems().get(0);
|
| 151 |
String productName = line.getBrand() + " " + line.getModel_name() + " " + line.getModel_number() + " " + line.getColor();
|
154 |
String productName = line.getBrand() + " " + line.getModel_name() + " " + line.getModel_number() + " " + line.getColor();
|
| 152 |
productName = productName.replaceAll("null", "").replaceAll(" ", " ");
|
155 |
productName = productName.replaceAll("null", "").replaceAll(" ", " ");
|
| 153 |
contentRow.createCell(0).setCellValue(collectionSerialNo-1);
|
156 |
contentRow.createCell(0).setCellValue(collectionSerialNo-1);
|
| - |
|
157 |
contentRow.createCell(1).setCellValue(getHotspotId(order.getPickupStoreId()));
|
| 154 |
contentRow.createCell(1).setCellValue(order.getId());
|
158 |
contentRow.createCell(2).setCellValue(order.getId());
|
| 155 |
contentRow.createCell(2).setCellValue(productName);
|
159 |
contentRow.createCell(3).setCellValue(productName);
|
| 156 |
contentRow.createCell(3).setCellValue(order.isCod() ? "COD" : "Prepaid");
|
160 |
contentRow.createCell(4).setCellValue(order.isCod() ? "COD" : "Prepaid");
|
| 157 |
contentRow.createCell(4).setCellValue(formatter.format(order.getDelivery_timestamp()));
|
161 |
contentRow.createCell(5).setCellValue(formatter.format(order.getDelivery_timestamp()));
|
| 158 |
contentRow.createCell(5).setCellValue(order.getTotal_amount());
|
162 |
contentRow.createCell(6).setCellValue(order.getTotal_amount());
|
| 159 |
contentRow.createCell(6).setCellValue(order.isCod() ? order.getTotal_amount() : 0.0);
|
163 |
contentRow.createCell(7).setCellValue(order.isCod() ? order.getTotal_amount() : 0.0);
|
| 160 |
//contentRow.createCell(7).setCellValue(order.isCod() ? .01 * order.getTotal_amount() : .005 * order.getTotal_amount());
|
164 |
//contentRow.createCell(7).setCellValue(order.isCod() ? .01 * order.getTotal_amount() : .005 * order.getTotal_amount());
|
| 161 |
}
|
165 |
}
|
| 162 |
|
166 |
|
| 163 |
try {
|
167 |
try {
|
| 164 |
wb.write(baosXLS);
|
168 |
wb.write(baosXLS);
|
| Line 167... |
Line 171... |
| 167 |
logger.error("Error while streaming payment details report", e);
|
171 |
logger.error("Error while streaming payment details report", e);
|
| 168 |
}
|
172 |
}
|
| 169 |
return baosXLS;
|
173 |
return baosXLS;
|
| 170 |
}
|
174 |
}
|
| 171 |
|
175 |
|
| - |
|
176 |
private String getHotspotId(long storeId){
|
| - |
|
177 |
for(PickupStore store: stores){
|
| - |
|
178 |
if(store.getId() == storeId){
|
| - |
|
179 |
return store.getHotspotId();
|
| - |
|
180 |
}
|
| - |
|
181 |
}
|
| - |
|
182 |
return "";
|
| - |
|
183 |
}
|
| 172 |
|
184 |
|
| 173 |
public String getErrorMsg() {
|
185 |
public String getErrorMsg() {
|
| 174 |
return error;
|
186 |
return error;
|
| 175 |
}
|
187 |
}
|
| 176 |
|
188 |
|
| Line 192... |
Line 204... |
| 192 |
|
204 |
|
| 193 |
public String getServletContextPath() {
|
205 |
public String getServletContextPath() {
|
| 194 |
return context.getContextPath();
|
206 |
return context.getContextPath();
|
| 195 |
}
|
207 |
}
|
| 196 |
|
208 |
|
| 197 |
public List<PickupStore> getAllStores() throws TTransportException, TException {
|
209 |
public List<PickupStore> getAllStores(){
|
| 198 |
return (new LogisticsClient()).getClient().getAllPickupStores();
|
210 |
return stores;
|
| 199 |
}
|
211 |
}
|
| 200 |
}
|
212 |
}
|