|
|
|
@ -9,6 +9,9 @@ import com.xujie.sys.modules.part.mapper.PartInformationMapper; |
|
|
|
import com.xujie.sys.modules.part.service.PartCostHistService; |
|
|
|
import com.xujie.sys.modules.part.mapper.PartCostHistMapper; |
|
|
|
import com.xujie.sys.modules.part.vo.BomComponentVo; |
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
|
import org.apache.poi.ss.usermodel.DataFormatter; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
@ -61,15 +64,15 @@ public class PartCostHistServiceImpl extends ServiceImpl<PartCostHistMapper, Par |
|
|
|
// 为对象赋值 |
|
|
|
task.setSite(data.getSite()); // site |
|
|
|
|
|
|
|
try { |
|
|
|
row.getCell(0).getStringCellValue(); // 物料编码 |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException("物料编码格式不正确,应为文本型!"); |
|
|
|
} |
|
|
|
if (row.getCell(0) == null || row.getCell(0).getStringCellValue().equals("")) { |
|
|
|
// try { |
|
|
|
// row.getCell(0).getStringCellValue(); // 物料编码 |
|
|
|
// } catch (Exception e) { |
|
|
|
// throw new RuntimeException("物料编码格式不正确,应为文本型!"); |
|
|
|
// } |
|
|
|
if (row.getCell(0) == null || getStringCellValue(row, 0).equals("")) { |
|
|
|
throw new RuntimeException("物料编码不能为空!(line:" + j + ")"); |
|
|
|
} |
|
|
|
task.setPartNo(row.getCell(0).getStringCellValue()); // 物料编码 |
|
|
|
task.setPartNo(getStringCellValue(row, 0)); // 物料编码 |
|
|
|
|
|
|
|
task.setStandardCost(BigDecimal.valueOf(row.getCell(1).getNumericCellValue())); //单位标准成本 |
|
|
|
|
|
|
|
@ -103,6 +106,15 @@ public class PartCostHistServiceImpl extends ServiceImpl<PartCostHistMapper, Par |
|
|
|
throw new RuntimeException("导入失败:"+e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String getStringCellValue(XSSFRow row, int columnIndex) { |
|
|
|
Cell cell = row.getCell(columnIndex); |
|
|
|
if (cell == null || cell.getCellType() == CellType.BLANK) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
DataFormatter formatter = new DataFormatter(); |
|
|
|
return formatter.formatCellValue(cell); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|