|
@@ -11,6 +11,8 @@ import com.platform.dao.entity.sb.SbModel;
|
|
|
import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
|
|
|
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.vo.export.sb.ExportSbInfoVO;
|
|
|
import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
|
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
@@ -458,34 +460,12 @@ public class CustomExcelImportUtil {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws IOException, InvalidFormatException {
|
|
|
- /*String[] files = {"C:\\Users\\cyz\\Desktop\\设备管理软件初始化数据准备-苏丹分公司-0123\\乌干达\\设备管理软件初始化数据准备-乌干达7.3KM项目-0129-备件.xlsx",
|
|
|
- "C:\\\\Users\\\\cyz\\\\Desktop\\\\设备管理软件初始化数据准备-苏丹分公司-0123\\\\乌干达\\\\设备管理软件初始化数据准备-乌干达111项目-0125-备件.xlsx",
|
|
|
- "C:\\\\Users\\\\cyz\\\\Desktop\\\\设备管理软件初始化数据准备-苏丹分公司-0123\\\\乌干达\\\\设备管理软件初始化数据准备-乌干达MBRARA项目-0130-备件.xlsx",
|
|
|
- "C:\\\\Users\\\\cyz\\\\Desktop\\\\设备管理软件初始化数据准备-苏丹分公司-0123\\\\乌干达\\\\设备管理软件初始化数据准备-乌干达六桥项目-0128-备件.xlsx",
|
|
|
- "C:\\\\Users\\\\cyz\\\\Desktop\\\\设备管理软件初始化数据准备-苏丹分公司-0123\\\\乌干达\\\\设备管理软件初始化数据准备-乌干达四桥项目-0129-备件.xlsx",
|
|
|
- "C:\\\\Users\\\\cyz\\\\Desktop\\\\设备管理软件初始化数据准备-苏丹分公司-0123\\\\乌干达\\\\设备管理软件初始化数据准备-利比里亚-1225-备件.xlsx"};
|
|
|
- */
|
|
|
- /*String[] files = {"C:\\Users\\cyz\\Desktop\\设备管理软件初始化数据准备-苏丹分公司-0123\\乌干达\\设备管理软件初始化数据准备-乌干达7.3KM项目-0129-设备.xlsx",
|
|
|
- "C:\\\\Users\\\\cyz\\\\Desktop\\\\设备管理软件初始化数据准备-苏丹分公司-0123\\\\乌干达\\\\设备管理软件初始化数据准备-乌干达111项目-0125-设备.xlsx",
|
|
|
- "C:\\\\Users\\\\cyz\\\\Desktop\\\\设备管理软件初始化数据准备-苏丹分公司-0123\\\\乌干达\\\\设备管理软件初始化数据准备-乌干达MBRARA项目-0130-设备.xlsx",
|
|
|
- "C:\\\\Users\\\\cyz\\\\Desktop\\\\设备管理软件初始化数据准备-苏丹分公司-0123\\\\乌干达\\\\设备管理软件初始化数据准备-乌干达六桥项目-0128-设备.xlsx",
|
|
|
- "C:\\\\Users\\\\cyz\\\\Desktop\\\\设备管理软件初始化数据准备-苏丹分公司-0123\\\\乌干达\\\\设备管理软件初始化数据准备-乌干达四桥项目-0129-设备.xlsx",
|
|
|
- "C:\\\\Users\\\\cyz\\\\Desktop\\\\设备管理软件初始化数据准备-苏丹分公司-0123\\\\乌干达\\\\设备管理软件初始化数据准备-乌干达办事处-设备.xlsx"};
|
|
|
-*/
|
|
|
- /* String[] files = {"C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-东帝汶.xls",
|
|
|
- "C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-肯尼亚.xls",
|
|
|
- "C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-利比里亚.xls",
|
|
|
- "C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-卢旺达.xls",
|
|
|
- "C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-孟加拉.xls",
|
|
|
- "C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-苏丹.xls",
|
|
|
- "C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-坦桑尼亚.xls",
|
|
|
- "C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-苏丹.xls"};*/
|
|
|
- String[] files = {"C:\\Users\\cyz\\Desktop\\C-001 (OS-M235) - 副本.xls"};
|
|
|
+ String[] files = {"C:\\Users\\cyz\\Downloads\\设备基础信息20210627125310010.xls"};
|
|
|
InputStream inputstream = new FileInputStream(files[0]);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
// List<SparePartInfoVO> list = importSparePartInfoList(now, inputstream);
|
|
|
- // List<SbInfoVO> list = importSbInfoList(inputstream);
|
|
|
- List<CheckStandard> list = importCheckStandardList(inputstream);
|
|
|
+ List<SbInfoVO> list = importListByUpdateALl(inputstream);
|
|
|
+ // List<CheckStandard> list = importCheckStandardList(inputstream);
|
|
|
|
|
|
list.forEach(item -> {
|
|
|
System.out.println(item.toString());
|
|
@@ -909,6 +889,16 @@ public class CustomExcelImportUtil {
|
|
|
}
|
|
|
record.setStatus(getSbInfoStatus(row.getCell(18).getStringCellValue()));
|
|
|
record.setRemark(row.getCell(19).getStringCellValue().trim());
|
|
|
+ System.out.println("row.getPhysicalNumberOfCells(): " + row.getPhysicalNumberOfCells());
|
|
|
+ // 主子设备和是否大屏显示
|
|
|
+ if(row.getPhysicalNumberOfCells()>20){
|
|
|
+ record.setIsChild(getChild(row.getCell(20).getStringCellValue().trim()));
|
|
|
+ record.setIsShow(getShow(row.getCell(21).getStringCellValue().trim()));
|
|
|
+ record.setPositionId(row.getCell(22).getStringCellValue().trim());
|
|
|
+ }else{// 默认值
|
|
|
+ record.setIsChild(SbInfoChildEnum.IS_NORMAL.getValue());
|
|
|
+ record.setIsShow(SbInfoShowEnum.NOT_SHOW.getValue());
|
|
|
+ }
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
error.append(index).append(",");
|
|
@@ -923,6 +913,28 @@ public class CustomExcelImportUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private static Integer getChild(String trim) {
|
|
|
+ if(StringUtils.isBlank(trim)){
|
|
|
+ return SbInfoChildEnum.IS_NORMAL.getValue();
|
|
|
+ }else if("子设备".equals(trim)){
|
|
|
+ return SbInfoChildEnum.IS_CHILD.getValue();
|
|
|
+ }else if("父设备".equals(trim)){
|
|
|
+ return SbInfoChildEnum.IS_PARENT.getValue();
|
|
|
+ }else{
|
|
|
+ return SbInfoChildEnum.IS_NORMAL.getValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static Integer getShow(String trim) {
|
|
|
+ if(StringUtils.isBlank(trim)){
|
|
|
+ return SbInfoShowEnum.NOT_SHOW.getValue();
|
|
|
+ }else if("不显示".equals(trim)){
|
|
|
+ return SbInfoShowEnum.NOT_SHOW.getValue();
|
|
|
+ }else{
|
|
|
+ return SbInfoShowEnum.IS_SHOWING.getValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导入点检标准
|
|
|
*
|
|
@@ -1024,7 +1036,7 @@ public class CustomExcelImportUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public static List<SbInfo> importSbInfoListForUpdateValue(InputStream inputstream) throws IOException, InvalidFormatException {
|
|
|
+ public static List<SbInfoVO> importListByUpdateALl(InputStream inputstream) throws IOException, InvalidFormatException {
|
|
|
if (inputstream == null) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
@@ -1039,46 +1051,89 @@ public class CustomExcelImportUtil {
|
|
|
}
|
|
|
Sheet sheet = book.getSheetAt(0);
|
|
|
int rowCounts = sheet.getLastRowNum();
|
|
|
- List<SbInfo> result = new ArrayList<>(rowCounts);
|
|
|
- SbInfo record = null;
|
|
|
+ List<SbInfoVO> result = new ArrayList<>(rowCounts);
|
|
|
+ SbInfoVO record = null;
|
|
|
|
|
|
StringBuffer error = new StringBuffer();
|
|
|
- for (int i = 1; i <= rowCounts; i++) {
|
|
|
- record = new SbInfo();
|
|
|
+ for (int i = 2; i <= rowCounts; i++) {
|
|
|
+ record = new SbInfoVO();
|
|
|
Row row = sheet.getRow(i);
|
|
|
String index = row.getCell(1).getStringCellValue() + "";
|
|
|
try {
|
|
|
//i,j i:行 j:列
|
|
|
- record.setFinancingNo(row.getCell(1).getStringCellValue());
|
|
|
- record.setInitialValue(new Double(getCellValue(row.getCell(3)).replace(",","")));
|
|
|
- record.setCutValue(new Double(getCellValue(row.getCell(4)).replace(",","")));
|
|
|
- double currentValue = BigDecimalUtil.sub(record.getInitialValue(), record.getCutValue());
|
|
|
- currentValue = currentValue<0?0:currentValue;
|
|
|
- record.setCurrentValue(currentValue);
|
|
|
- String startDate = getCellValue(row.getCell(5));
|
|
|
- if (startDate.contains(".")) {
|
|
|
- if (startDate.contains("E7")) {
|
|
|
- record.setStartDate(DateUtils.strToLocalDate(startDate.replace(".", "").replace("E7", ""), DateUtils.PATTERNYMD));
|
|
|
- } else if (startDate.endsWith(".0")) {
|
|
|
- record.setStartDate(DateUtils.strToLocalDate(ExcelDoubleToDate(startDate), DateUtils.PATTERN_YMD));
|
|
|
- } else {
|
|
|
- record.setStartDate(DateUtils.strToLocalDate(startDate, DateUtils.PATTERN_YMD_DOT));
|
|
|
- }
|
|
|
- } else if (startDate.contains("-")) {
|
|
|
- record.setStartDate(DateUtils.strToLocalDate(startDate, DateUtils.PATTERN_YMD));
|
|
|
- } else {
|
|
|
- record.setStartDate(DateUtils.strToLocalDate(startDate, DateUtils.PATTERNYMD));
|
|
|
- }
|
|
|
- if("4".equals(getCellValue(row.getCell(6)))){
|
|
|
- record.setMonth(new BigDecimal(48));
|
|
|
+ record.setId(row.getCell(0).getStringCellValue().trim());
|
|
|
+ record.setNo(row.getCell(1).getStringCellValue().trim());
|
|
|
+ record.setZbh(getCellValue(row.getCell(2)));
|
|
|
+ record.setName(row.getCell(3).getStringCellValue().trim().replace("'", ""));
|
|
|
+ record.setModel(getCellValue(row.getCell(4)).trim());
|
|
|
+ String level = getCellValue(row.getCell(5));
|
|
|
+ if(StringUtils.isBlank(level)){
|
|
|
+ record.setLevel(1);
|
|
|
}else{
|
|
|
- record.setMonth(new BigDecimal(getCellValue(row.getCell(6))));
|
|
|
+ record.setLevel(getLevel(level));
|
|
|
}
|
|
|
- record.setUsedMonth(new BigDecimal(getCellValue(row.getCell(7))));
|
|
|
- if(row.getLastCellNum() == 9){
|
|
|
- record.setRate(new BigDecimal(getCellValue(row.getCell(8))));
|
|
|
+ String value = getCellValue(row.getCell(6));
|
|
|
+ if(StringUtils.isBlank(value)){
|
|
|
+ record.setInitialValue(0.0);
|
|
|
}else{
|
|
|
- record.setRate(new BigDecimal(0));
|
|
|
+ record.setInitialValue(new Double(value));
|
|
|
+ }
|
|
|
+ record.setTypeName(row.getCell(7).getStringCellValue().trim());
|
|
|
+ record.setUseType(getUseType(row.getCell(8).getStringCellValue().trim()));
|
|
|
+ record.setZz(getCellValue(row.getCell(9)));
|
|
|
+ record.setCph(getCellValue(row.getCell(10)));
|
|
|
+ record.setZzh(getCellValue(row.getCell(11)));
|
|
|
+ record.setProducerId(row.getCell(12).getStringCellValue().trim());
|
|
|
+ record.setSaveUserName(row.getCell(13).getStringCellValue().trim());
|
|
|
+ record.setRepairUserName(row.getCell(14).getStringCellValue().trim());
|
|
|
+ record.setRepairUserNameSecond(row.getCell(15).getStringCellValue().trim());
|
|
|
+ if (StringUtils.isBlank(getCellValue(row.getCell(16)))) {
|
|
|
+ record.setBuyDate(DateUtils.strToLocalDate("2014-01-01", DateUtils.PATTERN_YMD));
|
|
|
+ } else {
|
|
|
+ record.setBuyDate(DateUtils.strToLocalDate((getCellValue(row.getCell(16)).substring(0, 4) + "-01-01"), DateUtils.PATTERN_YMD));
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(getCellValue(row.getCell(17)))) {
|
|
|
+ record.setStartDate(DateUtils.strToLocalDate("2019-01-01", DateUtils.PATTERN_YMD));
|
|
|
+ } else {
|
|
|
+ if (getCellValue(row.getCell(17)).contains(".")) {
|
|
|
+ if (getCellValue(row.getCell(17)).contains("E7")) {
|
|
|
+ record.setStartDate(DateUtils.strToLocalDate(getCellValue(row.getCell(17)).replace(".", "").replace("E7", ""), DateUtils.PATTERNYMD));
|
|
|
+ } else if (getCellValue(row.getCell(17)).endsWith(".0")) {
|
|
|
+ record.setStartDate(DateUtils.strToLocalDate(ExcelDoubleToDate(getCellValue(row.getCell(17))), DateUtils.PATTERN_YMD));
|
|
|
+ } else {
|
|
|
+ record.setStartDate(DateUtils.strToLocalDate(getCellValue(row.getCell(17)), DateUtils.PATTERN_YMD_DOT));
|
|
|
+ }
|
|
|
+ } else if (getCellValue(row.getCell(17)).contains("-")) {
|
|
|
+ record.setStartDate(DateUtils.strToLocalDate(getCellValue(row.getCell(17)), DateUtils.PATTERN_YMD));
|
|
|
+ } else {
|
|
|
+ if(getCellValue(row.getCell(17)).contains("/")){
|
|
|
+ String[] strList = getCellValue(row.getCell(17)).split("/");
|
|
|
+ if(strList.length == 3){
|
|
|
+ if(strList[1].length() == 1){
|
|
|
+ strList[1] = "0" + strList[1];
|
|
|
+ }
|
|
|
+ if(strList[2].length() == 1){
|
|
|
+ strList[2] = "0" + strList[2];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String newDate = strList[0] + "-" + strList[1] + "-" + strList[2];
|
|
|
+ record.setStartDate(DateUtils.strToLocalDate(newDate, DateUtils.PATTERN_YMD));
|
|
|
+ }else{
|
|
|
+ record.setStartDate(DateUtils.strToLocalDate(getCellValue(row.getCell(17)), DateUtils.PATTERNYMD));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setStatus(getSbInfoStatus(row.getCell(18).getStringCellValue()));
|
|
|
+ record.setRemark(row.getCell(19).getStringCellValue().trim());
|
|
|
+ System.out.println("row.getPhysicalNumberOfCells(): " + row.getPhysicalNumberOfCells());
|
|
|
+ // 主子设备和是否大屏显示
|
|
|
+ if(row.getPhysicalNumberOfCells()>20){
|
|
|
+ record.setIsChild(getChild(row.getCell(20).getStringCellValue().trim()));
|
|
|
+ record.setIsShow(getShow(row.getCell(21).getStringCellValue().trim()));
|
|
|
+ record.setPositionId(row.getCell(22).getStringCellValue().trim());
|
|
|
+ }else{// 默认值
|
|
|
+ record.setIsChild(SbInfoChildEnum.IS_NORMAL.getValue());
|
|
|
+ record.setIsShow(SbInfoShowEnum.NOT_SHOW.getValue());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
error.append(index).append(",");
|