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.HomeService; import com.bofeng.service.QzTaskReplyService; import com.bofeng.service.QzTaskService; import com.bofeng.service.RbService; 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 YeWeiHuiController { @Autowired private QzTaskService qzTaskService; @Autowired private RbService rbService; @Autowired private QzTaskReplyService qzTaskReplyService; @Autowired private HomeService homeService; @Autowired private UptownMapper uptownMapper; @Autowired private RbMapper rbMapper; @GetMapping("/yeweihui/home.html") public ModelAndView yeweihui(ModelMap model,@RequestParam(value = "userId") Long userId, @RequestParam(value = "showQZ", required = false, defaultValue = "-") String showQZ) { // 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("showQZ", "\""+showQZ+"\""); return new ModelAndView("/yeweihui/home.ftl", model); } @GetMapping("/yeweihui/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("/yeweihui/qiuzhu/queryTasksByStatus.json") public Model queryTasksByStatus(@Pd(name = "status") Integer status) { List taskList = qzTaskService.queryQzTaskByStatus(status); return Model.newSuccess(taskList); } @PostMapping("/yeweihui/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("/yeweihui/qiuzhu/reply/querybytaskid.json") public Model replyQiuzhuQueryByTaskId(@Pd(name = "taskId") Long taskId) { List reply = qzTaskReplyService.queryQzTaskReplyByTaskId(taskId); return Model.newSuccess(reply); } @PostMapping("/yeweihui/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("/yeweihui/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("/yeweihui/ribaoDy") public Model> yeweihuiRibaoDy(Long str) { // String[] split = str.split("&"); List rbList = rbService.selectXq(str); return Model.newSuccess(rbList); } @GetMapping("/yeweihui/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("/yeweihui/ribaoDyYcXq") public Model> yeweihuiRibaoYcXq(Long houseId) { List rbList = rbService.selectYcXq(houseId); return Model.newSuccess(rbList); } @GetMapping("/yeweihui/ribaohuiz.html") public ModelAndView yeweihuiRibaohuiz(ModelMap model) { return new ModelAndView("/yeweihui/ribaohuiz.ftl", model); } @GetMapping("/epi/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("/whepi/epi/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("/whepi/epi/lun/exportRiBao") @SneakyThrows public void lunExportRiBao(@Pd(name = "date") String date, HttpServletResponse resp) { List uptowns = rbMapper.selectUptownByName("金湖家园"); if (uptowns!=null && uptowns.size()>0) { Long upId = uptowns.get(0).getUptownId(); String fileName = uptowns.get(0).getUptownName(); fileName += "上报信息-"; fileName += date; List list = rbMapper.selectExcelRiBaoLY(upId,date); ExcelUtils.writeSheet(ExcelRiBaoLY.class, list).export(resp, fileName); } } @ApiOperation("导出小区家庭上报明细") @GetMapping("/whepi/epi/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("/yeweihui/tgPublish.html") public ModelAndView tuangouPublish(@Pd(name = "userId") Long userId, ModelMap model) throws JsonProcessingException { model.put("userId", "\""+userId+"\""); return new ModelAndView("/yeweihui/tgPublish.ftl", model); } @PostMapping("/whepi/getAllUptown") public Model> getAllUptown(HttpParameterParser parser, PageDb pageDb) { return Model.newSuccess(pageDb, uptownMapper.getUptowns(pageDb, parser.getMap())); } }