| Line 19... |
Line 19... |
| 19 |
import in.shop2020.crm.handler.AgentHandler;
|
19 |
import in.shop2020.crm.handler.AgentHandler;
|
| 20 |
import in.shop2020.crm.handler.TicketHandler;
|
20 |
import in.shop2020.crm.handler.TicketHandler;
|
| 21 |
import in.shop2020.serving.model.ShipmentUpdate;
|
21 |
import in.shop2020.serving.model.ShipmentUpdate;
|
| 22 |
import in.shop2020.serving.services.FedExTrackingService;
|
22 |
import in.shop2020.serving.services.FedExTrackingService;
|
| 23 |
import in.shop2020.thrift.clients.AlertClient;
|
23 |
import in.shop2020.thrift.clients.AlertClient;
|
| - |
|
24 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 24 |
import in.shop2020.thrift.clients.TransactionClient;
|
25 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 25 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
26 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| - |
|
27 |
import in.shop2020.model.v1.inventory.WarehouseLocation;
|
| - |
|
28 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 26 |
import in.shop2020.model.v1.order.Order;
|
29 |
import in.shop2020.model.v1.order.Order;
|
| 27 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
30 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 28 |
|
31 |
|
| 29 |
import java.text.ParseException;
|
32 |
import java.text.ParseException;
|
| 30 |
import java.util.ArrayList;
|
33 |
import java.util.ArrayList;
|
| 31 |
import java.util.Calendar;
|
34 |
import java.util.Calendar;
|
| 32 |
import java.util.Date;
|
35 |
import java.util.Date;
|
| - |
|
36 |
import java.util.HashMap;
|
| 33 |
import java.util.List;
|
37 |
import java.util.List;
|
| 34 |
import java.util.Map;
|
38 |
import java.util.Map;
|
| 35 |
|
39 |
|
| 36 |
import org.apache.commons.logging.Log;
|
40 |
import org.apache.commons.logging.Log;
|
| 37 |
import org.apache.commons.logging.LogFactory;
|
41 |
import org.apache.commons.logging.LogFactory;
|
| Line 47... |
Line 51... |
| 47 |
*
|
51 |
*
|
| 48 |
* @author mandeep
|
52 |
* @author mandeep
|
| 49 |
*/
|
53 |
*/
|
| 50 |
@Service
|
54 |
@Service
|
| 51 |
public class CRMServiceHandler implements Iface {
|
55 |
public class CRMServiceHandler implements Iface {
|
| 52 |
private static final Log log = LogFactory.getLog(CRMServiceHandler.class);
|
56 |
private static final Log log = LogFactory.getLog(CRMServiceHandler.class);
|
| 53 |
|
57 |
|
| 54 |
private TicketHandler ticketHandler;
|
58 |
private TicketHandler ticketHandler;
|
| 55 |
private ActivityHandler activityHandler;
|
59 |
private ActivityHandler activityHandler;
|
| 56 |
private AgentHandler agentHandler;
|
60 |
private AgentHandler agentHandler;
|
| 57 |
private FedExTrackingService fedexTrackClient = new FedExTrackingService();
|
61 |
private FedExTrackingService fedexTrackClientMumbai;
|
| 58 |
|
62 |
private FedExTrackingService fedexTrackClientDelhi;
|
| 59 |
public CRMServiceHandler() {
|
63 |
|
| 60 |
log.info("Creating context");
|
64 |
public CRMServiceHandler() {
|
| 61 |
ApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
|
65 |
log.info("Creating context");
|
| 62 |
ticketHandler = context.getBean(TicketHandler.class);
|
66 |
ApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
|
| 63 |
activityHandler = context.getBean(ActivityHandler.class);
|
67 |
ticketHandler = context.getBean(TicketHandler.class);
|
| 64 |
agentHandler = context.getBean(AgentHandler.class);
|
68 |
activityHandler = context.getBean(ActivityHandler.class);
|
| 65 |
}
|
69 |
agentHandler = context.getBean(AgentHandler.class);
|
| 66 |
|
70 |
}
|
| 67 |
public List<Ticket> getTickets(SearchFilter searchFilter) throws TException {
|
71 |
|
| 68 |
List<Ticket> ttickets = new ArrayList<Ticket>();
|
72 |
public List<Ticket> getTickets(SearchFilter searchFilter) throws TException {
|
| 69 |
for (in.shop2020.crm.domain.Ticket ticket : ticketHandler
|
73 |
List<Ticket> ttickets = new ArrayList<Ticket>();
|
| 70 |
.getTickets(in.shop2020.crm.domain.SearchFilter
|
74 |
for (in.shop2020.crm.domain.Ticket ticket : ticketHandler
|
| 71 |
.create(searchFilter))) {
|
75 |
.getTickets(in.shop2020.crm.domain.SearchFilter
|
| 72 |
ttickets.add(ticket.getThriftTicket());
|
76 |
.create(searchFilter))) {
|
| 73 |
}
|
77 |
ttickets.add(ticket.getThriftTicket());
|
| 74 |
|
78 |
}
|
| 75 |
return ttickets;
|
79 |
|
| 76 |
}
|
80 |
return ttickets;
|
| 77 |
|
81 |
}
|
| 78 |
public List<Ticket> getUnassignedTickets() throws TException {
|
82 |
|
| 79 |
List<Ticket> tickets = new ArrayList<Ticket>();
|
83 |
public List<Ticket> getUnassignedTickets() throws TException {
|
| 80 |
|
84 |
List<Ticket> tickets = new ArrayList<Ticket>();
|
| 81 |
for (in.shop2020.crm.domain.Ticket ticket : ticketHandler
|
85 |
|
| 82 |
.getUnassignedTickets()) {
|
86 |
for (in.shop2020.crm.domain.Ticket ticket : ticketHandler
|
| 83 |
tickets.add(ticket.getThriftTicket());
|
87 |
.getUnassignedTickets()) {
|
| 84 |
}
|
88 |
tickets.add(ticket.getThriftTicket());
|
| 85 |
|
89 |
}
|
| 86 |
return tickets;
|
90 |
|
| 87 |
}
|
91 |
return tickets;
|
| 88 |
|
92 |
}
|
| 89 |
@Transactional
|
93 |
|
| 90 |
public void updateTicket(Ticket ticket, Activity activity)
|
94 |
@Transactional
|
| 91 |
throws TException {
|
95 |
public void updateTicket(Ticket ticket, Activity activity)
|
| 92 |
try {
|
96 |
throws TException {
|
| 93 |
ticketHandler.updateTicket(in.shop2020.crm.domain.Ticket
|
97 |
try {
|
| 94 |
.create(ticket));
|
98 |
ticketHandler.updateTicket(in.shop2020.crm.domain.Ticket
|
| 95 |
activity.setTicketId(ticket.getId());
|
99 |
.create(ticket));
|
| 96 |
activityHandler.insertActivity(in.shop2020.crm.domain.Activity
|
100 |
activity.setTicketId(ticket.getId());
|
| 97 |
.create(activity));
|
101 |
activityHandler.insertActivity(in.shop2020.crm.domain.Activity
|
| 98 |
try{
|
102 |
.create(activity));
|
| 99 |
/*For now monitoring is only done for New tickets and hence once any
|
103 |
try{
|
| 100 |
* activity is done on a ticket after its creation, we stop monitoring that ticket*/
|
104 |
/*For now monitoring is only done for New tickets and hence once any
|
| 101 |
if(activity.getType()== ActivityType.SEND_EMAIL_TO_CUSTOMER ||
|
105 |
* activity is done on a ticket after its creation, we stop monitoring that ticket*/
|
| 102 |
activity.getType()== ActivityType.ESCALATE_TICKET ||
|
106 |
if(activity.getType()== ActivityType.SEND_EMAIL_TO_CUSTOMER ||
|
| 103 |
activity.getType()== ActivityType.CALLED_CUSTOMER ||
|
107 |
activity.getType()== ActivityType.ESCALATE_TICKET ||
|
| 104 |
activity.getTicketStatus().equals(TicketStatus.CLOSED)) {
|
108 |
activity.getType()== ActivityType.CALLED_CUSTOMER ||
|
| 105 |
AlertService.Client alertClient = new AlertClient().getClient();
|
109 |
activity.getTicketStatus().equals(TicketStatus.CLOSED)) {
|
| 106 |
alertClient.endMonitoringEntity(EntityType.TICKET, "ticketId = " + ticket.getId());
|
110 |
AlertService.Client alertClient = new AlertClient().getClient();
|
| 107 |
}
|
111 |
alertClient.endMonitoringEntity(EntityType.TICKET, "ticketId = " + ticket.getId());
|
| 108 |
} catch(Exception ex) {
|
112 |
}
|
| 109 |
log.error("Exception while ending monitoring for ticketId " + ticket.getId());
|
113 |
} catch(Exception ex) {
|
| 110 |
log.error(ex);
|
114 |
log.error("Exception while ending monitoring for ticketId " + ticket.getId());
|
| 111 |
}
|
115 |
log.error(ex);
|
| 112 |
} catch (ParseException e) {
|
116 |
}
|
| 113 |
throw new TException("Could not update " + ticket, e);
|
117 |
} catch (ParseException e) {
|
| 114 |
}
|
118 |
throw new TException("Could not update " + ticket, e);
|
| 115 |
}
|
119 |
}
|
| 116 |
|
120 |
}
|
| 117 |
@Transactional
|
121 |
|
| 118 |
public long insertTicket(Ticket ticket, Activity activity)
|
122 |
@Transactional
|
| 119 |
throws TException {
|
123 |
public long insertTicket(Ticket ticket, Activity activity)
|
| 120 |
try {
|
124 |
throws TException {
|
| 121 |
long ticketId = ticketHandler
|
125 |
try {
|
| 122 |
.insertTicket(in.shop2020.crm.domain.Ticket.create(ticket));
|
126 |
long ticketId = ticketHandler
|
| 123 |
activity.setTicketId(ticketId);
|
127 |
.insertTicket(in.shop2020.crm.domain.Ticket.create(ticket));
|
| 124 |
activityHandler.insertActivity(in.shop2020.crm.domain.Activity
|
128 |
activity.setTicketId(ticketId);
|
| 125 |
.create(activity));
|
129 |
activityHandler.insertActivity(in.shop2020.crm.domain.Activity
|
| 126 |
try {
|
130 |
.create(activity));
|
| 127 |
if(ticket.getCategory()!= TicketCategory.DELIVERY_PROBLEM &&
|
131 |
try {
|
| 128 |
ticket.getCategory()!= TicketCategory.PRODUCT_PROCUREMENT &&
|
132 |
if(ticket.getCategory()!= TicketCategory.DELIVERY_PROBLEM &&
|
| 129 |
ticket.getCategory()!= TicketCategory.DOA_RECEIVED) {
|
133 |
ticket.getCategory()!= TicketCategory.PRODUCT_PROCUREMENT &&
|
| 130 |
MonitoredEntity entity = new MonitoredEntity();
|
134 |
ticket.getCategory()!= TicketCategory.DOA_RECEIVED) {
|
| 131 |
entity.setEntityType(EntityType.TICKET);
|
135 |
MonitoredEntity entity = new MonitoredEntity();
|
| 132 |
entity.setEventType(0);
|
136 |
entity.setEntityType(EntityType.TICKET);
|
| 133 |
entity.setEntityIdentifier("ticketId = " + new Long(ticketId).toString());
|
137 |
entity.setEventType(0);
|
| 134 |
entity.setDescription(ticket.getDescription());
|
138 |
entity.setEntityIdentifier("ticketId = " + new Long(ticketId).toString());
|
| 135 |
Calendar thresholdTime = Calendar.getInstance();
|
139 |
entity.setDescription(ticket.getDescription());
|
| 136 |
thresholdTime.add(Calendar.HOUR, 4);
|
140 |
Calendar thresholdTime = Calendar.getInstance();
|
| 137 |
entity.setWarnExpiryTime(thresholdTime.getTimeInMillis());
|
141 |
thresholdTime.add(Calendar.HOUR, 4);
|
| 138 |
thresholdTime.add(Calendar.HOUR, 2);
|
142 |
entity.setWarnExpiryTime(thresholdTime.getTimeInMillis());
|
| 139 |
entity.setCriticalExpiryTime(thresholdTime.getTimeInMillis());
|
143 |
thresholdTime.add(Calendar.HOUR, 2);
|
| 140 |
AlertService.Client alertClient = new AlertClient().getClient();
|
144 |
entity.setCriticalExpiryTime(thresholdTime.getTimeInMillis());
|
| 141 |
alertClient.scheduleAlert(entity);
|
145 |
AlertService.Client alertClient = new AlertClient().getClient();
|
| 142 |
}
|
146 |
alertClient.scheduleAlert(entity);
|
| 143 |
} catch (Exception ex) {
|
147 |
}
|
| 144 |
log.error("Exception while scheduling alert for Ticket Id "+ticketId);
|
148 |
} catch (Exception ex) {
|
| 145 |
log.error(ex);
|
149 |
log.error("Exception while scheduling alert for Ticket Id "+ticketId);
|
| 146 |
}
|
150 |
log.error(ex);
|
| 147 |
return ticketId;
|
151 |
}
|
| 148 |
} catch (ParseException e) {
|
152 |
return ticketId;
|
| 149 |
throw new TException("Could not insert " + ticket, e);
|
153 |
} catch (ParseException e) {
|
| 150 |
}
|
154 |
throw new TException("Could not insert " + ticket, e);
|
| 151 |
}
|
155 |
}
|
| 152 |
|
156 |
}
|
| 153 |
public List<Activity> getActivities(SearchFilter searchFilter)
|
157 |
|
| 154 |
throws TException {
|
158 |
public List<Activity> getActivities(SearchFilter searchFilter)
|
| 155 |
List<Activity> tactivities = new ArrayList<Activity>();
|
159 |
throws TException {
|
| 156 |
//Start:- Added By Manish Sharma for Displaying Current Ticket Status for Unread Customer Activities on 21-Jun-2013
|
160 |
List<Activity> tactivities = new ArrayList<Activity>();
|
| 157 |
in.shop2020.crm.domain.SearchFilter filter_to_check =in.shop2020.crm.domain.SearchFilter.create(searchFilter);
|
161 |
//Start:- Added By Manish Sharma for Displaying Current Ticket Status for Unread Customer Activities on 21-Jun-2013
|
| 158 |
List<in.shop2020.crm.domain.Activity> activities = activityHandler
|
162 |
in.shop2020.crm.domain.SearchFilter filter_to_check =in.shop2020.crm.domain.SearchFilter.create(searchFilter);
|
| 159 |
.getActivities(filter_to_check);
|
163 |
List<in.shop2020.crm.domain.Activity> activities = activityHandler
|
| 160 |
in.shop2020.crm.domain.SearchFilter new_searchFilter = new in.shop2020.crm.domain.SearchFilter();
|
164 |
.getActivities(filter_to_check);
|
| 161 |
//End:- Added By Manish Sharma for Displaying Current Ticket Status for Unread Customer Activities on 21-Jun-2013
|
165 |
in.shop2020.crm.domain.SearchFilter new_searchFilter = new in.shop2020.crm.domain.SearchFilter();
|
| 162 |
|
166 |
//End:- Added By Manish Sharma for Displaying Current Ticket Status for Unread Customer Activities on 21-Jun-2013
|
| 163 |
if (activities != null) {
|
167 |
|
| 164 |
for (in.shop2020.crm.domain.Activity ticket : activities) {
|
168 |
if (activities != null) {
|
| 165 |
//Start:- Added By Manish Sharma for Displaying Current Ticket Status for Unread Customer Activities on 21-Jun-2013
|
169 |
for (in.shop2020.crm.domain.Activity ticket : activities) {
|
| 166 |
in.shop2020.crm.Activity activity = ticket.getThriftActivity();
|
170 |
//Start:- Added By Manish Sharma for Displaying Current Ticket Status for Unread Customer Activities on 21-Jun-2013
|
| 167 |
if(filter_to_check.getIsActivityRead()!=null && !filter_to_check.getIsActivityRead()){
|
171 |
in.shop2020.crm.Activity activity = ticket.getThriftActivity();
|
| 168 |
if(activity.getTicketId() > 0){
|
172 |
if(filter_to_check.getIsActivityRead()!=null && !filter_to_check.getIsActivityRead()){
|
| 169 |
new_searchFilter.setTicketId(activity.getTicketId());
|
173 |
if(activity.getTicketId() > 0){
|
| 170 |
List<in.shop2020.crm.domain.Ticket> tickets_as_per_activity= ticketHandler.getTickets(new_searchFilter);
|
174 |
new_searchFilter.setTicketId(activity.getTicketId());
|
| 171 |
activity.setTicketStatus(tickets_as_per_activity.get(0).getStatus());
|
175 |
List<in.shop2020.crm.domain.Ticket> tickets_as_per_activity= ticketHandler.getTickets(new_searchFilter);
|
| 172 |
}
|
176 |
activity.setTicketStatus(tickets_as_per_activity.get(0).getStatus());
|
| 173 |
}
|
177 |
}
|
| 174 |
tactivities.add(activity);
|
178 |
}
|
| 175 |
//End:- Added By Manish Sharma for Displaying Current Ticket Status for Unread Customer Activities on 21-Jun-2013
|
179 |
tactivities.add(activity);
|
| 176 |
}
|
180 |
//End:- Added By Manish Sharma for Displaying Current Ticket Status for Unread Customer Activities on 21-Jun-2013
|
| 177 |
}
|
181 |
}
|
| 178 |
|
182 |
}
|
| 179 |
return tactivities;
|
183 |
|
| 180 |
}
|
184 |
return tactivities;
|
| 181 |
|
185 |
}
|
| 182 |
public long insertActivity(Activity activity) throws TException {
|
186 |
|
| 183 |
try {
|
187 |
public long insertActivity(Activity activity) throws TException {
|
| 184 |
return activityHandler.insertActivity(in.shop2020.crm.domain.Activity
|
188 |
try {
|
| 185 |
.create(activity));
|
189 |
return activityHandler.insertActivity(in.shop2020.crm.domain.Activity
|
| 186 |
} catch (ParseException e) {
|
190 |
.create(activity));
|
| 187 |
throw new TException("Could not insert " + activity, e);
|
191 |
} catch (ParseException e) {
|
| 188 |
}
|
192 |
throw new TException("Could not insert " + activity, e);
|
| 189 |
}
|
193 |
}
|
| 190 |
|
194 |
}
|
| 191 |
@Transactional
|
195 |
|
| 192 |
public void markAsRead(long activityId, long agentId) throws TException {
|
196 |
@Transactional
|
| 193 |
in.shop2020.crm.domain.SearchFilter searchFilter = new in.shop2020.crm.domain.SearchFilter();
|
197 |
public void markAsRead(long activityId, long agentId) throws TException {
|
| 194 |
searchFilter.setActivityId(activityId);
|
198 |
in.shop2020.crm.domain.SearchFilter searchFilter = new in.shop2020.crm.domain.SearchFilter();
|
| 195 |
activityHandler.markAsRead(activityId);
|
199 |
searchFilter.setActivityId(activityId);
|
| 196 |
in.shop2020.crm.domain.Activity activity = activityHandler
|
200 |
activityHandler.markAsRead(activityId);
|
| 197 |
.getActivities(searchFilter).get(0);
|
201 |
in.shop2020.crm.domain.Activity activity = activityHandler
|
| 198 |
|
202 |
.getActivities(searchFilter).get(0);
|
| 199 |
// Setting activity fields from latest ticket fields
|
203 |
|
| 200 |
if (activity.getTicketId() != null) {
|
204 |
// Setting activity fields from latest ticket fields
|
| 201 |
searchFilter.setTicketId(activity.getTicketId());
|
205 |
if (activity.getTicketId() != null) {
|
| 202 |
in.shop2020.crm.domain.Ticket ticket = ticketHandler.getTickets(searchFilter).get(0);
|
206 |
searchFilter.setTicketId(activity.getTicketId());
|
| 203 |
activity.setTicketAssigneeId(ticket.getAssigneeId());
|
207 |
in.shop2020.crm.domain.Ticket ticket = ticketHandler.getTickets(searchFilter).get(0);
|
| 204 |
activity.setTicketCategory(ticket.getCategory());
|
208 |
activity.setTicketAssigneeId(ticket.getAssigneeId());
|
| 205 |
activity.setTicketDescription(ticket.getDescription());
|
209 |
activity.setTicketCategory(ticket.getCategory());
|
| 206 |
activity.setTicketPriority(ticket.getPriority());
|
210 |
activity.setTicketDescription(ticket.getDescription());
|
| 207 |
activity.setTicketStatus(ticket.getStatus());
|
211 |
activity.setTicketPriority(ticket.getPriority());
|
| 208 |
}
|
212 |
activity.setTicketStatus(ticket.getStatus());
|
| 209 |
|
213 |
}
|
| 210 |
activity.setCreatorId(agentId);
|
214 |
|
| 211 |
activity.setDescription("Marked as read ticketId: "
|
215 |
activity.setCreatorId(agentId);
|
| 212 |
+ activity.getTicketId() + ", activityId: " + activityId);
|
216 |
activity.setDescription("Marked as read ticketId: "
|
| 213 |
activity.setType(ActivityType.OTHER);
|
217 |
+ activity.getTicketId() + ", activityId: " + activityId);
|
| 214 |
activityHandler.insertActivity(activity);
|
218 |
activity.setType(ActivityType.OTHER);
|
| 215 |
}
|
219 |
activityHandler.insertActivity(activity);
|
| 216 |
|
220 |
}
|
| 217 |
public List<Agent> getAgents(SearchFilter searchFilter) throws TException {
|
221 |
|
| 218 |
List<Agent> agents = new ArrayList<Agent>();
|
222 |
public List<Agent> getAgents(SearchFilter searchFilter) throws TException {
|
| 219 |
|
223 |
List<Agent> agents = new ArrayList<Agent>();
|
| 220 |
for (in.shop2020.crm.domain.Agent agent : agentHandler
|
224 |
|
| 221 |
.getAgents(in.shop2020.crm.domain.SearchFilter
|
225 |
for (in.shop2020.crm.domain.Agent agent : agentHandler
|
| 222 |
.create(searchFilter))) {
|
226 |
.getAgents(in.shop2020.crm.domain.SearchFilter
|
| 223 |
agents.add(agent.getThriftAgent());
|
227 |
.create(searchFilter))) {
|
| 224 |
}
|
228 |
agents.add(agent.getThriftAgent());
|
| 225 |
|
229 |
}
|
| 226 |
return agents;
|
230 |
|
| 227 |
}
|
231 |
return agents;
|
| 228 |
|
232 |
}
|
| 229 |
public List<Agent> getInactiveAgents(SearchFilter searchFilter) throws TException {
|
233 |
|
| 230 |
List<Agent> agents = new ArrayList<Agent>();
|
234 |
public List<Agent> getInactiveAgents(SearchFilter searchFilter) throws TException {
|
| 231 |
|
235 |
List<Agent> agents = new ArrayList<Agent>();
|
| 232 |
for (in.shop2020.crm.domain.Agent agent : agentHandler
|
236 |
|
| 233 |
.getInactiveAgents(in.shop2020.crm.domain.SearchFilter
|
237 |
for (in.shop2020.crm.domain.Agent agent : agentHandler
|
| 234 |
.create(searchFilter))) {
|
238 |
.getInactiveAgents(in.shop2020.crm.domain.SearchFilter
|
| 235 |
agents.add(agent.getThriftAgent());
|
239 |
.create(searchFilter))) {
|
| 236 |
}
|
240 |
agents.add(agent.getThriftAgent());
|
| 237 |
|
241 |
}
|
| 238 |
return agents;
|
242 |
|
| 239 |
}
|
243 |
return agents;
|
| 240 |
|
244 |
}
|
| 241 |
public void updatePasswordForAgent(String agentEmailId, String password)
|
245 |
|
| 242 |
throws TException {
|
246 |
public void updatePasswordForAgent(String agentEmailId, String password)
|
| 243 |
agentHandler.updatePasswordForAgent(agentEmailId, password);
|
247 |
throws TException {
|
| 244 |
}
|
248 |
agentHandler.updatePasswordForAgent(agentEmailId, password);
|
| 245 |
|
249 |
}
|
| 246 |
public long getLastEmailProcessedTimestamp() throws TException {
|
250 |
|
| 247 |
return agentHandler.getLastEmailProcessedTimestamp().getTime();
|
251 |
public long getLastEmailProcessedTimestamp() throws TException {
|
| 248 |
}
|
252 |
return agentHandler.getLastEmailProcessedTimestamp().getTime();
|
| 249 |
|
253 |
}
|
| 250 |
public void updateLastEmailProcessedTimestamp(long timestamp)
|
254 |
|
| 251 |
throws TException {
|
255 |
public void updateLastEmailProcessedTimestamp(long timestamp)
|
| 252 |
agentHandler.updateLastEmailProcessedTimestamp(new Date(timestamp));
|
256 |
throws TException {
|
| 253 |
}
|
257 |
agentHandler.updateLastEmailProcessedTimestamp(new Date(timestamp));
|
| 254 |
|
258 |
}
|
| 255 |
public List<String> getRoleNamesForAgent(String agentEmailId)
|
259 |
|
| 256 |
throws TException {
|
260 |
public List<String> getRoleNamesForAgent(String agentEmailId)
|
| 257 |
return agentHandler.getRoleNamesForAgent(agentEmailId);
|
261 |
throws TException {
|
| 258 |
}
|
262 |
return agentHandler.getRoleNamesForAgent(agentEmailId);
|
| 259 |
|
263 |
}
|
| 260 |
public List<String> getPermissionsForRoleName(String roleName)
|
264 |
|
| 261 |
throws TException {
|
265 |
public List<String> getPermissionsForRoleName(String roleName)
|
| 262 |
return agentHandler.getPermissionsForRoleName(roleName);
|
266 |
throws TException {
|
| 263 |
}
|
267 |
return agentHandler.getPermissionsForRoleName(roleName);
|
| 264 |
|
268 |
}
|
| 265 |
public void changeAgentStatus(boolean status, String emailId)
|
269 |
|
| 266 |
throws TException {
|
270 |
public void changeAgentStatus(boolean status, String emailId)
|
| 267 |
agentHandler.changeAgentStatus(status, emailId);
|
271 |
throws TException {
|
| 268 |
}
|
272 |
agentHandler.changeAgentStatus(status, emailId);
|
| - |
|
273 |
}
|
| 269 |
|
274 |
|
| 270 |
public boolean isAlive() throws TException {
|
275 |
public boolean isAlive() throws TException {
|
| 271 |
try {
|
276 |
try {
|
| 272 |
return !agentHandler.getAgents(null).isEmpty();
|
277 |
return !agentHandler.getAgents(null).isEmpty();
|
| 273 |
} catch (Exception e) {
|
278 |
} catch (Exception e) {
|
| 274 |
log.error("Could not fetch agents", e);
|
279 |
log.error("Could not fetch agents", e);
|
| 275 |
}
|
280 |
}
|
| 276 |
|
281 |
|
| 277 |
return false;
|
282 |
return false;
|
| 278 |
}
|
283 |
}
|
| 279 |
|
284 |
|
| 280 |
public void closeSession() throws TException {
|
285 |
public void closeSession() throws TException {
|
| 281 |
}
|
286 |
}
|
| 282 |
|
287 |
|
| 283 |
public void insertAgent(Agent agent, List<String> role) throws TException {
|
288 |
public void insertAgent(Agent agent, List<String> role) throws TException {
|
| 284 |
agentHandler.insertAgent(in.shop2020.crm.domain.Agent.create(agent), role);
|
289 |
agentHandler.insertAgent(in.shop2020.crm.domain.Agent.create(agent), role);
|
| 285 |
}
|
290 |
}
|
| 286 |
|
291 |
|
| 287 |
public void unassignAgentTickets(int assigneeId) {
|
292 |
public void unassignAgentTickets(int assigneeId) {
|
| 288 |
ticketHandler.unassignAgentTickets(assigneeId);
|
293 |
ticketHandler.unassignAgentTickets(assigneeId);
|
| 289 |
}
|
294 |
}
|
| 290 |
|
295 |
|
| 291 |
public void changeAgentRole(long id, List<String> role) {
|
296 |
public void changeAgentRole(long id, List<String> role) {
|
| 292 |
agentHandler.changeAgentRole(id,role);
|
297 |
agentHandler.changeAgentRole(id,role);
|
| 293 |
}
|
298 |
}
|
| 294 |
|
299 |
|
| 295 |
public int getOpenTicketCountForAgent(long agentId) {
|
300 |
public int getOpenTicketCountForAgent(long agentId) {
|
| 296 |
return ticketHandler.getOpenTicketCountForAgent(agentId);
|
301 |
return ticketHandler.getOpenTicketCountForAgent(agentId);
|
| 297 |
}
|
302 |
}
|
| 298 |
|
303 |
|
| 299 |
public Map<String,Long> getOpenTicketsMap() {
|
304 |
public Map<String,Long> getOpenTicketsMap() {
|
| 300 |
return ticketHandler.getOpenTicketsMap();
|
305 |
return ticketHandler.getOpenTicketsMap();
|
| 301 |
}
|
306 |
}
|
| 302 |
|
307 |
|
| 303 |
|
308 |
|
| 304 |
public Map<String, String> getFedexReconciliationDataMap(
|
309 |
public Map<String, String> getFedexReconciliationDataMap(
|
| 305 |
List<Long> order_ids, String method_key) {
|
310 |
List<Long> order_ids, String method_key) {
|
| 306 |
log.info("Into Method of CRM Service to get Fedex Reconciliation Data");
|
311 |
log.info("Into Method of CRM Service to get Fedex Reconciliation Data");
|
| - |
|
312 |
Map<String, String> fedexReconciliationDataMap = new HashMap<String,String>();
|
| 307 |
Map<String, String> fedexReconciliationDataMap = null;
|
313 |
Map<String, String> fedexReconciliationDataMap1 = null;
|
| - |
|
314 |
Map<String, String> fedexReconciliationDataMap2 = null;
|
| 308 |
try{
|
315 |
try{
|
| 309 |
TransactionClient transactionServiceClient = new TransactionClient();
|
316 |
TransactionClient transactionServiceClient = new TransactionClient();
|
| 310 |
List<Order> orderList= transactionServiceClient.getClient().getOrderList(order_ids);
|
317 |
List<Order> orderList= transactionServiceClient.getClient().getOrderList(order_ids);
|
| - |
|
318 |
List<Order> orderListDelhi = new ArrayList<Order>();
|
| - |
|
319 |
List<Order> orderListMumbai = new ArrayList<Order>();
|
| - |
|
320 |
for(Order ord1: orderList){
|
| - |
|
321 |
Warehouse warehouse = null;
|
| - |
|
322 |
try{
|
| - |
|
323 |
InventoryClient isc = new InventoryClient();
|
| - |
|
324 |
warehouse = isc.getClient().getWarehouse(ord1.getWarehouse_id());
|
| - |
|
325 |
} catch(Exception e) {
|
| - |
|
326 |
log.error("Unable to get warehouse for id : " + ord1.getWarehouse_id(),e);
|
| - |
|
327 |
}
|
| - |
|
328 |
if(warehouse!=null){
|
| - |
|
329 |
if(WarehouseLocation.Mumbai==warehouse.getLogisticsLocation()){
|
| - |
|
330 |
orderListMumbai.add(ord1);
|
| - |
|
331 |
}
|
| - |
|
332 |
else{
|
| - |
|
333 |
orderListDelhi.add(ord1);
|
| - |
|
334 |
}
|
| - |
|
335 |
}
|
| - |
|
336 |
}
|
| - |
|
337 |
|
| - |
|
338 |
fedexTrackClientMumbai = new FedExTrackingService(WarehouseLocation.Mumbai);
|
| - |
|
339 |
fedexTrackClientDelhi = new FedExTrackingService(WarehouseLocation.Delhi);
|
| - |
|
340 |
|
| - |
|
341 |
if("delivered_orders".equalsIgnoreCase(method_key)){
|
| - |
|
342 |
fedexReconciliationDataMap1 = fedexTrackClientMumbai.readFedExDeliveredOrdersMap(orderListMumbai);
|
| - |
|
343 |
}
|
| 311 |
if("delivered_orders".equalsIgnoreCase(method_key)){
|
344 |
if("delivered_orders".equalsIgnoreCase(method_key)){
|
| 312 |
fedexReconciliationDataMap = fedexTrackClient.readFedExDeliveredOrdersMap(orderList);
|
345 |
fedexReconciliationDataMap2 = fedexTrackClientDelhi.readFedExDeliveredOrdersMap(orderListDelhi);
|
| - |
|
346 |
}
|
| - |
|
347 |
if("returned_orders".equalsIgnoreCase(method_key)){
|
| - |
|
348 |
fedexReconciliationDataMap1 = fedexTrackClientMumbai.readFedExReturnedOrdersMap(orderListMumbai);
|
| 313 |
}
|
349 |
}
|
| 314 |
if("returned_orders".equalsIgnoreCase(method_key)){
|
350 |
if("returned_orders".equalsIgnoreCase(method_key)){
|
| 315 |
fedexReconciliationDataMap = fedexTrackClient.readFedExReturnedOrdersMap(orderList);
|
351 |
fedexReconciliationDataMap2 = fedexTrackClientDelhi.readFedExReturnedOrdersMap(orderListDelhi);
|
| - |
|
352 |
}
|
| - |
|
353 |
if("undelivered_orders".equalsIgnoreCase(method_key)){
|
| - |
|
354 |
fedexReconciliationDataMap1 = fedexTrackClientMumbai.readFedExUnDeliveredOrdersMap(orderListMumbai);
|
| 316 |
}
|
355 |
}
|
| 317 |
if("undelivered_orders".equalsIgnoreCase(method_key)){
|
356 |
if("undelivered_orders".equalsIgnoreCase(method_key)){
|
| 318 |
fedexReconciliationDataMap = fedexTrackClient.readFedExUnDeliveredOrdersMap(orderList);
|
357 |
fedexReconciliationDataMap2 = fedexTrackClientDelhi.readFedExUnDeliveredOrdersMap(orderListDelhi);
|
| - |
|
358 |
}
|
| - |
|
359 |
if("first_delivery_attempted_orders".equalsIgnoreCase(method_key)){
|
| - |
|
360 |
fedexReconciliationDataMap1 = fedexTrackClientMumbai.readFedExFirstDeliveryAttemptedOrdersMap(orderListMumbai);
|
| 319 |
}
|
361 |
}
|
| 320 |
if("first_delivery_attempted_orders".equalsIgnoreCase(method_key)){
|
362 |
if("first_delivery_attempted_orders".equalsIgnoreCase(method_key)){
|
| 321 |
fedexReconciliationDataMap = fedexTrackClient.readFedExFirstDeliveryAttemptedOrdersMap(orderList);
|
363 |
fedexReconciliationDataMap2 = fedexTrackClientDelhi.readFedExFirstDeliveryAttemptedOrdersMap(orderListDelhi);
|
| 322 |
}
|
364 |
}
|
| 323 |
if("destination_city_reached_orders".equalsIgnoreCase(method_key)){
|
365 |
if("destination_city_reached_orders".equalsIgnoreCase(method_key)){
|
| - |
|
366 |
fedexReconciliationDataMap1 = fedexTrackClientMumbai.readFedExReachedDestinationOrdersMap(orderListMumbai);
|
| - |
|
367 |
}
|
| - |
|
368 |
if("destination_city_reached_orders".equalsIgnoreCase(method_key)){
|
| 324 |
fedexReconciliationDataMap = fedexTrackClient.readFedExReachedDestinationOrdersMap(orderList);
|
369 |
fedexReconciliationDataMap2 = fedexTrackClientDelhi.readFedExReachedDestinationOrdersMap(orderListDelhi);
|
| - |
|
370 |
}
|
| - |
|
371 |
if("picked_up_orders".equalsIgnoreCase(method_key) || "local_connection_orders".equalsIgnoreCase(method_key)){
|
| - |
|
372 |
fedexReconciliationDataMap1 = fedexTrackClientMumbai.readFedExPickupOrdersMap(orderListMumbai);
|
| 325 |
}
|
373 |
}
|
| 326 |
if("picked_up_orders".equalsIgnoreCase(method_key) || "local_connection_orders".equalsIgnoreCase(method_key)){
|
374 |
if("picked_up_orders".equalsIgnoreCase(method_key) || "local_connection_orders".equalsIgnoreCase(method_key)){
|
| 327 |
fedexReconciliationDataMap = fedexTrackClient.readFedExPickupOrdersMap(orderList);
|
375 |
fedexReconciliationDataMap2 = fedexTrackClientDelhi.readFedExPickupOrdersMap(orderListDelhi);
|
| 328 |
}
|
376 |
}
|
| - |
|
377 |
fedexReconciliationDataMap.putAll(fedexReconciliationDataMap1);
|
| - |
|
378 |
fedexReconciliationDataMap.putAll(fedexReconciliationDataMap2);
|
| 329 |
// TODO Auto-generated method stub
|
379 |
// TODO Auto-generated method stub
|
| 330 |
}
|
380 |
}
|
| 331 |
catch (TTransportException e) {
|
381 |
catch (TTransportException e) {
|
| 332 |
log.error("Unable to create thrift Client from fedex reconciliation method.... ", e);
|
382 |
log.error("Unable to create thrift Client from fedex reconciliation method.... ", e);
|
| 333 |
} catch (TException e) {
|
383 |
} catch (TException e) {
|
| 334 |
log.error("Unable to get thrift Client from fedex reconciliation method.... ", e);
|
384 |
log.error("Unable to get thrift Client from fedex reconciliation method.... ", e);
|
| 335 |
}
|
385 |
}
|
| 336 |
log.info("Into Method of CRM Service to get Fedex Reconciliation Data....and got it successfully");
|
386 |
log.info("Into Method of CRM Service to get Fedex Reconciliation Data....and got it successfully");
|
| 337 |
return fedexReconciliationDataMap;
|
387 |
return fedexReconciliationDataMap;
|
| 338 |
}
|
388 |
}
|
| 339 |
}
|
389 |
}
|