|
@@ -5,6 +5,7 @@ import com.platform.common.exception.BusinessException;
|
|
|
import com.platform.common.model.UserInfo;
|
|
|
import com.platform.common.util.*;
|
|
|
import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
|
|
|
+import com.platform.dao.entity.check.CheckJob;
|
|
|
import com.platform.dao.entity.check.CheckStandard;
|
|
|
import com.platform.dao.entity.purchase.*;
|
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
@@ -462,13 +463,13 @@ 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\\LTKJ\\Downloads\\备件基础信息20220113205723195.xls"};
|
|
|
+ String[] files = {"C:\\Users\\LTKJ\\Downloads\\2022.1.28保养任务 终版 导入.xls"};
|
|
|
for(String fileStr:files){
|
|
|
System.out.println(fileStr);
|
|
|
InputStream inputstream = new FileInputStream(fileStr);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
//List<SbInfoVO> list = importSbInfoList(inputstream);
|
|
|
- List<SparePartInfoVO> list = importSparePartInfoListForUpdate(inputstream);
|
|
|
+ List<CheckJob> list = importCheckJobList(inputstream);
|
|
|
list.forEach(item -> {
|
|
|
System.out.println(item.toString());
|
|
|
});
|
|
@@ -1185,6 +1186,48 @@ public class CustomExcelImportUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导入点检任务,更新时间
|
|
|
+ *
|
|
|
+ * @param inputstream
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @throws InvalidFormatException
|
|
|
+ */
|
|
|
+ public static List<CheckJob> importCheckJobList(InputStream inputstream) throws IOException, InvalidFormatException {
|
|
|
+ if (inputstream == null) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ Workbook book = null;
|
|
|
+ if (!(inputstream.markSupported())) {
|
|
|
+ inputstream = new PushbackInputStream(inputstream, 8);
|
|
|
+ }
|
|
|
+ if (POIFSFileSystem.hasPOIFSHeader(inputstream)) {
|
|
|
+ book = new HSSFWorkbook(inputstream);
|
|
|
+ } else if (POIXMLDocument.hasOOXMLHeader(inputstream)) {
|
|
|
+ book = new XSSFWorkbook(OPCPackage.open(inputstream));
|
|
|
+ }
|
|
|
+ Sheet sheet = book.getSheetAt(0);
|
|
|
+ int rowCounts = sheet.getLastRowNum();
|
|
|
+ List<CheckJob> result = new ArrayList<>(rowCounts);
|
|
|
+ CheckJob record = null;
|
|
|
+ StringBuffer error = new StringBuffer();
|
|
|
+ LOGGER.info("文件行数:" + rowCounts);
|
|
|
+ for (int i = 2; i <= rowCounts; i++) {
|
|
|
+ record = new CheckJob();
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ if(isRowEmpty(row)){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ record.setId(getCellValue(row.getCell(0)));
|
|
|
+ String startDate = getCellValue(row.getCell(10)).trim();
|
|
|
+ record.setStartTime(DateUtils.strToLocalDate(startDate, DateUtils.PATTERN_YMD));
|
|
|
+ result.add(record);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 导入修改,导入的模板是导出的ExportCheckStandardVO
|
|
|
*
|