| Line 1... |
Line 1... |
| 1 |
/**
|
1 |
/**
|
| 2 |
*
|
2 |
*
|
| 3 |
*/
|
3 |
*/
|
| 4 |
package in.shop2020.crm.service.handler;
|
4 |
package in.shop2020.crm.service.handler;
|
| 5 |
|
5 |
|
| 6 |
import in.shop2020.alert.AlertService;
|
- |
|
| 7 |
import in.shop2020.alert.EntityType;
|
- |
|
| 8 |
import in.shop2020.alert.MonitoredEntity;
|
- |
|
| 9 |
import in.shop2020.config.ConfigException;
|
6 |
import in.shop2020.config.ConfigException;
|
| 10 |
import in.shop2020.crm.Activity;
|
7 |
import in.shop2020.crm.Activity;
|
| 11 |
import in.shop2020.crm.ActivityType;
|
8 |
import in.shop2020.crm.ActivityType;
|
| 12 |
import in.shop2020.crm.Agent;
|
9 |
import in.shop2020.crm.Agent;
|
| 13 |
import in.shop2020.crm.TicketStatus;
|
10 |
import in.shop2020.crm.TicketStatus;
|
| Line 18... |
Line 15... |
| 18 |
import in.shop2020.crm.handler.ActivityHandler;
|
15 |
import in.shop2020.crm.handler.ActivityHandler;
|
| 19 |
import in.shop2020.crm.handler.AgentHandler;
|
16 |
import in.shop2020.crm.handler.AgentHandler;
|
| 20 |
import in.shop2020.crm.handler.TicketHandler;
|
17 |
import in.shop2020.crm.handler.TicketHandler;
|
| 21 |
import in.shop2020.serving.model.ShipmentUpdate;
|
18 |
import in.shop2020.serving.model.ShipmentUpdate;
|
| 22 |
import in.shop2020.serving.services.FedExTrackingService;
|
19 |
import in.shop2020.serving.services.FedExTrackingService;
|
| 23 |
import in.shop2020.thrift.clients.AlertClient;
|
- |
|
| 24 |
import in.shop2020.thrift.clients.InventoryClient;
|
20 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 25 |
import in.shop2020.thrift.clients.TransactionClient;
|
21 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 26 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
22 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 27 |
import in.shop2020.model.v1.inventory.WarehouseLocation;
|
23 |
import in.shop2020.model.v1.inventory.WarehouseLocation;
|
| 28 |
import in.shop2020.model.v1.inventory.Warehouse;
|
24 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 29 |
import in.shop2020.model.v1.order.Order;
|
25 |
import in.shop2020.model.v1.order.Order;
|
| 30 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
26 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 31 |
|
27 |
|
| 32 |
import java.text.ParseException;
|
28 |
import java.text.ParseException;
|
| 33 |
import java.util.ArrayList;
|
29 |
import java.util.ArrayList;
|
| 34 |
import java.util.Calendar;
|
- |
|
| - |
|
30 |
|
| 35 |
import java.util.Date;
|
31 |
import java.util.Date;
|
| 36 |
import java.util.HashMap;
|
32 |
import java.util.HashMap;
|
| 37 |
import java.util.List;
|
33 |
import java.util.List;
|
| 38 |
import java.util.Map;
|
34 |
import java.util.Map;
|
| 39 |
|
35 |
|
| Line 98... |
Line 94... |
| 98 |
ticketHandler.updateTicket(in.shop2020.crm.domain.Ticket
|
94 |
ticketHandler.updateTicket(in.shop2020.crm.domain.Ticket
|
| 99 |
.create(ticket));
|
95 |
.create(ticket));
|
| 100 |
activity.setTicketId(ticket.getId());
|
96 |
activity.setTicketId(ticket.getId());
|
| 101 |
activityHandler.insertActivity(in.shop2020.crm.domain.Activity
|
97 |
activityHandler.insertActivity(in.shop2020.crm.domain.Activity
|
| 102 |
.create(activity));
|
98 |
.create(activity));
|
| 103 |
try{
|
- |
|
| 104 |
/*For now monitoring is only done for New tickets and hence once any
|
- |
|
| 105 |
* activity is done on a ticket after its creation, we stop monitoring that ticket*/
|
- |
|
| 106 |
if(activity.getType()== ActivityType.SEND_EMAIL_TO_CUSTOMER ||
|
- |
|
| 107 |
activity.getType()== ActivityType.ESCALATE_TICKET ||
|
- |
|
| 108 |
activity.getType()== ActivityType.CALLED_CUSTOMER ||
|
- |
|
| 109 |
activity.getTicketStatus().equals(TicketStatus.CLOSED)) {
|
- |
|
| 110 |
AlertService.Client alertClient = new AlertClient().getClient();
|
- |
|
| 111 |
alertClient.endMonitoringEntity(EntityType.TICKET, "ticketId = " + ticket.getId());
|
- |
|
| 112 |
}
|
- |
|
| 113 |
} catch(Exception ex) {
|
- |
|
| 114 |
log.error("Exception while ending monitoring for ticketId " + ticket.getId());
|
- |
|
| 115 |
log.error(ex);
|
- |
|
| 116 |
}
|
- |
|
| 117 |
} catch (ParseException e) {
|
99 |
} catch (ParseException e) {
|
| 118 |
throw new TException("Could not update " + ticket, e);
|
100 |
throw new TException("Could not update " + ticket, e);
|
| 119 |
}
|
101 |
}
|
| 120 |
}
|
102 |
}
|
| 121 |
|
103 |
|
| Line 126... |
Line 108... |
| 126 |
long ticketId = ticketHandler
|
108 |
long ticketId = ticketHandler
|
| 127 |
.insertTicket(in.shop2020.crm.domain.Ticket.create(ticket));
|
109 |
.insertTicket(in.shop2020.crm.domain.Ticket.create(ticket));
|
| 128 |
activity.setTicketId(ticketId);
|
110 |
activity.setTicketId(ticketId);
|
| 129 |
activityHandler.insertActivity(in.shop2020.crm.domain.Activity
|
111 |
activityHandler.insertActivity(in.shop2020.crm.domain.Activity
|
| 130 |
.create(activity));
|
112 |
.create(activity));
|
| 131 |
try {
|
- |
|
| 132 |
if(ticket.getCategory()!= TicketCategory.DELIVERY_PROBLEM &&
|
- |
|
| 133 |
ticket.getCategory()!= TicketCategory.PRODUCT_PROCUREMENT &&
|
- |
|
| 134 |
ticket.getCategory()!= TicketCategory.DOA_RECEIVED) {
|
- |
|
| 135 |
MonitoredEntity entity = new MonitoredEntity();
|
- |
|
| 136 |
entity.setEntityType(EntityType.TICKET);
|
- |
|
| 137 |
entity.setEventType(0);
|
- |
|
| 138 |
entity.setEntityIdentifier("ticketId = " + new Long(ticketId).toString());
|
- |
|
| 139 |
entity.setDescription(ticket.getDescription().substring(0, Math.min(ticket.getDescription().length(), 2048)-1));
|
- |
|
| 140 |
Calendar thresholdTime = Calendar.getInstance();
|
- |
|
| 141 |
thresholdTime.add(Calendar.HOUR, 4);
|
- |
|
| 142 |
entity.setWarnExpiryTime(thresholdTime.getTimeInMillis());
|
- |
|
| 143 |
thresholdTime.add(Calendar.HOUR, 2);
|
- |
|
| 144 |
entity.setCriticalExpiryTime(thresholdTime.getTimeInMillis());
|
- |
|
| 145 |
AlertService.Client alertClient = new AlertClient().getClient();
|
- |
|
| 146 |
alertClient.scheduleAlert(entity);
|
- |
|
| 147 |
}
|
- |
|
| 148 |
} catch (Exception ex) {
|
- |
|
| 149 |
log.error("Exception while scheduling alert for Ticket Id "+ticketId);
|
- |
|
| 150 |
ex.printStackTrace();
|
- |
|
| 151 |
}
|
- |
|
| 152 |
return ticketId;
|
113 |
return ticketId;
|
| 153 |
} catch (ParseException e) {
|
114 |
} catch (ParseException e) {
|
| 154 |
throw new TException("Could not insert " + ticket, e);
|
115 |
throw new TException("Could not insert " + ticket, e);
|
| 155 |
}
|
116 |
}
|
| 156 |
}
|
117 |
}
|