|
@@ -460,12 +460,13 @@ public class CustomExcelImportUtil {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws IOException, InvalidFormatException {
|
|
|
- String[] files = {"C:\\Users\\cyz\\Downloads\\设备基础信息20210627125310010.xls"};
|
|
|
- InputStream inputstream = new FileInputStream(files[0]);
|
|
|
+ String[] files = {"C:\\Users\\cyz\\Downloads\\维护计划和机台信息\\C-006 (OS-M240).xls",
|
|
|
+ "C:\\Users\\cyz\\Downloads\\维护计划和机台信息\\C-001 (OS-M235)-多列模板.xls"};
|
|
|
+ InputStream inputstream = new FileInputStream(files[1]);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
// List<SparePartInfoVO> list = importSparePartInfoList(now, inputstream);
|
|
|
- List<SbInfoVO> list = importListByUpdateALl(inputstream);
|
|
|
- // List<CheckStandard> list = importCheckStandardList(inputstream);
|
|
|
+ // List<SbInfoVO> list = importListByUpdateALl(inputstream);
|
|
|
+ List<CheckStandard> list = importCheckStandardList(inputstream);
|
|
|
|
|
|
list.forEach(item -> {
|
|
|
System.out.println(item.toString());
|
|
@@ -960,29 +961,30 @@ public class CustomExcelImportUtil {
|
|
|
int rowCounts = sheet.getLastRowNum();
|
|
|
List<CheckStandard> result = new ArrayList<>(rowCounts);
|
|
|
CheckStandard record = null;
|
|
|
- String sbNo = sheet.getRow(4).getCell(13).getStringCellValue();
|
|
|
+ String sbNo = "" ;
|
|
|
+ int type = 0;// 没有负责人的,1有
|
|
|
+ if(sheet.getRow(4).getCell(10) != null && StringUtils.isNotBlank(sheet.getRow(4).getCell(10) .getStringCellValue())){
|
|
|
+ type = 0;
|
|
|
+ sbNo = sheet.getRow(4).getCell(10).getStringCellValue();
|
|
|
+ }else{
|
|
|
+ type = 1;
|
|
|
+ sbNo = sheet.getRow(4).getCell(13).getStringCellValue();
|
|
|
+ }
|
|
|
StringBuffer error = new StringBuffer();
|
|
|
+ LOGGER.info("文件行数:" + rowCounts);
|
|
|
for (int i = 12; i <= rowCounts; i++) {
|
|
|
record = new CheckStandard();
|
|
|
Row row = sheet.getRow(i);
|
|
|
if(isRowEmpty(row)){
|
|
|
- continue;
|
|
|
+ break;
|
|
|
}
|
|
|
String index = row.getCell(1).getStringCellValue() + "";
|
|
|
try {
|
|
|
- //i,j i:行 j:列
|
|
|
- setPeriod(row, record);
|
|
|
- String sort = getCellValue(row.getCell(11)).trim();
|
|
|
- System.out.println(sort.substring(0,sort.length()-2 ));
|
|
|
- record.setSort(Integer.valueOf(sort.substring(0,sort.length()-2 )));
|
|
|
- record.setRequirement(row.getCell(12).getStringCellValue().trim());
|
|
|
- record.setName(record.getRequirement().substring(0,4));
|
|
|
- record.setId(IdGeneratorUtils.getObjectId());
|
|
|
- record.setType(CheckStandardTypeEnum.POLLING.getValue());
|
|
|
- record.setSbId(sbNo);// 需要根据no来判断设备的id
|
|
|
- record.setStandardHours("0");
|
|
|
- record.setEnable(1);
|
|
|
- setRemark(row, record);
|
|
|
+ if(type == 0){
|
|
|
+ setNoPerson(sbNo, row, record);
|
|
|
+ }else{
|
|
|
+ setPerson(sbNo, row, record);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
throw new BusinessException("导入异常,行号:"+ i + ", 错误信息" + e.getMessage() + ", 错误原因" + e.getCause());
|
|
|
}
|
|
@@ -991,6 +993,36 @@ public class CustomExcelImportUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private static void setPerson(String sbNo, Row row, CheckStandard record) {
|
|
|
+ //i,j i:行 j:列
|
|
|
+ setPeriod(row, record);
|
|
|
+ String sort = getCellValue(row.getCell(11)).trim();
|
|
|
+ record.setSort(Integer.valueOf(sort.substring(0,sort.length()-2 )));
|
|
|
+ record.setRequirement(row.getCell(12).getStringCellValue().trim());
|
|
|
+ record.setName(record.getRequirement().substring(0,4));
|
|
|
+ record.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ record.setType(CheckStandardTypeEnum.POLLING.getValue());
|
|
|
+ record.setNo(sbNo);// 需要根据no来判断设备的id
|
|
|
+ record.setStandardHours("0");
|
|
|
+ record.setEnable(1);
|
|
|
+ setRemark(row, record);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void setNoPerson(String sbNo, Row row, CheckStandard record) {
|
|
|
+ //i,j i:行 j:列
|
|
|
+ setPeriod(row, record);
|
|
|
+ String sort = getCellValue(row.getCell(8)).trim();
|
|
|
+ record.setSort(Integer.valueOf(sort.substring(0,sort.length()-2 )));
|
|
|
+ record.setRequirement(row.getCell(9).getStringCellValue().trim());
|
|
|
+ record.setName(record.getRequirement().substring(0,4));
|
|
|
+ record.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ record.setType(CheckStandardTypeEnum.POLLING.getValue());
|
|
|
+ record.setNo(sbNo);// 需要根据no来判断设备的id
|
|
|
+ record.setStandardHours("0");
|
|
|
+ record.setEnable(1);
|
|
|
+ setRemark(row, record);
|
|
|
+ }
|
|
|
+
|
|
|
private static void setRemark(Row row, CheckStandard record) {
|
|
|
if(StringUtils.isNotEmpty(row.getCell(7).getStringCellValue())){
|
|
|
record.setCheckUserType(1);
|