WangHan
2025-04-02 a8ba678a3fe5a39da2c732014cebbb66e408e97c
consum-base/src/main/java/com/consum/base/controller/DepFormScrappedController.java
@@ -1,15 +1,12 @@
package com.consum.base.controller;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -32,10 +29,6 @@
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ReflectUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
/**
 * @ClassName DepFormScrappedController
@@ -44,14 +37,14 @@
 * @Description
 * @Version 1.0
 **/
@Api(value = "部门报废", tags = "部门报废")
// @Api(value = "部门报废", tags = "部门报废")
@RestController
@RequestMapping("/pc/l/wh/form/scrapped")
public class DepFormScrappedController extends BaseController {
    @Resource
    private DepFormScrappedService depFormScrappedService;
    @ApiOperation(value = "新增报废单", notes = "新增报废单")
    // @ApiOperation(value = "新增报废单", notes = "新增报废单")
    @PostMapping("/deptAdd")
    public ResponseValue deptAdd() throws Exception {
        LDeptFormScrappedParam param = CommonUtil.getObjFromReqBody(LDeptFormScrappedParam.class);
@@ -69,9 +62,9 @@
     * @Description 列表查询 1.查询报废单 2.查询报废单物品
     * @Date
     */
    @ApiOperation(value = "列表查询", notes = "列表查询")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "param", value = "查询条件", dataType = "LWhFormScrappedQry", paramType = "query")})
    // @ApiOperation(value = "列表查询", notes = "列表查询")
//    @ApiImplicitParams({
//        @ApiImplicitParam(name = "param", value = "查询条件", dataType = "LWhFormScrappedQry", paramType = "query")})
    @GetMapping("/deptList")
    public ResponseValue queryList() {
        LDeptFormScrappedQry param = CommonUtil.getObjFromReq(LDeptFormScrappedQry.class);
@@ -133,8 +126,8 @@
    /**
     * @Description 根据id查询详情
     */
    @ApiOperation(value = "根据id查询详情", notes = "根据id查询详情")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "报废单id", dataType = "Long", paramType = "query")})
    // @ApiOperation(value = "根据id查询详情", notes = "根据id查询详情")
    // @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "报废单id", dataType = "Long", paramType = "query")})
    @GetMapping("/deptDetail")
    public ResponseValue getById(Long id) {
        if (id == null) {
@@ -143,10 +136,10 @@
        return ResponseValue.success(this.depFormScrappedService.getById(id));
    }
    @ApiOperation(value = "导出报废单", notes = "导出报废单")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "报废单id", dataType = "Long", paramType = "query")})
    // @ApiOperation(value = "导出报废单", notes = "导出报废单")
    // @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "报废单id", dataType = "Long", paramType = "query")})
    @GetMapping("/deptList/export")
    public void export(Long id, HttpServletResponse response) throws Exception {
    public ResponseValue<String> export(Long id, HttpServletResponse response) throws Exception {
        if (id == null) {
            throw new RuntimeException("报废单id为空");
        }
@@ -174,12 +167,15 @@
        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, map);
        // 设置响应头
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
        response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("部门报废单.xlsx", "utf-8"));
        try (OutputStream outputStream = response.getOutputStream()) {
            workbook.write(outputStream);
            workbook.close();
        }
//        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
//        response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("部门报废单.xlsx", "utf-8"));
//        try (OutputStream outputStream = response.getOutputStream()) {
//            workbook.write(outputStream);
//            workbook.close();
//        }
        String filePath = downLoadExcel("采购入库单", workbook);
        return ResponseValue.success("导出成功", filePath);
    }
    @GetMapping("/deptListByModel")