Rev 486 | Blame | Last modification | View Log | RSS feed
package in.shop2020.hotspot.dashbaord.server.handler;import java.util.ArrayList;import java.util.Date;import java.util.List;import in.shop2020.hotspot.dashbaord.server.TransactionUtils;import in.shop2020.hotspot.dashbaord.shared.actions.AllOrderListRequest;import in.shop2020.hotspot.dashbaord.shared.actions.AllOrderListResponse;import in.shop2020.hotspot.dashbaord.shared.actions.Order;import in.shop2020.hotspot.dashbaord.shared.actions.OrderType;import in.shop2020.model.v1.order.Alert;import in.shop2020.model.v1.order.ExtraOrderInfo;import in.shop2020.model.v1.order.OrderStatus;import in.shop2020.model.v1.order.Transaction;import in.shop2020.model.v1.order.TransactionStatus;import in.shop2020.model.v1.order.TransactionService.Client;import in.shop2020.thrift.clients.TransactionServiceClient;import net.customware.gwt.dispatch.server.ActionHandler;import net.customware.gwt.dispatch.server.ExecutionContext;import net.customware.gwt.dispatch.shared.ActionException;public class AllOrderListHandler implements ActionHandler<AllOrderListRequest, AllOrderListResponse>{private OrderType type;private long warehouseId;@Overridepublic AllOrderListResponse execute(AllOrderListRequest request,ExecutionContext context) throws ActionException {// TODO Auto-generated method stubtype = request.getType();warehouseId = request.getWarehouseId();AllOrderListResponse or = new AllOrderListResponse(type, TransactionUtils.getOrders(type, warehouseId));return or;}@Overridepublic Class<AllOrderListRequest> getActionType() {// TODO Auto-generated method stubreturn AllOrderListRequest.class;}@Overridepublic void rollback(AllOrderListRequest arg0, AllOrderListResponse arg1,ExecutionContext arg2) throws ActionException {// TODO Auto-generated method stub}private List<Order> getInitOrders(){List<Order> orders = new ArrayList<Order>();try{TransactionServiceClient client = new TransactionServiceClient();Client c = client.getClient();List<in.shop2020.model.v1.order.Order> t_orders = c.getAllOrders(null, 0L, new Date().getTime(),1);for (in.shop2020.model.v1.order.Order t_order: t_orders){Order o = new Order(t_order.getId(), t_order.getCustomer_id(), t_order.getCustomer_name(), t_order.getCustomer_mobilenumber(),t_order.getCustomer_pincode(), t_order.getCustomer_address(), t_order.getCustomer_email(), t_order.getCreated_timestamp(),t_order.getExpected_delivery_time(), t_order.getStatus().getValue(), t_order.getStatusDescription(), t_order.getLineitems().get(0).getSku_id(),t_order.getLineitems().get(0).getBrand(), t_order.getLineitems().get(0).getModel_name(), t_order.getLineitems().get(0).getModel_number(),t_order.getLineitems().get(0).getExtra_info(), t_order.getTotal_amount(), t_order.getTotal_weight(), t_order.getAirwaybill_no(),t_order.getBilled_by(), t_order.getInvoice_number(), false);orders.add(o);//check if it has an associated alertList<Alert> alerts = c.getAlerts(t_order.getId(), true);if(alerts != null){if (alerts.size() != 0){o.setAlert(true);o.setStatusMessage(alerts.iterator().next().getComment());}}else{o.setAlert(false);}}}catch(Exception e){System.out.println(e);}return orders;}}