| | |
| | | package com.xiaopeng.maintenance.controller; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xiaopeng.api.model.maintenance.XpCruiseCheckInRecord; |
| | | import com.xiaopeng.api.model.maintenance.XpCruiseCheckInRule; |
| | | import com.xiaopeng.api.model.operation.SysOperLog; |
| | | import com.xiaopeng.api.vo.account.LoginOperationUser; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.utils.poi.ExcelUtil; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.security.service.TokenService; |
| | | import com.xiaopeng.maintenance.dto.XpCruiseCheckInRuleDto; |
| | |
| | | import com.xiaopeng.maintenance.model.vo.RealTimePositionVo; |
| | | import com.xiaopeng.maintenance.service.IXpCruiseCheckInRecordService; |
| | | import com.xiaopeng.maintenance.service.IXpCruiseCheckInRuleService; |
| | | import com.xiaopeng.maintenance.vo.XpCruiseCheckInRecordQuery; |
| | | import com.xiaopeng.maintenance.vo.XpCruiseCheckInRecordVO; |
| | | import com.xiaopeng.maintenance.vo.XpCruiseCheckInRuleListPage; |
| | | import com.xiaopeng.maintenance.vo.XpCruiseCheckInStatisticsQuery; |
| | | import com.xiaopeng.maintenance.vo.XpCruiseCheckInStatisticsVO; |
| | | import com.xiaopeng.maintenance.vo.*; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | 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; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("") |
| | | @Slf4j |
| | | public class XpCruiseCheckInRuleController { |
| | | |
| | | @Resource |
| | |
| | | @ApiOperation(value = "巡游打卡统计", tags = {"管理后台-巡游打卡管理"}) |
| | | @PostMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/statistic") |
| | | public R<List<XpCruiseCheckInStatisticsVO>> pageList(@RequestBody XpCruiseCheckInStatisticsQuery query) { |
| | | |
| | | return R.ok(xpCruiseCheckInRecordService.statistics(query)); |
| | | } |
| | | |
| | |
| | | @PostMapping("/maintenance-admin/api/v1/cruiseCheckInRecord/export") |
| | | public R<PageInfo<XpCruiseCheckInRecordVO>> pageListExport(@RequestBody XpCruiseCheckInRecordQuery query, HttpServletResponse response) { |
| | | List<XpCruiseCheckInRecordVO> list = xpCruiseCheckInRecordService.all(query); |
| | | ExcelUtil<XpCruiseCheckInRecordVO> util = new ExcelUtil<>(XpCruiseCheckInRecordVO.class); |
| | | util.exportExcel(response, list, "巡游打卡记录"); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), XpCruiseCheckInRecordVO.class, list); |
| | | 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); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | outputStream.flush(); |
| | | } catch (IOException e) { |
| | | log.error("导出巡游打卡记录失败", e); |
| | | } finally { |
| | | try { |
| | | if (outputStream != null) { |
| | | outputStream.close(); |
| | | } |
| | | if (workbook != null) { |
| | | workbook.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | log.error("关闭输出流失败", e); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |