mitao
2 天以前 e8e30e5474c1fd0c14390710066e40c17155ad37
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AssetAdMaterialPriceController.java
@@ -1,6 +1,5 @@
package com.ruoyi.web.controller.api;
import cn.idev.excel.FastExcel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
@@ -8,6 +7,7 @@
import com.ruoyi.system.dto.asset.AssetAdMaterialPriceDTO;
import com.ruoyi.system.query.AssetAdMaterialPriceQuery;
import com.ruoyi.system.service.AssetAdMaterialPriceService;
import com.ruoyi.system.utils.FastExcelUtil;
import com.ruoyi.system.vo.asset.AssetAdMaterialPriceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -30,7 +30,6 @@
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.List;
@@ -91,18 +90,7 @@
    @ApiOperation("下载导入模板")
    @GetMapping("/template")
    public void getTemplate(HttpServletResponse response){
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        String fileName = null;
        try {
            fileName = URLEncoder.encode("广告物料单价导入模板", "UTF-8").replaceAll("\\+", "%20");
            response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
            FastExcel.write(response.getOutputStream(), AssetAdMaterialPriceDTO.class)
                    .sheet("广告物料单价")
                    .doWrite(Collections.emptyList());
        } catch (IOException e) {
            log.error("下载导入模板异常", e);
        }
        FastExcelUtil.exportData(response, "广告物料单价导入模板", "广告物料单价", AssetAdMaterialPriceDTO.class, Collections.emptyList());
    }
    @ApiOperation("导入")
@@ -113,10 +101,7 @@
            return R.fail("请选择一个文件上传!");
        }
        try {
            List<AssetAdMaterialPriceDTO> list = FastExcel.read(file.getInputStream())
                    .head(AssetAdMaterialPriceDTO.class)
                    .sheet()
                    .doReadSync();
            List<AssetAdMaterialPriceDTO> list = FastExcelUtil.readMultipartFile(file.getInputStream(), AssetAdMaterialPriceDTO.class);
            assetAdMaterialPriceService.importAssetAdMaterialPrice(list);
            return R.ok();
        } catch (IOException e) {