#
mrzhssss
2022-04-18 cd91d368ecceb75d93e9a0099507371ccc38d749
src/main/java/zy/cloud/wms/manager/controller/ItemReportController.java
@@ -7,6 +7,10 @@
import com.baomidou.mybatisplus.plugins.Page;
import com.core.common.DateUtils;
import com.core.exception.CoolException;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.xssf.usermodel.*;
import zy.cloud.wms.manager.entity.Cstmr;
import zy.cloud.wms.manager.entity.Item;
import zy.cloud.wms.manager.entity.ItemReport;
@@ -20,6 +24,11 @@
import org.springframework.web.bind.annotation.*;
import zy.cloud.wms.manager.service.ItemService;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
@RestController
@@ -76,11 +85,35 @@
   @RequestMapping(value = "/itemReport/update/auth")
   @ManagerAuth
    public R update(ItemReport itemReport){
        if (Cools.isEmpty(itemReport) || null==itemReport.getId()){
    public R update(ItemReport report){
        if (Cools.isEmpty(report) || null==report.getId()){
            return R.error();
        }
        itemReportService.updateById(itemReport);
        if (report.getDeliverReason() == null || report.getDeliverReason().equals("")) {
            report.setDeliverIssue(false);
        }else {
            report.setDeliverIssue(true);
        }
        if (report.getQualityReason() == null || report.getQualityReason().equals("")) {
            report.setQualityIssue(false);
        }else {
            report.setQualityIssue(true);
        }
        if (report.getDesignReason() == null || report.getDesignReason().equals("")) {
            report.setDesignIssue(false);
        }else {
            report.setDesignIssue(true);
        }
        if (report.getInstallReason() == null || report.getInstallReason().equals("")) {
            report.setInstallIssue(false);
        }else {
            report.setInstallIssue(true);
        }
        itemReportService.update(report,new EntityWrapper<ItemReport>()
                .eq("id",report.getId()));
        return R.ok();
    }
@@ -144,4 +177,52 @@
        }
        return R.ok(result);
    }
    @RequestMapping("/itemReport/makeReport/auth")
    public HttpServletResponse makeReport(@RequestParam("id") String id, HttpServletResponse response){
        /**
         * 控管与初始化
         *
         */
        if (Cools.isEmpty(id)) {
            throw new CoolException("需要生成报告的项目为空,无法生成");
        }
        Item item = itemService.selectOne(new EntityWrapper<Item>()
                .eq("id", id));
        ItemReport itemReport = itemReportService.selectOne(new EntityWrapper<ItemReport>()
                .eq("item_id", id));
        if (Cools.isEmpty(item) || Cools.isEmpty(itemReport)) {
            throw new CoolException("找不到该项目或是项目的总结");
        }
        return itemReportService.makeReport(item,itemReport, response);
    }
    public static void main(String[] args) {
        FileOutputStream out = null;
        FileInputStream in = null;
        try {
            in = new FileInputStream("src/main/resources/excel/analysis_report.xlsx");
            out = new FileOutputStream("C:\\Users\\Zhs\\Desktop\\report.xlsx");
            XSSFWorkbook wb = new XSSFWorkbook(in);
            XSSFSheet mainSheet = wb.getSheet("报告");
            XSSFRow row10 = mainSheet.getRow(11);
            XSSFCell cell = row10.getCell(1);
            cell.setCellValue("为啥你就可以呢?");
            wb.write(out);
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                out.close();
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}