|
@@ -10,9 +10,7 @@ import com.platform.dao.entity.sb.SbInfo;
|
|
import com.platform.dao.entity.sb.SbModel;
|
|
import com.platform.dao.entity.sb.SbModel;
|
|
import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
|
|
import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
|
|
import com.platform.dao.entity.store.SpareStore;
|
|
import com.platform.dao.entity.store.SpareStore;
|
|
-import com.platform.dao.enums.CheckStandardTypeEnum;
|
|
|
|
-import com.platform.dao.enums.SbInfoChildEnum;
|
|
|
|
-import com.platform.dao.enums.SbInfoShowEnum;
|
|
|
|
|
|
+import com.platform.dao.enums.*;
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
|
|
import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
@@ -459,13 +457,13 @@ public class CustomExcelImportUtil {
|
|
public static void main(String[] args) throws IOException, InvalidFormatException {
|
|
public static void main(String[] args) throws IOException, InvalidFormatException {
|
|
//String path = "C:\\Users\\cyz\\Downloads\\老版维保计划\\noperson";
|
|
//String path = "C:\\Users\\cyz\\Downloads\\老版维保计划\\noperson";
|
|
//File dirFile = new File("C:\\Users\\cyz\\Downloads\\老版维保计划\\noperson");
|
|
//File dirFile = new File("C:\\Users\\cyz\\Downloads\\老版维保计划\\noperson");
|
|
- String[] files = {"C:\\Users\\cyz\\\\Downloads\\2021.8.3设备基础导入 修改设备等级 设备类型 自定义类型.xls"};
|
|
|
|
|
|
+ String[] files = {"C:\\Users\\cyz\\\\Downloads\\保养标准20210812160348862.xls"};
|
|
for(String fileStr:files){
|
|
for(String fileStr:files){
|
|
System.out.println(fileStr);
|
|
System.out.println(fileStr);
|
|
InputStream inputstream = new FileInputStream(fileStr);
|
|
InputStream inputstream = new FileInputStream(fileStr);
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
//List<SbInfoVO> list = importSbInfoList(inputstream);
|
|
//List<SbInfoVO> list = importSbInfoList(inputstream);
|
|
- List<SbInfoVO> list = importListByUpdateALl(inputstream);
|
|
|
|
|
|
+ List<CheckStandard> list = importCheckStandardListByUpdate(inputstream);
|
|
list.forEach(item -> {
|
|
list.forEach(item -> {
|
|
System.out.println(item.toString());
|
|
System.out.println(item.toString());
|
|
});
|
|
});
|
|
@@ -995,6 +993,89 @@ public class CustomExcelImportUtil {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 导入修改,导入的模板是导出的ExportCheckStandardVO
|
|
|
|
+ *
|
|
|
|
+ * @param inputstream
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ * @throws InvalidFormatException
|
|
|
|
+ */
|
|
|
|
+ public static List<CheckStandard> importCheckStandardListByUpdate(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<CheckStandard> result = new ArrayList<>(rowCounts);
|
|
|
|
+ CheckStandard record = null;
|
|
|
|
+ StringBuffer error = new StringBuffer();
|
|
|
|
+ LOGGER.info("文件行数:" + rowCounts);
|
|
|
|
+ for (int i = 2; i <= rowCounts; i++) {
|
|
|
|
+ record = new CheckStandard();
|
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
|
+ if(isRowEmpty(row)){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ record.setId(row.getCell(0).getStringCellValue().trim());
|
|
|
|
+ record.setName(row.getCell(3).getStringCellValue().trim());
|
|
|
|
+ record.setNo(row.getCell(4).getStringCellValue().trim());
|
|
|
|
+ record.setRequirement(row.getCell(5).getStringCellValue().trim());
|
|
|
|
+ record.setRemark(row.getCell(6).getStringCellValue().trim());
|
|
|
|
+ String period = row.getCell(7).getStringCellValue();
|
|
|
|
+ record.setPeriod(Double.valueOf(period).intValue());
|
|
|
|
+ String periodType = row.getCell(8).getStringCellValue();
|
|
|
|
+ if(periodType.equals("天")){
|
|
|
|
+ record.setPeriodType(CheckPlanPeriodTypeEnum.DAY.getValue());
|
|
|
|
+ }else if(periodType.equals("周")){
|
|
|
|
+ record.setPeriodType(CheckPlanPeriodTypeEnum.WEEK.getValue());
|
|
|
|
+ }else if(periodType.equals("月")){
|
|
|
|
+ record.setPeriodType(CheckPlanPeriodTypeEnum.MONTH.getValue());
|
|
|
|
+ }else if(periodType.equals("季度")){
|
|
|
|
+ record.setPeriodType(CheckPlanPeriodTypeEnum.SEASON.getValue());
|
|
|
|
+ }else if(periodType.equals("年")){
|
|
|
|
+ record.setPeriodType(CheckPlanPeriodTypeEnum.YEAR.getValue());
|
|
|
|
+ }else if(periodType.equals("公里")){
|
|
|
|
+ record.setPeriodType(CheckPlanPeriodTypeEnum.MILES.getValue());
|
|
|
|
+ }else if(periodType.equals("台时")){
|
|
|
|
+ record.setPeriodType(CheckPlanPeriodTypeEnum.TAISHI.getValue());
|
|
|
|
+ }
|
|
|
|
+ String lastDate = row.getCell(9).getStringCellValue().trim();
|
|
|
|
+ String nextDate = row.getCell(10).getStringCellValue().trim();
|
|
|
|
+ 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();
|
|
|
|
+ if(StringUtils.isBlank(checkUserType)){
|
|
|
|
+ if(record.getPeriodType()>1){
|
|
|
|
+ record.setCheckUserType(CheckUserTypeEnum.REPAIR_USER.getValue());
|
|
|
|
+ }else{
|
|
|
|
+ record.setCheckUserType(CheckUserTypeEnum.USE_USER.getValue());
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ record.setCheckUserType(Integer.valueOf(checkUserType));
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new BusinessException("导入异常,行号:"+ i + ", 错误信息" + e.getMessage() + ", 错误原因" + e.getCause());
|
|
|
|
+ }
|
|
|
|
+ result.add(record);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 导入老版本的点检标准
|
|
* 导入老版本的点检标准
|
|
*
|
|
*
|