春风项目四线(合箱线、总装线)
yyt
2024-05-06 bbc5784cc34d65e64d639d949e75b978fe07bdb3
jcdm-main/src/main/java/com/jcdm/main/rm/repairRecord/controller/RmRepairRecordController.java
@@ -1,7 +1,25 @@
package com.jcdm.main.rm.repairRecord.controller;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.jcdm.common.core.domain.R;
import com.jcdm.common.core.domain.entity.SysDictData;
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
import com.jcdm.main.bs.orderScheduling.vo.FollowReportVO;
import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
import com.jcdm.main.rm.repairData.domain.RmRepairData;
import com.jcdm.main.rm.repairRecord.vo.RmRepairDataVO;
import com.jcdm.system.service.ISysDictDataService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -34,6 +52,9 @@
    @Autowired
    private IRmRepairRecordService rmRepairRecordService;
    @Resource
    private ISysDictDataService iSysDictDataService;
    /**
     * 查询返修记录列表
     */
@@ -47,6 +68,63 @@
    }
    /**
     * 获取返修数据列表
     * @param rmRepairRecord
     * @return
     */
    @PreAuthorize("@ss.hasPermi('rm:repairRecord:list')")
    @GetMapping("/getRepairReportList")
    public R getRepairReportList(RmRepairRecord rmRepairRecord)
    {
        RmRepairDataVO repairReportList = rmRepairRecordService.getRepairReportList(rmRepairRecord);
        return R.ok(repairReportList);
    }
    @PreAuthorize("@ss.hasPermi('rm:repairRecord:export')")
    @Log(title = "返修数据报表导出", businessType = BusinessType.EXPORT)
    @PostMapping("/exportRepair")
    public void exportRepair(HttpServletResponse response, RmRepairRecord rmRepairRecord)
    {
        RmRepairDataVO repairReportList = rmRepairRecordService.getRepairReportList(rmRepairRecord);
//        List<SysDictData> allDict = iSysDictDataService.selectDictDataList(null);
        String fileName = "追溯报表";
        try {
            ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();
            WriteSheet mainSheet = EasyExcel.writerSheet(0, "返修数据")
                    .head(RmRepairRecord.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            WriteSheet sheet1 = EasyExcel.writerSheet(1, "拧紧数据")
                    .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            WriteSheet sheet2 = EasyExcel.writerSheet(2, "相机检测")
                    .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            WriteSheet sheet3 = EasyExcel.writerSheet(3, "外漏检测")
                    .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            WriteSheet sheet4 = EasyExcel.writerSheet(4, "机油加注")
                    .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            WriteSheet sheet5 = EasyExcel.writerSheet(5, "工位结果")
                    .head(DaPassingStationCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                    .build();
            excelWriter.write(repairReportList.getMainList(),mainSheet);
            excelWriter.write(repairReportList.getList1(),sheet1);
            excelWriter.write(repairReportList.getList2(),sheet2);
            excelWriter.write(repairReportList.getList3(),sheet3);
            excelWriter.write(repairReportList.getList4(),sheet4);
            excelWriter.write(repairReportList.getList5(),sheet5);
            response.setContentType("application/vnd.ms-excel;charset=utf-8");
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-Disposition","attachment;filename="+fileName+".xlsx");
            excelWriter.finish();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    /**
     * 不分页查询返修记录列表
     */
    @GetMapping("/noPagelist")