| | |
| | | package com.estate.expert.admin.controller.admin; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.estate.expert.admin.domain.business.accidentbrief.AccidentBrief; |
| | |
| | | import com.estate.expert.admin.domain.common.request.PageReq; |
| | | import com.estate.expert.admin.service.AccidentBriefService; |
| | | 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 io.swagger.annotations.ApiParam; |
| | | import lombok.extern.java.Log; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | 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.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @Slf4j |
| | | @CrossOrigin |
| | |
| | | @Resource |
| | | private OnDutyService onDutyService; |
| | | |
| | | @ApiOperation(value = "列表") |
| | | @ApiOperation(value = "列表",response = OnDutyVo.class) |
| | | @PostMapping("/list") |
| | | public Result list(@Validated @RequestBody OnDutyRequest request) { |
| | | public Result<Page<OnDutyVo>> list(@Validated @RequestBody OnDutyRequest request) { |
| | | |
| | | Page<OnDutyVo> page = new Page<>(request.getPageReq().getPage(), request.getPageReq().getSize()); |
| | | List<OnDutyVo> res = onDutyService.pageList(page, request); |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "详情") |
| | | @ApiOperation(value = "详情",response = OnDutyVo.class) |
| | | @PostMapping("/detail/{id}") |
| | | public Result detail(@PathVariable Integer id) { |
| | | public Result<OnDutyVo> detail(@PathVariable Integer id) { |
| | | OnDutyVo vo = onDutyService.detail(id); |
| | | return Result.success(vo); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "批量删除") |
| | | @PostMapping("/delete") |
| | | public Result delete(@RequestBody List<Integer> ids) { |
| | | return Result.success(onDutyService.removeByIds(ids)); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出") |
| | | @PostMapping(value = "/export") |
| | | public void export(@RequestBody OnDutyRequest query){ |
| | | List<OnDutyVo> list = onDutyService.exportList(query); |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), OnDutyVo.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) { |