|
@@ -18,7 +18,9 @@ import com.platform.office.poi.excel.ExcelImportUtil;
|
|
|
import com.platform.office.poi.excel.entity.ImportParams;
|
|
|
import com.platform.office.poi.excel.imports.CellValueServer;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.time.DateFormatUtils;
|
|
|
import org.apache.poi.POIXMLDocument;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
import org.apache.poi.openxml4j.opc.OPCPackage;
|
|
@@ -33,6 +35,7 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -457,7 +460,7 @@ public class CustomExcelImportUtil {
|
|
|
public static void main(String[] args) throws IOException, InvalidFormatException {
|
|
|
//String path = "C:\\Users\\cyz\\Downloads\\老版维保计划\\noperson";
|
|
|
//File dirFile = new File("C:\\Users\\cyz\\Downloads\\老版维保计划\\noperson");
|
|
|
- String[] files = {"C:\\Users\\cyz\\\\Downloads\\2021.9.14 保养标准 保养时间 去除指定.xls"};
|
|
|
+ String[] files = {"C:\\Users\\cyz\\\\Downloads\\2021.9.14 保养标准 保养时间 去除指定 (1).xls"};
|
|
|
for(String fileStr:files){
|
|
|
System.out.println(fileStr);
|
|
|
InputStream inputstream = new FileInputStream(fileStr);
|
|
@@ -555,8 +558,14 @@ public class CustomExcelImportUtil {
|
|
|
// 判断数据的类型
|
|
|
switch (cell.getCellType()) {
|
|
|
case Cell.CELL_TYPE_NUMERIC: // 数字
|
|
|
- cellValue = String.valueOf(cell.getNumericCellValue());
|
|
|
- cellValue = cellValue.trim().replaceAll(",", "");
|
|
|
+ if (HSSFDateUtil.isCellDateFormatted(cell)) {
|
|
|
+ Date date = cell.getDateCellValue();
|
|
|
+ cellValue = DateFormatUtils.format(date, "yyyy-MM-dd");
|
|
|
+ } else {
|
|
|
+ double value = cell.getNumericCellValue();
|
|
|
+ DecimalFormat df = new DecimalFormat("0");
|
|
|
+ cellValue = df.format(value);
|
|
|
+ }
|
|
|
break;
|
|
|
case Cell.CELL_TYPE_STRING: // 字符串
|
|
|
cellValue = String.valueOf(cell.getStringCellValue());
|
|
@@ -1052,13 +1061,14 @@ public class CustomExcelImportUtil {
|
|
|
}
|
|
|
String lastDate = getCellValue(row.getCell(11));
|
|
|
String nextDate = getCellValue(row.getCell(12));
|
|
|
+
|
|
|
if(StringUtils.isNotBlank(lastDate)){
|
|
|
record.setLastDate(DateUtils.strToLocalDate(lastDate, DateUtils.PATTERN_YMD));
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(nextDate)){
|
|
|
record.setNextDate(DateUtils.strToLocalDate(nextDate, DateUtils.PATTERN_YMD));
|
|
|
}
|
|
|
- String checkUserType = row.getCell(11).getStringCellValue().trim();
|
|
|
+ String checkUserType = row.getCell(13).getStringCellValue().trim();
|
|
|
if(StringUtils.isBlank(checkUserType)){
|
|
|
if(record.getPeriodType()>1){
|
|
|
record.setCheckUserType(CheckUserTypeEnum.REPAIR_USER.getValue());
|