PageRenderTime 67ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/com/blickx/controller/ComplaintsController.java

https://bitbucket.org/Venkata_blickx/mycableproduction
Java | 270 lines | 166 code | 73 blank | 31 comment | 6 complexity | 4a460c9b8161b26d416336da9cea82c4 MD5 | raw file
  1. package com.blickx.controller;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import org.apache.log4j.Logger;
  7. import org.springframework.beans.BeanUtils;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.ModelAttribute;
  10. import org.springframework.web.bind.annotation.PathVariable;
  11. import org.springframework.web.bind.annotation.RequestBody;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RequestMethod;
  14. import org.springframework.web.bind.annotation.ResponseBody;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import com.blickx.dao.UserDao;
  17. import com.blickx.domain.ComplaintEntity;
  18. //import com.blickx.mycable.beme.dto.ComplaintBemeInputDTO;
  19. import com.blickx.output.GetComplaintList;
  20. import com.blickx.searchEntities.AssignComplaintSearch;
  21. import com.blickx.searchEntities.CloseComplaint;
  22. import com.blickx.searchEntities.GetComplaint;
  23. import com.blickx.searchEntities.SearchByDateEntity;
  24. import com.blickx.services.ComplaintService;
  25. import com.blickx.services.CustomerService;
  26. import com.blickx.services.EmployeeService;
  27. import com.blickx.to.AddComplaintOfflineResponse;
  28. import com.blickx.to.ComplaintRatingObject;
  29. import com.blickx.to.ComplaintStatusTo;
  30. import com.blickx.to.ComplaintSummaryTo;
  31. import com.blickx.to.GetOpenClosedComplaintTo;
  32. import com.blickx.to.input.ComplaintInputTo;
  33. import com.blickx.utill.CommonUtils;
  34. import com.blickx.wrapper.CloseComplaintsWrapper;
  35. import com.blickx.wrapper.ComplaintWrapper;
  36. /**
  37. * Complaints Controller
  38. *
  39. */
  40. @RestController
  41. @RequestMapping("/service/{client_id}/complaint")
  42. public class ComplaintsController {
  43. @Autowired
  44. ComplaintService complaintService;
  45. @Autowired
  46. EmployeeService eService;
  47. @Autowired
  48. CustomerService cService;
  49. @Autowired
  50. UserDao udao;
  51. private Logger logger = Logger.getLogger(ComplaintsController.class);
  52. /*public static String client_id ;
  53. static{
  54. @PathVariable
  55. }
  56. //static String client_id = getClient_id()
  57. */
  58. /*@RequestMapping(value="/addComplaintBeme",method = {RequestMethod.POST,RequestMethod.GET}, headers="Accept=application/json" )
  59. public String addComplaintBeme(@PathVariable String client_id,
  60. @RequestBody ComplaintBemeInputDTO complaintTo) {
  61. logger.info("************* addComplaintDesktop complaint Input************" + complaintTo);
  62. complaintTo.setClient_id(client_id);
  63. return complaintService.addComplaintBeeMe(complaintTo);
  64. }*/
  65. @RequestMapping(value="/addComplaintDesktop",method = {RequestMethod.POST,RequestMethod.GET}, headers="Accept=application/json" )
  66. public String addComplaintDesktop(@PathVariable String client_id,
  67. @RequestBody ComplaintInputTo complaintTo) {
  68. logger.info("************* addComplaintDesktop complaint Input************" + complaintTo);
  69. complaintTo.setClient_id(client_id);
  70. return complaintService.addComplaintDesktop(complaintTo);
  71. }
  72. @RequestMapping(value="/addComplaint",method = {RequestMethod.POST, RequestMethod.GET}, headers="Accept=application/json" )
  73. public String addComplaint(@PathVariable String client_id,
  74. @ModelAttribute("complaint") ComplaintInputTo complaintTo) {
  75. logger.info("************* addComplaint complaint Input************" + complaintTo);
  76. ComplaintEntity complaint = new ComplaintEntity();
  77. BeanUtils.copyProperties(complaintTo, complaint);
  78. //complaint.setCustomer_id(cService.getCustomer_id(complaintTo.getCustomer_uid()));
  79. if(CommonUtils.exists(complaintTo.getEmployee_uid()))
  80. complaint.setEmployee_id(eService.getEmployee_id(complaintTo.getEmployee_uid()));
  81. if(CommonUtils.exists(complaintTo.getIme_number()))
  82. complaint.setEmployee_id(udao.getEmployeeIDusingIme(complaintTo.getIme_number()));
  83. complaint.setClient_id(client_id);
  84. return complaintService.addComplaint(complaint);
  85. }
  86. @RequestMapping(value="/addComplaintOffline",method = {RequestMethod.POST,RequestMethod.GET}, headers="Accept=application/json", consumes = "application/json", produces = "application/json" )
  87. public @ResponseBody List<AddComplaintOfflineResponse> addComplaints(
  88. @PathVariable String client_id,
  89. @RequestBody ComplaintWrapper complaintsTo) {
  90. logger.info("************* addComplaint complaint Input************" + complaintsTo);
  91. List<AddComplaintOfflineResponse> result = new ArrayList<AddComplaintOfflineResponse>();
  92. for(ComplaintInputTo complaintTo:complaintsTo.getComplaintsTo()){
  93. AddComplaintOfflineResponse addComplaintResponse = new AddComplaintOfflineResponse();
  94. ComplaintEntity complaint = new ComplaintEntity();
  95. BeanUtils.copyProperties(complaintTo, complaint);
  96. complaint.setClient_id(client_id);
  97. //String customer_id = cService.getCustomer_id(complaintTo.getCustomer_uid());
  98. //complaint.setCustomer_id(customer_id);
  99. //complaint.setEmployee_id(eService.getEmployee_id(complaintTo.getEmployee_uid()));
  100. if(CommonUtils.exists(complaintTo.getEmployee_uid()))
  101. complaint.setEmployee_id(eService.getEmployee_id(complaintTo.getEmployee_uid()));
  102. if(CommonUtils.exists(complaintTo.getIme_number()))
  103. complaint.setEmployee_id(udao.getEmployeeIDusingIme(complaintTo.getIme_number()));
  104. String res = complaintService.addComplaint(complaint);
  105. //addComplaintResponse.setCustomer_uid(complaintTo.getCustomer_uid());
  106. addComplaintResponse.setCustomer_id(complaint.getCustomer_id());
  107. addComplaintResponse.setResponse(res);
  108. result.add(addComplaintResponse);
  109. }
  110. return result;
  111. }
  112. @SuppressWarnings("unchecked")
  113. @RequestMapping(value="/getComplaint", method = {RequestMethod.GET, RequestMethod.POST}, headers="Accept=application/json" )
  114. public ComplaintEntity getComplaint(
  115. @PathVariable String client_id,
  116. @RequestBody GetComplaint getComplaint) {
  117. getComplaint.setClient_id(client_id);
  118. return complaintService.getComplaint(getComplaint);
  119. }
  120. @RequestMapping(value="/getOpenOrClosedComplaint",method = RequestMethod.GET, headers="Accept=application/json" )
  121. public List<GetOpenClosedComplaintTo> getOpenOrClosedComplaint(@PathVariable String client_id, @ModelAttribute("type") String type) {
  122. return complaintService.getOpenOrClosedComplaints(client_id, type);
  123. }
  124. @RequestMapping(value="/getOpenOrClosedComplaintByDate",method = RequestMethod.GET, headers="Accept=application/json" )
  125. public List<GetOpenClosedComplaintTo> getOpenOrClosedComplaint(
  126. @PathVariable String client_id,
  127. @ModelAttribute("SearchByDateEntity")SearchByDateEntity dates) {
  128. dates.setClient_id(client_id);
  129. return complaintService.getOpenOrClosedComplaintsByDate(dates);
  130. }
  131. @RequestMapping(value = "/updateComplaint", method = RequestMethod.GET, headers = "Accept=application/json")
  132. public @ResponseBody Map<String, String> getComplaintById(
  133. @ModelAttribute ComplaintEntity complaint) {
  134. return complaintService.updateComplaint(complaint);
  135. }
  136. @RequestMapping(value="/getComplaintStatusDetails",method = RequestMethod.GET, headers="Accept=application/json" )
  137. public @ResponseBody List<Object> getComplaintStatus(@PathVariable("client_id") String client_id) {
  138. List<Object> resultToAngular = new ArrayList<Object>();
  139. ComplaintStatusTo status = complaintService.getComplaintStatus(client_id);
  140. resultToAngular.add(new Object[]{"Task","Hours Per Day"});
  141. /*resultToAngular.add(new Object[]{"total",status.getTotal()});
  142. resultToAngular.add(new Object[]{"pending",status.getPending()});
  143. resultToAngular.add(new Object[]{"collected",status.getCollected()});
  144. */
  145. resultToAngular.add(new Object[]{"Open",status.getOpen()});
  146. resultToAngular.add(new Object[]{"Assigned", status.getAssign()});
  147. resultToAngular.add(new Object[]{"Resolved", status.getResolve()});
  148. List<Object> result = new ArrayList<Object>();
  149. result.add(resultToAngular);
  150. result.add(new Object[]{"total",(status.getOpen().intValue() + status.getAssign().intValue())});
  151. return result;
  152. }
  153. @RequestMapping(value="/getComplaintSummaryOpen",method = RequestMethod.GET, headers="Accept=application/json" )
  154. public @ResponseBody List<ComplaintSummaryTo> getComplaintSummaryOpen(@PathVariable("client_id") String client_id) {
  155. return complaintService.getComplaintSummaryOpen(client_id);
  156. }
  157. @RequestMapping(value="/assignComplaint",method = RequestMethod.POST, headers="Accept=application/json" )
  158. public @ResponseBody int makeAssign(@RequestBody AssignComplaintSearch assign) {
  159. return complaintService.makeAssign(assign);
  160. }
  161. @RequestMapping(value="/closeComplaint",method = RequestMethod.POST, headers="Accept=application/json" )
  162. public @ResponseBody int getComplaintSummaryOpen(@RequestBody CloseComplaint closeComplaint) {
  163. return complaintService.closeComplaint(closeComplaint);
  164. }
  165. @RequestMapping(value="/resolveComplaints",method = RequestMethod.POST, headers="Accept=application/json" )
  166. public @ResponseBody Map<String, String> resolveComplaints(@RequestBody CloseComplaintsWrapper closeComplaintsWrap) {
  167. Map<String, String> response = new HashMap<String, String>();
  168. logger.info("resolveComplaint Controller INput:" + closeComplaintsWrap);
  169. for(CloseComplaint closeComplaint : closeComplaintsWrap.getResloveComplaints()) {
  170. Integer res = complaintService.resolveComplaint(closeComplaint);
  171. logger.info("resolveComplaint Controller Individual Complaint :" + closeComplaint);
  172. response.put("status", res.toString());
  173. response.put("complaint_id", closeComplaint.getComplaint_id());
  174. }
  175. return response;
  176. }
  177. @RequestMapping(value="/complaintRating",method = RequestMethod.GET, headers="Accept=application/json" )
  178. public @ResponseBody ComplaintRatingObject getComplaintRating(@PathVariable String client_id) {
  179. return complaintService.getComplaintRating(client_id);
  180. }
  181. @RequestMapping(value="/getC_ids",method = RequestMethod.GET, headers="Accept=application/json" )
  182. public @ResponseBody List<String> getC_ids(@PathVariable String client_id) {
  183. return complaintService.getC_ids(client_id);
  184. }
  185. // Android Service
  186. @RequestMapping(value="/getComplaintsList",method = RequestMethod.POST, headers="Accept=application/json" )
  187. public @ResponseBody List<GetComplaintList> GetComplaintList(@PathVariable String client_id, @RequestBody Map<String, String> input) {
  188. return complaintService.GetComplaintList(client_id, input);
  189. }
  190. @RequestMapping(value="/getUpdatedComplaintsList",method = RequestMethod.POST, headers="Accept=application/json" )
  191. public @ResponseBody List<GetComplaintList> GetUpdatedComplaintList(@PathVariable String client_id, @RequestBody Map<String, String> input) {
  192. return complaintService.GetUpdatedComplaintList(client_id, input);
  193. }
  194. }