package com.bofeng.wx.controller; import com.bofeng.dao.RbMapper; import com.bofeng.dao.UptownMapper; import com.bofeng.entity.*; import com.bofeng.excel.ExcelUtils; import com.bofeng.service.*; import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.yvan.Model; import com.yvan.ModelOps; import com.yvan.PageDb; import com.yvan.mvc.Pd; import com.yvan.platform.Conv; import com.yvan.platform.JsonWapper; import com.yvan.platform.YvanUtil; import com.yvan.springmvc.HttpParameterParser; import io.swagger.annotations.ApiOperation; import lombok.SneakyThrows; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @RestController public class RiBaoYwhController { @Autowired private QzTaskService qzTaskService; @Autowired private RbService rbService; @Autowired private QzTaskReplyService qzTaskReplyService; @Autowired private HomeService homeService; @Autowired private JmTuangouService jmTuangouService; @Autowired private UptownMapper uptownMapper; @Autowired private RbMapper rbMapper; @Autowired private RiBaoService riBaoService; // 查询业委会日报首页小区及统计数据 @GetMapping("/ywh/getRibaoYwh") public Model getRibaoYwh(@Pd(name = "userId") Long userId) { return Model.newSuccess(riBaoService.getRibaoYwh(userId)); } // 查询业委会日报首页小区对应栋列表 @GetMapping("/ywh/queryRibaoYwhDongList") public Model> queryRibaoYwhDongList(@Pd(name = "uptownId") Long uptownId) { List listSuspected = riBaoService.queryRibaoYwhDongList(uptownId); return Model.newSuccess(listSuspected); } // 查询业委会日报某一栋小区单元数据 根据queryRibaoYwhDongList获取栋数据作为参数传递给此接口 @GetMapping("/ywh/queryDanYuanList") public Model> queryDanYuanList(@Pd(name = "uptownId") Long uptownId, @Pd(name = "ridgepole") Long ridgepole) { List listSuspected = riBaoService.queryDanYuanList(uptownId, ridgepole); return Model.newSuccess(listSuspected); } // 查询业委会日报某一栋门牌数据 根据queryDanYuanList获取单元数据作为参数传递给此接口 // uptownId:小区id; ridgepole:栋;unitId:单元id @GetMapping("/ywh/queryMenPaiList") public Model> queryMenPaiList(@Pd(name = "uptownId") Long uptownId, @Pd(name = "ridgepole") Long ridgepole, @Pd(name = "unitId") Long unitId) { List listSuspected = riBaoService.queryMenPaiList(uptownId, ridgepole, unitId); return Model.newSuccess(listSuspected); } @GetMapping("/ywh/home.html") public ModelAndView yeweihui(ModelMap model, @RequestParam(value = "userId") Long userId, @RequestParam(value = "show", required = false, defaultValue = "-") String show) { // List taskList = qzTaskService.selectAll(1225321682867105793L); // List rbList = rbService.selectAll(1225321682867105793L); List taskList = qzTaskService.selectAll(userId); List rbList = rbService.selectAll(userId); model.put("taskList", YvanUtil.toJsonPretty(taskList)); model.put("rbList", YvanUtil.toJsonPretty(rbList)); model.put("user_id", "\"" + userId + "\""); model.put("show", "\"" + show + "\""); return new ModelAndView("/yeweihui/home.ftl", model); } @GetMapping("/ywh/qiuzhuDetail.html") public ModelAndView qiuzhudetail(@Pd(name = "taskId") Long taskId, @Pd(name = "userId") Long userId, ModelMap model) throws JsonProcessingException { QzTask task = qzTaskService.queryByTaskId(taskId); // A业委会,B居委会,C物业,D志愿者 StringBuffer target = new StringBuffer(); if (task.getTaskTarget().equals("A")) { target.append("业委会"); } else if (task.getTaskTarget().equals("B")) { if (target.length() > 0) { target.append("、居委会"); } else { target.append("居委会"); } } else if (task.getTaskTarget().equals("C")) { if (target.length() > 0) { target.append("、物业"); } else { target.append("物业"); } } else if (task.getTaskTarget().equals("D")) { if (target.length() > 0) { target.append("、志愿者"); } else { target.append("志愿者"); } } task.setTaskTarget(target.toString()); model.put("taskJson", new JsonWapper(task)); model.put("task", task); model.put("userId", "\"" + userId + "\""); return new ModelAndView("/yeweihui/qiuzhuDetail.ftl", model); } @PostMapping("/ywh/qiuzhu/queryTasksByStatus.json") public Model queryTasksByStatus(@Pd(name = "status") Integer status) { List taskList = qzTaskService.queryQzTaskByStatus(status); return Model.newSuccess(taskList); } @PostMapping("/ywh/qiuzhu/reply/add.json") public ModelOps replyQiuzhuInsert(QzTaskReply qzTaskReply) { Integer success = qzTaskReplyService.insertQzTaskReply(qzTaskReply); if (success > 0) { return ModelOps.newSuccess(); } else { return ModelOps.newFail("操作失败"); } } @PostMapping("/ywh/qiuzhu/reply/querybytaskid.json") public Model replyQiuzhuQueryByTaskId(@Pd(name = "taskId") Long taskId) { List reply = qzTaskReplyService.queryQzTaskReplyByTaskId(taskId); return Model.newSuccess(reply); } @PostMapping("/ywh/qiuzhu/list.json") public Model queryByHouseNumber(String houseNumber, @Pd(name = "status") Integer status) { if (houseNumber.length() <= 0) { return Model.newSuccess(qzTaskService.queryQzTaskByStatus(status)); } List list = qzTaskService.queryByHouseNumber(houseNumber, status); return Model.newSuccess(list); } @GetMapping("/ywh/ribao.html") public ModelAndView yeweihuiRibao(ModelMap model) { // List taskList = qzTaskService.selectAll(); // // model.put("taskList", YvanUtil.toJsonPretty(taskList)); return new ModelAndView("/yeweihui/ribao.ftl", model); } @GetMapping("/ywh/ribaoDy") public Model> yeweihuiRibaoDy(Long str) { // String[] split = str.split("&"); List rbList = rbService.selectXq(str); return Model.newSuccess(rbList); } @GetMapping("/ywh/ribaoXq.html") public ModelAndView yeweihuiRibaoYcXq(ModelMap model) { Map queryParam = Maps.newLinkedHashMap(); queryParam.put("userId", "12345677"); queryParam.put("statistics", "M"); return new ModelAndView("/yeweihui/ribaoXq.ftl", model); } @GetMapping("/ywh/ribaoDyYcXq") public Model> yeweihuiRibaoYcXq(Long houseId) { List rbList = rbService.selectYcXq(houseId); return Model.newSuccess(rbList); } @GetMapping("/ywh/ribaohuiz.html") public ModelAndView yeweihuiRibaohuiz(ModelMap model) { return new ModelAndView("/yeweihui/ribaohuiz.ftl", model); } @GetMapping("/ywh/yeweihui/ribaohuiz") public Model> yeweihuiRibaohuiz(Long userCreate, String reportDate) { // Long userCreate = 1225321682867105793L; List uptowns = rbMapper.selectUptown(userCreate); if (uptowns != null && uptowns.size() > 0) { Long upId = uptowns.get(0).getUptownId(); Map map1 = rbMapper.selecthuiz(upId, reportDate); Map map2 = rbMapper.selectyicahng(upId, reportDate); Map map3 = rbMapper.selecthuiz1(upId); Map reMap = Maps.newHashMap(); reMap.put("uptownName", uptowns.get(0).getUptownName()); List nums = Lists.newArrayList(); nums.add(Conv.NI(map3.get("houseCount"))); nums.add(Conv.NI(map1.get("reportCount"))); nums.add(Conv.NI(map2.get("yichangCount"))); nums.add(Conv.NI(map1.get("safetyNum"))); nums.add(Conv.NI(map1.get("suspectedNum"))); reMap.put("nums", nums); return Model.newSuccess(reMap); } return Model.newFail("没有数据"); } @ApiOperation("导出正常家庭上报明细") @GetMapping("/ywh/yeweihui/exportRiBao") @SneakyThrows public void exportRiBao(@Pd(name = "uptownId") Long uptownId, @Pd(name = "date") String date, HttpServletResponse resp) { Uptown uptown = uptownMapper.selectById(uptownId); if (uptown != null && uptown.getUptownId() > 0) { Long upId = uptown.getUptownId(); String fileName = uptown.getUptownName(); fileName += "上报信息-"; fileName += date; List list = rbMapper.selectExcelRiBao(upId, date); ExcelUtils.writeSheet(ExcelRiBao.class, list).export(resp, fileName); } } @ApiOperation("导出凌云家庭上报明细") @GetMapping("/ywh/lun/exportRiBao") @SneakyThrows public void lunExportRiBao(@Pd(name = "date") String date, HttpServletResponse resp) { Uptown uptown = uptownMapper.selectById("1238790987234"); Long upId = uptown.getUptownId(); String fileName = uptown.getUptownName(); fileName += "上报信息-"; fileName += date; List list = rbMapper.selectExcelRiBaoLY(upId, date); ExcelUtils.writeSheet(ExcelRiBaoLY.class, list).export(resp, fileName); } @ApiOperation("导出小区家庭上报明细") @GetMapping("/ywh/yeweihui/EXR") @SneakyThrows public void exportRiBaoByXiaoQu(@Pd(name = "uptownId") Long uptownId, @Pd(name = "date") String date, HttpServletResponse resp) { Uptown uptown = uptownMapper.selectById(uptownId); if (uptown != null && uptown.getUptownId() > 0) { Long upId = uptown.getUptownId(); String fileName = uptown.getUptownName(); fileName += "上报信息-"; fileName += date; List list = rbMapper.selectExcelRiBaoPrivate(upId, date); ExcelUtils.writeSheet(ExcelRiBaoPrivate.class, list).export(resp, fileName); } } @GetMapping("/ywh/tgPublish.html") public ModelAndView tgPublish(@Pd(name = "userId") Long userId, ModelMap model) throws JsonProcessingException { model.put("userId", "\"" + userId + "\""); return new ModelAndView("/yeweihui/tgPublish.ftl", model); } @PostMapping("/ywh/tgPublish.json") public Model tuangouPublish(JmTuangou jmTuangou) { Integer success = jmTuangouService.tuangouPublish(jmTuangou); if (success == 1) { return Model.newSuccess("操作成功"); } else { return Model.newFail("操作失败"); } } @PostMapping("/ywh/tuangou/list/query.json") public Model queryTuangouListByTitle(@Pd(name = "userId") Long userId, @Pd(name = "title", required = false) String title) { List list = jmTuangouService.queryTuangouListByTitle(userId, title); return Model.newSuccess(list); } @PostMapping("/ywh/tuangou/mylist/query.json") public Model queryTuangouMyListByTitle(@Pd(name = "userId") Long userId, @Pd(name = "title", required = false) String title) { List myList = jmTuangouService.queryTuangouMyListByTitle(userId, title); return Model.newSuccess(myList); } @PostMapping("/ywh/getAllUptown") public Model> getAllUptown(HttpParameterParser parser, PageDb pageDb) { return Model.newSuccess(pageDb, uptownMapper.getUptowns(pageDb, parser.getMap())); } }