PageRenderTime 45ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/Server/tomcat/WEB-INF/src/com/drhelper/android/service/CheckTableService.java

https://github.com/weiganyi/dr-helper
Java | 60 lines | 38 code | 11 blank | 11 comment | 3 complexity | f41d9f17912401070fdb009544e0a7f9 MD5 | raw file
  1. package com.drhelper.android.service;
  2. import java.util.ArrayList;
  3. import java.util.Iterator;
  4. import javax.servlet.http.HttpSession;
  5. import com.alibaba.fastjson.JSON;
  6. import com.drhelper.android.bean.com.EmptyTable;
  7. import com.drhelper.android.bean.com.EmptyTableList;
  8. import com.drhelper.common.db.DBManager;
  9. import com.drhelper.common.entity.Table;
  10. public class CheckTableService extends Service {
  11. public String doAction(HttpSession session, String reqBody) {
  12. EmptyTableList respEmptyTableList = null;
  13. String respBody = null;
  14. respEmptyTableList = new EmptyTableList();
  15. //get the empty table list
  16. DBManager db = new DBManager();
  17. ArrayList<Table> tableList = db.getEmptyTableList();
  18. if (tableList == null) {
  19. respEmptyTableList.setResult(false);
  20. respBody = JSON.toJSONString(respEmptyTableList);
  21. return respBody;
  22. }
  23. respEmptyTableList.setList(new ArrayList<EmptyTable>());
  24. ArrayList<EmptyTable> list = respEmptyTableList.getList();
  25. //create the resp object
  26. Iterator<Table> iterator = tableList.listIterator();
  27. Table table = null;
  28. EmptyTable emptyTable = null;
  29. while (iterator.hasNext()) {
  30. table = iterator.next();
  31. emptyTable = new EmptyTable();
  32. emptyTable.setTableNum(table.getTable_num());
  33. emptyTable.setTableSeatNum(table.getTable_seat_num());
  34. list.add(emptyTable);
  35. }
  36. respEmptyTableList.setResult(true);
  37. //test notice push
  38. /*
  39. if (NoticeServerListener.worker != null) {
  40. NoticeServerListener.worker.publishEvent(
  41. NoticeServer.emptyTableEvent,
  42. (String)session.getAttribute("id"));
  43. }
  44. */
  45. //serialize the object
  46. respBody = JSON.toJSONString(respEmptyTableList);
  47. return respBody;
  48. }
  49. }