| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | import com.ruoyi.common.core.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.other.api.domain.TFleet; |
| | | import com.ruoyi.other.api.domain.TGroupCompany; |
| | | import com.ruoyi.other.api.dto.FleetExcelDTO; |
| | | import com.ruoyi.other.api.dto.FleetQueryDTO; |
| | | import com.ruoyi.other.service.TFleetService; |
| | | import com.ruoyi.other.service.TGroupCompanyService; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RequestPart; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 导入车队(Excel) |
| | | */ |
| | | @RequiresPermissions(value = {"/fleet/import"}, logical = Logical.OR) |
| | | @PostMapping("/import") |
| | | @ApiOperation(value = "导入车队", tags = {"管理后台-车队管理"}) |
| | | @Log(title = "【车队管理】导入车队", businessType = BusinessType.IMPORT) |
| | | public AjaxResult<String> importData(@RequestPart("file") MultipartFile file) throws Exception { |
| | | List<FleetExcelDTO> items = new ExcelUtil<>(FleetExcelDTO.class).importExcel(file.getInputStream()); |
| | | return AjaxResult.success(fleetService.importFleets(items)); |
| | | } |
| | | |
| | | /** |
| | | * 下载车队导入模板 |
| | | */ |
| | | @RequiresPermissions(value = {"/fleet/import"}, logical = Logical.OR) |
| | | @GetMapping("/import-template") |
| | | @ApiOperation(value = "下载车队导入模板", tags = {"管理后台-车队管理"}) |
| | | public void template(HttpServletResponse response) { |
| | | new ExcelUtil<>(FleetExcelDTO.class).importTemplateExcel(response, "车队导入模板"); |
| | | } |
| | | |
| | | /** |
| | | * 导出车队(Excel,按筛选条件) |
| | | */ |
| | | @RequiresPermissions(value = {"/fleet/export"}, logical = Logical.OR) |
| | | @PutMapping("/export") |
| | | @ApiOperation(value = "导出车队", tags = {"管理后台-车队管理"}) |
| | | @Log(title = "【车队管理】导出车队", businessType = BusinessType.EXPORT) |
| | | public void export(HttpServletResponse response, @RequestBody(required = false) FleetQueryDTO query) { |
| | | new ExcelUtil<>(FleetExcelDTO.class).exportExcel(response, fleetService.selectExportList(query), "车队数据"); |
| | | } |
| | | |
| | | /** |
| | | * 查询车队详情(查看按钮使用) |
| | | */ |
| | | @RequiresPermissions(value = {"/fleet/list"}, logical = Logical.OR) |
| | | @GetMapping("/detail") |
| | | @ApiOperation(value = "查询车队详情", tags = {"管理后台-车队管理"}) |
| | | public AjaxResult<TFleet> detail(@RequestParam("id") Integer id) { |
| | | if (id == null) { |
| | | return AjaxResult.error("车队ID不能为空"); |
| | | } |
| | | TFleet fleet = fleetService.getById(id); |
| | | if (fleet == null) { |
| | | return AjaxResult.error("车队不存在或已删除"); |
| | | } |
| | | if (fleet.getCompanyId() != null) { |
| | | TGroupCompany company = groupCompanyService.getById(fleet.getCompanyId()); |
| | | if (company != null) { |
| | | fleet.setCompanyName(company.getName()); |
| | | } |
| | | } |
| | | return AjaxResult.success(fleet); |
| | | } |
| | | |
| | | /** |
| | | * 按公司ID批量回填公司名称 |
| | | */ |
| | | private void fillCompanyName(List<TFleet> records) { |