whycxzp
2022-09-07 701f43e193b6277bd3686b1940c32ac9d7ba74f8
软件excel解析
2个文件已修改
19 ■■■■ 已修改文件
src/main/java/com/whyc/pojo/Software.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/SoftwareService.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/Software.java
@@ -27,7 +27,7 @@
    private String owner;
    @ApiModelProperty("归档日期")
    private Date filingDate;
    private String filingDate;
    @ApiModelProperty("适用机型-物料编码")
    private String applyMaterialCode;
@@ -96,11 +96,11 @@
        this.owner = owner;
    }
    public Date getFilingDate() {
    public String getFilingDate() {
        return filingDate;
    }
    public void setFilingDate(Date filingDate) {
    public void setFilingDate(String filingDate) {
        this.filingDate = filingDate;
    }
src/main/java/com/whyc/service/SoftwareService.java
@@ -11,6 +11,7 @@
import com.whyc.pojo.Software;
import com.whyc.util.ActionUtil;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
@@ -23,7 +24,6 @@
import java.io.*;
import java.net.URLEncoder;
import java.text.ParseException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
@@ -55,7 +55,7 @@
        for (int i = 0; i < typeArr.length; i++) {
            //excel单元格中的✔对应字符
            if(typeArr[i].contains("þ")){
                common.setType(typeArr[i].trim());
                common.setType(typeArr[i].replace("þ","").trim());
                break;
            }
        }
@@ -63,8 +63,7 @@
        common.setBasedVersion(sheet.getRow(4).getCell(4).getStringCellValue());
        common.setOwner(sheet.getRow(5).getCell(2).getStringCellValue());
        Date filingDate = sheet.getRow(5).getCell(4).getDateCellValue();
        common.setFilingDate(filingDate);
        common.setFilingDate(sheet.getRow(5).getCell(4).getStringCellValue());
        //最后一行,取发布说明
        common.setReleaseNotes(sheet.getRow(lastRowNum).getCell(2).getStringCellValue());
@@ -74,8 +73,10 @@
            Software software = new Software();
            BeanUtils.copyProperties(common,software);
            //取第3列,第5列
            software.setApplyMaterialCode(sheet.getRow(8+i).getCell(2).getStringCellValue());
            software.setApplyModel(sheet.getRow(8+i).getCell(4).getStringCellValue());
            Cell cell = sheet.getRow(7 + i).getCell(2);
            cell.setCellType(Cell.CELL_TYPE_STRING);
            software.setApplyMaterialCode(cell.getStringCellValue());
            software.setApplyModel(sheet.getRow(7+i).getCell(4).getStringCellValue());
            softwareList.add(software);
        }