| | |
| | | package com.estate.expert.admin.controller.admin; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.estate.expert.admin.domain.business.check.CheckVo; |
| | | import com.estate.expert.admin.domain.business.onduty.OnDutyVo; |
| | | import com.estate.expert.admin.domain.common.request.OnDutyRequest; |
| | | import com.estate.expert.admin.service.CheckService; |
| | | import com.estate.expert.admin.service.OnDutyService; |
| | | import com.estate.expert.admin.utils.WebUtils; |
| | | import com.estate.expert.common.rpc.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | |
| | | @Resource |
| | | private CheckService checkService; |
| | | |
| | | @ApiOperation(value = "列表") |
| | | @ApiOperation(value = "列表",response = OnDutyVo.class) |
| | | @PostMapping("/list") |
| | | public Result list(@Validated @RequestBody OnDutyRequest request) { |
| | | public Result<Page<CheckVo>> list(@Validated @RequestBody OnDutyRequest request) { |
| | | |
| | | Page<CheckVo> page = new Page<>(request.getPageReq().getPage(), request.getPageReq().getSize()); |
| | | List<CheckVo> res = checkService.pageList(page, request); |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "详情") |
| | | @ApiOperation(value = "详情",response = OnDutyVo.class) |
| | | @PostMapping("/detail/{id}") |
| | | public Result detail(@PathVariable Integer id) { |
| | | public Result<CheckVo> detail(@PathVariable Integer id) { |
| | | CheckVo vo = checkService.detail(id); |
| | | return Result.success(vo); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "批量删除") |
| | | @PostMapping("/delete") |
| | | public Result delete(@RequestBody List<Integer> ids) { |
| | | return Result.success(checkService.removeByIds(ids)); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出") |
| | | @PostMapping(value = "/export") |
| | | public void export(@RequestBody OnDutyRequest query){ |
| | | List<CheckVo> list = checkService.exportList(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), CheckVo.class, list); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("检查情况导出信息.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // @ApiOperation(value = "新增故事简讯") |
| | | // @PostMapping("/add") |
| | | // public Result add(@Validated @RequestBody AccidentBrief dto) { |