YeWeiHuiController.java 10 KB

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