YeWeiHuiController.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package com.bofeng.wx.controller;
  2. import com.bofeng.entity.QzTask;
  3. import com.bofeng.entity.QzTaskReply;
  4. import com.bofeng.entity.SysUptownHouse;
  5. import com.bofeng.entity.sysUptownUnit;
  6. import com.bofeng.service.QzTaskReplyService;
  7. import com.bofeng.service.QzTaskService;
  8. import com.bofeng.service.RbService;
  9. import com.fasterxml.jackson.core.JsonProcessingException;
  10. import com.google.common.collect.Maps;
  11. import com.yvan.Model;
  12. import com.yvan.ModelOps;
  13. import com.yvan.mvc.Pd;
  14. import com.yvan.platform.JsonWapper;
  15. import com.yvan.platform.YvanUtil;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.ui.ModelMap;
  18. import org.springframework.web.bind.annotation.GetMapping;
  19. import org.springframework.web.bind.annotation.PostMapping;
  20. import org.springframework.web.bind.annotation.RequestParam;
  21. import org.springframework.web.bind.annotation.RestController;
  22. import org.springframework.web.servlet.ModelAndView;
  23. import java.util.List;
  24. import java.util.Map;
  25. @RestController
  26. public class YeWeiHuiController {
  27. @Autowired
  28. private QzTaskService qzTaskService;
  29. @Autowired
  30. private RbService rbService;
  31. @Autowired
  32. private QzTaskReplyService qzTaskReplyService;
  33. @GetMapping("/yeweihui/home.html")
  34. public ModelAndView yeweihui(ModelMap model,@RequestParam(value = "userId", required = false,defaultValue = "0") Long userId) {
  35. Map<String, Object> queryParam = Maps.newLinkedHashMap();
  36. queryParam.put("userId", "12345677");
  37. queryParam.put("statistics", "M");
  38. List<QzTask> taskList = qzTaskService.selectAll();
  39. // List<sysUptownUnit> rbList = rbService.selectAll();
  40. model.put("taskList", YvanUtil.toJsonPretty(taskList));
  41. // model.put("rbList", YvanUtil.toJsonPretty(rbList));
  42. return new ModelAndView("/yeweihui/home.ftl", model);
  43. }
  44. @GetMapping("/yeweihui/qiuzhuDetail.html")
  45. public ModelAndView qiuzhudetail(@Pd(name = "taskId") Long taskId, ModelMap model) throws JsonProcessingException {
  46. QzTask task = qzTaskService.queryByTaskId(taskId);
  47. // A业委会,B居委会,C物业,D志愿者
  48. StringBuffer target = new StringBuffer();
  49. if (task.getTaskTarget().equals("A")) {
  50. target.append("业委会");
  51. }
  52. else if (task.getTaskTarget().equals("B")) {
  53. if (target.length() > 0) {
  54. target.append("、居委会");
  55. }
  56. else {
  57. target.append("居委会");
  58. }
  59. }
  60. else if (task.getTaskTarget().equals("C")) {
  61. if (target.length() > 0) {
  62. target.append("、物业");
  63. }
  64. else {
  65. target.append("物业");
  66. }
  67. }
  68. else if (task.getTaskTarget().equals("D")) {
  69. if (target.length() > 0) {
  70. target.append("、志愿者");
  71. }
  72. else {
  73. target.append("志愿者");
  74. }
  75. }
  76. task.setTaskTarget(target.toString());
  77. model.put("taskJson", new JsonWapper(task));
  78. model.put("task", task);
  79. return new ModelAndView("/yeweihui/qiuzhuDetail.ftl", model);
  80. }
  81. @PostMapping("/yeweihui/qiuzhu/queryTasksByStatus.json")
  82. public Model queryTasksByStatus(@Pd(name = "status") Integer status) {
  83. List<QzTask> taskList = qzTaskService.queryQzTask(status);
  84. return Model.newSuccess(taskList);
  85. }
  86. @PostMapping("/yeweihui/qiuzhu/reply/add.json")
  87. public ModelOps replyQiuzhuInsert(QzTaskReply qzTaskReply) {
  88. Integer success = qzTaskReplyService.insertQzTaskReply(qzTaskReply);
  89. if (success > 0) {
  90. return ModelOps.newSuccess();
  91. }
  92. else {
  93. return ModelOps.newFail("操作失败");
  94. }
  95. }
  96. @PostMapping("/yeweihui/qiuzhu/reply/querybytaskid.json")
  97. public Model replyQiuzhuQueryByTaskId(@Pd(name = "taskId") Long taskId) {
  98. List<QzTaskReply> reply = qzTaskReplyService.queryQzTaskReplyByTaskId(taskId);
  99. return Model.newSuccess(reply);
  100. }
  101. @PostMapping("/yeweihui/qiuzhu/list.json")
  102. public Model queryByHouseNumber(@Pd(name = "houseNumber") String houseNumber, @Pd(name = "status") Integer status) {
  103. List<QzTask> list = qzTaskService.queryByHouseNumber(houseNumber, status);
  104. return Model.newSuccess(list);
  105. }
  106. @GetMapping("/yeweihui/ribao.html")
  107. public ModelAndView yeweihuiRibao(ModelMap model) {
  108. // List<QzTask> taskList = qzTaskService.selectAll();
  109. //
  110. // model.put("taskList", YvanUtil.toJsonPretty(taskList));
  111. return new ModelAndView("/yeweihui/ribao.ftl", model);
  112. }
  113. @GetMapping("/yeweihui/ribaoDy")
  114. public Model<List<SysUptownHouse>> yeweihuiRibaoDy(String str) {
  115. String[] split = str.split("&");
  116. List<SysUptownHouse> rbList = rbService.selectXq(split[0],split[1]);
  117. return Model.newSuccess(rbList);
  118. }
  119. }