RiBaoYwhController.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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.*;
  7. import com.fasterxml.jackson.core.JsonProcessingException;
  8. import com.google.common.collect.Lists;
  9. import com.google.common.collect.Maps;
  10. import com.yvan.Model;
  11. import com.yvan.ModelOps;
  12. import com.yvan.PageDb;
  13. import com.yvan.mvc.Pd;
  14. import com.yvan.platform.Conv;
  15. import com.yvan.platform.JsonWapper;
  16. import com.yvan.platform.YvanUtil;
  17. import com.yvan.springmvc.HttpParameterParser;
  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 RiBaoYwhController {
  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 JmTuangouService jmTuangouService;
  42. @Autowired
  43. private UptownMapper uptownMapper;
  44. @Autowired
  45. private RbMapper rbMapper;
  46. @Autowired
  47. private RiBaoService riBaoService;
  48. // 查询业委会日报首页小区及统计数据
  49. @GetMapping("/ywh/getRibaoYwh")
  50. public Model<UptownUnit> getRibaoYwh(@Pd(name = "userId") Long userId) {
  51. return Model.newSuccess(riBaoService.getRibaoYwh(userId));
  52. }
  53. // 查询业委会日报首页小区对应栋列表
  54. @GetMapping("/ywh/queryRibaoYwhDongList")
  55. public Model<List<UptownUnit>> queryRibaoYwhDongList(@Pd(name = "uptownId") Long uptownId) {
  56. List<UptownUnit> listSuspected = riBaoService.queryRibaoYwhDongList(uptownId);
  57. return Model.newSuccess(listSuspected);
  58. }
  59. // 查询业委会日报某一栋小区单元数据 根据queryRibaoYwhDongList获取栋数据作为参数传递给此接口
  60. @GetMapping("/ywh/queryDanYuanList")
  61. public Model<List<UptownUnit>> queryDanYuanList(@Pd(name = "uptownId") Long uptownId, @Pd(name = "ridgepole") Long ridgepole) {
  62. List<UptownUnit> listSuspected = riBaoService.queryDanYuanList(uptownId, ridgepole);
  63. return Model.newSuccess(listSuspected);
  64. }
  65. // 查询业委会日报某一栋门牌数据 根据queryDanYuanList获取单元数据作为参数传递给此接口
  66. // uptownId:小区id; ridgepole:栋;unitId:单元id
  67. @GetMapping("/ywh/queryMenPaiList")
  68. public Model<List<UptownUnit>> queryMenPaiList(@Pd(name = "uptownId") Long uptownId, @Pd(name = "ridgepole") Long ridgepole, @Pd(name = "unitId") Long unitId) {
  69. List<UptownUnit> listSuspected = riBaoService.queryMenPaiList(uptownId, ridgepole, unitId);
  70. return Model.newSuccess(listSuspected);
  71. }
  72. @GetMapping("/ywh/home.html")
  73. public ModelAndView yeweihui(ModelMap model, @RequestParam(value = "userId") Long userId, @RequestParam(value = "show", required = false, defaultValue = "-") String show) {
  74. // List<QzTask> taskList = qzTaskService.selectAll(1225321682867105793L);
  75. // List<sysUptownUnit> rbList = rbService.selectAll(1225321682867105793L);
  76. List<QzTask> taskList = qzTaskService.selectAll(userId);
  77. List<sysUptownUnit> rbList = rbService.selectAll(userId);
  78. model.put("taskList", YvanUtil.toJsonPretty(taskList));
  79. model.put("rbList", YvanUtil.toJsonPretty(rbList));
  80. model.put("user_id", "\"" + userId + "\"");
  81. model.put("show", "\"" + show + "\"");
  82. return new ModelAndView("/yeweihui/home.ftl", model);
  83. }
  84. @GetMapping("/ywh/qiuzhuDetail.html")
  85. public ModelAndView qiuzhudetail(@Pd(name = "taskId") Long taskId, @Pd(name = "userId") Long userId, ModelMap model) throws JsonProcessingException {
  86. QzTask task = qzTaskService.queryByTaskId(taskId);
  87. // A业委会,B居委会,C物业,D志愿者
  88. StringBuffer target = new StringBuffer();
  89. if (task.getTaskTarget().equals("A")) {
  90. target.append("业委会");
  91. } else if (task.getTaskTarget().equals("B")) {
  92. if (target.length() > 0) {
  93. target.append("、居委会");
  94. } else {
  95. target.append("居委会");
  96. }
  97. } else if (task.getTaskTarget().equals("C")) {
  98. if (target.length() > 0) {
  99. target.append("、物业");
  100. } else {
  101. target.append("物业");
  102. }
  103. } else if (task.getTaskTarget().equals("D")) {
  104. if (target.length() > 0) {
  105. target.append("、志愿者");
  106. } else {
  107. target.append("志愿者");
  108. }
  109. }
  110. task.setTaskTarget(target.toString());
  111. model.put("taskJson", new JsonWapper(task));
  112. model.put("task", task);
  113. model.put("userId", "\"" + userId + "\"");
  114. return new ModelAndView("/yeweihui/qiuzhuDetail.ftl", model);
  115. }
  116. @PostMapping("/ywh/qiuzhu/queryTasksByStatus.json")
  117. public Model queryTasksByStatus(@Pd(name = "status") Integer status) {
  118. List<QzTask> taskList = qzTaskService.queryQzTaskByStatus(status);
  119. return Model.newSuccess(taskList);
  120. }
  121. @PostMapping("/ywh/qiuzhu/reply/add.json")
  122. public ModelOps replyQiuzhuInsert(QzTaskReply qzTaskReply) {
  123. Integer success = qzTaskReplyService.insertQzTaskReply(qzTaskReply);
  124. if (success > 0) {
  125. return ModelOps.newSuccess();
  126. } else {
  127. return ModelOps.newFail("操作失败");
  128. }
  129. }
  130. @PostMapping("/ywh/qiuzhu/reply/querybytaskid.json")
  131. public Model replyQiuzhuQueryByTaskId(@Pd(name = "taskId") Long taskId) {
  132. List<QzTaskReply> reply = qzTaskReplyService.queryQzTaskReplyByTaskId(taskId);
  133. return Model.newSuccess(reply);
  134. }
  135. @PostMapping("/ywh/qiuzhu/list.json")
  136. public Model queryByHouseNumber(String houseNumber, @Pd(name = "status") Integer status) {
  137. if (houseNumber.length() <= 0) {
  138. return Model.newSuccess(qzTaskService.queryQzTaskByStatus(status));
  139. }
  140. List<QzTask> list = qzTaskService.queryByHouseNumber(houseNumber, status);
  141. return Model.newSuccess(list);
  142. }
  143. @GetMapping("/ywh/ribao.html")
  144. public ModelAndView yeweihuiRibao(ModelMap model) {
  145. // List<QzTask> taskList = qzTaskService.selectAll();
  146. //
  147. // model.put("taskList", YvanUtil.toJsonPretty(taskList));
  148. return new ModelAndView("/yeweihui/ribao.ftl", model);
  149. }
  150. @GetMapping("/ywh/ribaoDy")
  151. public Model<List<SysUptownHouse>> yeweihuiRibaoDy(Long str) {
  152. // String[] split = str.split("&");
  153. List<SysUptownHouse> rbList = rbService.selectXq(str);
  154. return Model.newSuccess(rbList);
  155. }
  156. @GetMapping("/ywh/ribaoXq.html")
  157. public ModelAndView yeweihuiRibaoYcXq(ModelMap model) {
  158. Map<String, Object> queryParam = Maps.newLinkedHashMap();
  159. queryParam.put("userId", "12345677");
  160. queryParam.put("statistics", "M");
  161. return new ModelAndView("/yeweihui/ribaoXq.ftl", model);
  162. }
  163. @GetMapping("/ywh/ribaoDyYcXq")
  164. public Model<List<MsSuspected>> yeweihuiRibaoYcXq(Long houseId) {
  165. List<MsSuspected> rbList = rbService.selectYcXq(houseId);
  166. return Model.newSuccess(rbList);
  167. }
  168. @GetMapping("/ywh/ribaohuiz.html")
  169. public ModelAndView yeweihuiRibaohuiz(ModelMap model) {
  170. return new ModelAndView("/yeweihui/ribaohuiz.ftl", model);
  171. }
  172. @GetMapping("/ywh/yeweihui/ribaohuiz")
  173. public Model<Map<String, Object>> yeweihuiRibaohuiz(Long userCreate, String reportDate) {
  174. // Long userCreate = 1225321682867105793L;
  175. List<Uptown> uptowns = rbMapper.selectUptown(userCreate);
  176. if (uptowns != null && uptowns.size() > 0) {
  177. Long upId = uptowns.get(0).getUptownId();
  178. Map<String, Integer> map1 = rbMapper.selecthuiz(upId, reportDate);
  179. Map<String, Integer> map2 = rbMapper.selectyicahng(upId, reportDate);
  180. Map<String, Integer> map3 = rbMapper.selecthuiz1(upId);
  181. Map<String, Object> reMap = Maps.newHashMap();
  182. reMap.put("uptownName", uptowns.get(0).getUptownName());
  183. List<Integer> nums = Lists.newArrayList();
  184. nums.add(Conv.NI(map3.get("houseCount")));
  185. nums.add(Conv.NI(map1.get("reportCount")));
  186. nums.add(Conv.NI(map2.get("yichangCount")));
  187. nums.add(Conv.NI(map1.get("safetyNum")));
  188. nums.add(Conv.NI(map1.get("suspectedNum")));
  189. reMap.put("nums", nums);
  190. return Model.newSuccess(reMap);
  191. }
  192. return Model.newFail("没有数据");
  193. }
  194. @ApiOperation("导出正常家庭上报明细")
  195. @GetMapping("/ywh/yeweihui/exportRiBao")
  196. @SneakyThrows
  197. public void exportRiBao(@Pd(name = "uptownId") Long uptownId,
  198. @Pd(name = "date") String date,
  199. HttpServletResponse resp) {
  200. Uptown uptown = uptownMapper.selectById(uptownId);
  201. if (uptown != null && uptown.getUptownId() > 0) {
  202. Long upId = uptown.getUptownId();
  203. String fileName = uptown.getUptownName();
  204. fileName += "上报信息-";
  205. fileName += date;
  206. List<ExcelRiBao> list = rbMapper.selectExcelRiBao(upId, date);
  207. ExcelUtils.writeSheet(ExcelRiBao.class, list).export(resp, fileName);
  208. }
  209. }
  210. @ApiOperation("导出凌云家庭上报明细")
  211. @GetMapping("/ywh/lun/exportRiBao")
  212. @SneakyThrows
  213. public void lunExportRiBao(@Pd(name = "date") String date,
  214. HttpServletResponse resp) {
  215. Uptown uptown = uptownMapper.selectById("1238790987234");
  216. Long upId = uptown.getUptownId();
  217. String fileName = uptown.getUptownName();
  218. fileName += "上报信息-";
  219. fileName += date;
  220. List<ExcelRiBaoLY> list = rbMapper.selectExcelRiBaoLY(upId, date);
  221. ExcelUtils.writeSheet(ExcelRiBaoLY.class, list).export(resp, fileName);
  222. }
  223. @ApiOperation("导出小区家庭上报明细")
  224. @GetMapping("/ywh/yeweihui/EXR")
  225. @SneakyThrows
  226. public void exportRiBaoByXiaoQu(@Pd(name = "uptownId") Long uptownId,
  227. @Pd(name = "date") String date,
  228. HttpServletResponse resp) {
  229. Uptown uptown = uptownMapper.selectById(uptownId);
  230. if (uptown != null && uptown.getUptownId() > 0) {
  231. Long upId = uptown.getUptownId();
  232. String fileName = uptown.getUptownName();
  233. fileName += "上报信息-";
  234. fileName += date;
  235. List<ExcelRiBaoPrivate> list = rbMapper.selectExcelRiBaoPrivate(upId, date);
  236. ExcelUtils.writeSheet(ExcelRiBaoPrivate.class, list).export(resp, fileName);
  237. }
  238. }
  239. @GetMapping("/ywh/tgPublish.html")
  240. public ModelAndView tgPublish(@Pd(name = "userId") Long userId, ModelMap model) throws JsonProcessingException {
  241. model.put("userId", "\"" + userId + "\"");
  242. return new ModelAndView("/yeweihui/tgPublish.ftl", model);
  243. }
  244. @PostMapping("/ywh/tgPublish.json")
  245. public Model tuangouPublish(JmTuangou jmTuangou) {
  246. Integer success = jmTuangouService.tuangouPublish(jmTuangou);
  247. if (success == 1) {
  248. return Model.newSuccess("操作成功");
  249. } else {
  250. return Model.newFail("操作失败");
  251. }
  252. }
  253. @PostMapping("/ywh/tuangou/list/query.json")
  254. public Model queryTuangouListByTitle(@Pd(name = "userId") Long userId, @Pd(name = "title", required = false) String title) {
  255. List<JmTuangou> list = jmTuangouService.queryTuangouListByTitle(userId, title);
  256. return Model.newSuccess(list);
  257. }
  258. @PostMapping("/ywh/tuangou/mylist/query.json")
  259. public Model queryTuangouMyListByTitle(@Pd(name = "userId") Long userId, @Pd(name = "title", required = false) String title) {
  260. List<JmTuangou> myList = jmTuangouService.queryTuangouMyListByTitle(userId, title);
  261. return Model.newSuccess(myList);
  262. }
  263. @PostMapping("/ywh/getAllUptown")
  264. public Model<List<Uptown>> getAllUptown(HttpParameterParser parser, PageDb pageDb) {
  265. return Model.newSuccess(pageDb, uptownMapper.getUptowns(pageDb, parser.getMap()));
  266. }
  267. }