| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.system.dto.TCrmSupplierDTO; |
| | | import com.ruoyi.system.model.TCrmBranch; |
| | | import com.ruoyi.system.model.TCrmChangePoints; |
| | | import com.ruoyi.system.model.TCrmSalesperson; |
| | | import com.ruoyi.system.model.TCrmSupplier; |
| | | import com.ruoyi.system.export.TCrmBranchExport; |
| | | import com.ruoyi.system.export.TCrmSupplierExport; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TCrmBranchQuery; |
| | | import com.ruoyi.system.query.TCrmSupplierQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.TCrmSupplierVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | private final TCrmSupplierService crmSupplierService; |
| | | private final ISysUserService sysUserService; |
| | | private final TCrmWarehouseService crmWarehouseService; |
| | | @Autowired |
| | | public TCrmSupplierController(TCrmSupplierService crmSupplierService, ISysUserService sysUserService) { |
| | | public TCrmSupplierController(TCrmSupplierService crmSupplierService, ISysUserService sysUserService, TCrmWarehouseService crmWarehouseService) { |
| | | this.crmSupplierService = crmSupplierService; |
| | | this.sysUserService = sysUserService; |
| | | this.crmWarehouseService = crmWarehouseService; |
| | | } |
| | | |
| | | /** |
| | |
| | | TCrmSupplier crmSupplier = crmSupplierService.getById(id); |
| | | TCrmSupplierVO crmSupplierVO = new TCrmSupplierVO(); |
| | | BeanUtils.copyProperties(crmSupplier, crmSupplierVO); |
| | | // 查询仓库 |
| | | TCrmWarehouse crmWarehouse = crmWarehouseService.getById(crmSupplier.getWarehouseId()); |
| | | if(Objects.nonNull(crmWarehouse)){ |
| | | crmSupplierVO.setWarehouseName(crmWarehouse.getWarehouseName()); |
| | | } |
| | | return R.ok(crmSupplierVO); |
| | | } |
| | | |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Log(title = "crm供应商管理信息-供应商管理导出", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "供应商管理导出") |
| | | @PostMapping("/exportList") |
| | | public void exportList(@RequestBody TCrmSupplierQuery query){ |
| | | List<TCrmSupplierExport> crmSupplierExports = crmSupplierService.exportList(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TCrmSupplierExport.class, crmSupplierExports); |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |