YeWeiHuiController.java 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. package com.bofeng.wx.controller;
  2. import com.bofeng.dao.RbMapper;
  3. import com.bofeng.entity.*;
  4. import com.bofeng.excel.ExcelUtils;
  5. import com.bofeng.service.HomeService;
  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.Lists;
  11. import com.google.common.collect.Maps;
  12. import com.yvan.Model;
  13. import com.yvan.ModelOps;
  14. import com.yvan.mvc.Pd;
  15. import com.yvan.platform.Conv;
  16. import com.yvan.platform.JsonWapper;
  17. import com.yvan.platform.YvanUtil;
  18. import io.swagger.annotations.ApiOperation;
  19. import lombok.SneakyThrows;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.ui.ModelMap;
  22. import org.springframework.web.bind.annotation.GetMapping;
  23. import org.springframework.web.bind.annotation.PostMapping;
  24. import org.springframework.web.bind.annotation.RequestParam;
  25. import org.springframework.web.bind.annotation.RestController;
  26. import org.springframework.web.servlet.ModelAndView;
  27. import javax.servlet.http.HttpServletResponse;
  28. import java.util.List;
  29. import java.util.Map;
  30. @RestController
  31. public class YeWeiHuiController {
  32. @Autowired
  33. private QzTaskService qzTaskService;
  34. @Autowired
  35. private RbService rbService;
  36. @Autowired
  37. private QzTaskReplyService qzTaskReplyService;
  38. @Autowired
  39. private HomeService homeService;
  40. @Autowired
  41. private RbMapper rbMapper;
  42. @GetMapping("/yeweihui/home.html")
  43. public ModelAndView yeweihui(ModelMap model,@RequestParam(value = "userId") Long userId) {
  44. // List<QzTask> taskList = qzTaskService.selectAll(1225321682867105793L);
  45. // List<sysUptownUnit> rbList = rbService.selectAll(1225321682867105793L);
  46. List<QzTask> taskList = qzTaskService.selectAll(userId);
  47. List<sysUptownUnit> rbList = rbService.selectAll(userId);
  48. model.put("taskList", YvanUtil.toJsonPretty(taskList));
  49. model.put("rbList", YvanUtil.toJsonPretty(rbList));
  50. model.put("user_id", "\""+userId+"\"");
  51. return new ModelAndView("/yeweihui/home.ftl", model);
  52. }
  53. @GetMapping("/yeweihui/qiuzhuDetail.html")
  54. public ModelAndView qiuzhudetail(@Pd(name = "taskId") Long taskId,@Pd(name = "userId") Long userId, ModelMap model) throws JsonProcessingException {
  55. QzTask task = qzTaskService.queryByTaskId(taskId);
  56. // A业委会,B居委会,C物业,D志愿者
  57. StringBuffer target = new StringBuffer();
  58. if (task.getTaskTarget().equals("A")) {
  59. target.append("业委会");
  60. }
  61. else if (task.getTaskTarget().equals("B")) {
  62. if (target.length() > 0) {
  63. target.append("、居委会");
  64. }
  65. else {
  66. target.append("居委会");
  67. }
  68. }
  69. else if (task.getTaskTarget().equals("C")) {
  70. if (target.length() > 0) {
  71. target.append("、物业");
  72. }
  73. else {
  74. target.append("物业");
  75. }
  76. }
  77. else if (task.getTaskTarget().equals("D")) {
  78. if (target.length() > 0) {
  79. target.append("、志愿者");
  80. }
  81. else {
  82. target.append("志愿者");
  83. }
  84. }
  85. task.setTaskTarget(target.toString());
  86. model.put("taskJson", new JsonWapper(task));
  87. model.put("task", task);
  88. model.put("userId", "\""+userId+"\"");
  89. return new ModelAndView("/yeweihui/qiuzhuDetail.ftl", model);
  90. }
  91. @PostMapping("/yeweihui/qiuzhu/queryTasksByStatus.json")
  92. public Model queryTasksByStatus(@Pd(name = "status") Integer status) {
  93. List<QzTask> taskList = qzTaskService.queryQzTaskByStatus(status);
  94. return Model.newSuccess(taskList);
  95. }
  96. @PostMapping("/yeweihui/qiuzhu/reply/add.json")
  97. public ModelOps replyQiuzhuInsert(QzTaskReply qzTaskReply) {
  98. Integer success = qzTaskReplyService.insertQzTaskReply(qzTaskReply);
  99. if (success > 0) {
  100. return ModelOps.newSuccess();
  101. }
  102. else {
  103. return ModelOps.newFail("操作失败");
  104. }
  105. }
  106. @PostMapping("/yeweihui/qiuzhu/reply/querybytaskid.json")
  107. public Model replyQiuzhuQueryByTaskId(@Pd(name = "taskId") Long taskId) {
  108. List<QzTaskReply> reply = qzTaskReplyService.queryQzTaskReplyByTaskId(taskId);
  109. return Model.newSuccess(reply);
  110. }
  111. @PostMapping("/yeweihui/qiuzhu/list.json")
  112. public Model queryByHouseNumber(String houseNumber, @Pd(name = "status") Integer status) {
  113. if (houseNumber.length() <= 0) {
  114. return Model.newSuccess(qzTaskService.queryQzTaskByStatus(status));
  115. }
  116. List<QzTask> list = qzTaskService.queryByHouseNumber(houseNumber, status);
  117. return Model.newSuccess(list);
  118. }
  119. @GetMapping("/yeweihui/ribao.html")
  120. public ModelAndView yeweihuiRibao(ModelMap model) {
  121. // List<QzTask> taskList = qzTaskService.selectAll();
  122. //
  123. // model.put("taskList", YvanUtil.toJsonPretty(taskList));
  124. return new ModelAndView("/yeweihui/ribao.ftl", model);
  125. }
  126. @GetMapping("/yeweihui/ribaoDy")
  127. public Model<List<SysUptownHouse>> yeweihuiRibaoDy(Long str) {
  128. // String[] split = str.split("&");
  129. List<SysUptownHouse> rbList = rbService.selectXq(str);
  130. return Model.newSuccess(rbList);
  131. }
  132. @GetMapping("/yeweihui/ribaoXq.html")
  133. public ModelAndView yeweihuiRibaoYcXq(ModelMap model) {
  134. Map<String, Object> queryParam = Maps.newLinkedHashMap();
  135. queryParam.put("userId", "12345677");
  136. queryParam.put("statistics", "M");
  137. return new ModelAndView("/yeweihui/ribaoXq.ftl", model);
  138. }
  139. @GetMapping("/yeweihui/ribaoDyYcXq")
  140. public Model<List<MsSuspected>> yeweihuiRibaoYcXq(Long houseId) {
  141. List<MsSuspected> rbList = rbService.selectYcXq(houseId);
  142. return Model.newSuccess(rbList);
  143. }
  144. @GetMapping("/yeweihui/ribaohuiz.html")
  145. public ModelAndView yeweihuiRibaohuiz(ModelMap model) {
  146. return new ModelAndView("/yeweihui/ribaohuiz.ftl", model);
  147. }
  148. @GetMapping("/yeweihui/ribaohuiz")
  149. public Model<Map<String, Object>> yeweihuiRibaohuiz(/*Long userCreate,*/String reportDate) {
  150. Long userCreate = 1226159827797225474L;
  151. List<Uptown> uptowns = rbMapper.selectUptown(userCreate);
  152. if (uptowns!=null && uptowns.size()>0) {
  153. Long upId = uptowns.get(0).getUptownId();
  154. Map<String, Integer> map1 = rbMapper.selecthuiz(upId,reportDate);
  155. Map<String, Integer> map2 = rbMapper.selectyicahng(upId,reportDate);
  156. Map<String, Object> reMap = Maps.newHashMap();
  157. reMap.put("uptownName", uptowns.get(0).getUptownName());
  158. List<Integer> nums = Lists.newArrayList();
  159. nums.add(Conv.NI(map1.get("houseCount")));
  160. nums.add(Conv.NI(map1.get("reportCount")));
  161. nums.add(Conv.NI(map2.get("yichangCount")));
  162. nums.add(Conv.NI(map1.get("safetyNum")));
  163. nums.add(Conv.NI(map1.get("suspectedNum")));
  164. reMap.put("nums", nums);
  165. return Model.newSuccess(reMap);
  166. }
  167. return Model.newFail("没有数据");
  168. }
  169. @ApiOperation("导出家庭上报明细")
  170. @GetMapping("/yeweihui/exportRiBao")
  171. @SneakyThrows
  172. public void exportRiBao(@Pd(name = "userId") Long userId,
  173. @Pd(name = "date") String date,
  174. HttpServletResponse resp) {
  175. List<Uptown> uptowns = rbMapper.selectUptown(userId);
  176. if (uptowns!=null && uptowns.size()>0) {
  177. Long upId = uptowns.get(0).getUptownId();
  178. String fileName = uptowns.get(0).getUptownName();
  179. fileName += "上报信息-";
  180. fileName += date;
  181. List<ExcelRiBao> list = rbMapper.selectExcelRiBao(upId,date);
  182. ExcelUtils.writeSheet(ExcelRiBao.class, list).export(resp, fileName);
  183. }
  184. }
  185. }