|
|
|
@ -10,10 +10,7 @@ import com.xujie.sys.modules.part.mapper.BomManagementMapper; |
|
|
|
import com.xujie.sys.modules.part.mapper.PartInformationMapper; |
|
|
|
import com.xujie.sys.modules.part.service.BomManagementService; |
|
|
|
import com.xujie.sys.modules.part.vo.*; |
|
|
|
import com.xujie.sys.modules.pms.data.GetParamInData; |
|
|
|
import com.xujie.sys.modules.pms.data.QcItemData; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.ss.formula.ptg.NotEqualPtg; |
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
|
import org.apache.poi.ss.usermodel.DataFormatter; |
|
|
|
@ -22,13 +19,13 @@ import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@ -871,9 +868,9 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
} |
|
|
|
task.setLineItemNo(++lineItemNo); |
|
|
|
task.setLineSequence(++lineSeqNo); |
|
|
|
task.setPrintUnit(partInformationEntity.getUmId()); // 单位 |
|
|
|
task.setQtyPerAssembly(getNumericCellValueOrDefault(row, 2, BigDecimal.ZERO)); // 单位用量 |
|
|
|
task.setComponentScrap(getNumericCellValueOrDefault(row, 3, BigDecimal.ZERO)); // 调机量 |
|
|
|
task.setPrintUnit(partInformationEntity.getUmId2()); // 单位 |
|
|
|
task.setQtyPerAssembly(getNumericCellValueOrDefault(row, 2)); // 单位用量 |
|
|
|
task.setComponentScrap(getNumericCellValueOrDefault(row, 3)); // 调机量 |
|
|
|
task.setShrinkageFactor(data.getShrinkageFactor()); // 损耗率 |
|
|
|
saveList.add(task); |
|
|
|
} |
|
|
|
@ -893,9 +890,25 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
return formatter.formatCellValue(cell); |
|
|
|
} |
|
|
|
|
|
|
|
private BigDecimal getNumericCellValueOrDefault(XSSFRow row, int columnIndex, BigDecimal defaultValue) { |
|
|
|
private BigDecimal getNumericCellValueOrDefault(XSSFRow row, int columnIndex) { |
|
|
|
Cell cell = row.getCell(columnIndex); |
|
|
|
return (cell == null || cell.getCellType() == CellType.BLANK) ? defaultValue : BigDecimal.valueOf(cell.getNumericCellValue()); |
|
|
|
if (cell == null || cell.getCellType() == CellType.BLANK) { |
|
|
|
return BigDecimal.ZERO; |
|
|
|
} |
|
|
|
switch (cell.getCellType()) { |
|
|
|
case NUMERIC: |
|
|
|
BigDecimal value = BigDecimal.valueOf(cell.getNumericCellValue()); |
|
|
|
return value.setScale(4, RoundingMode.HALF_UP); // 四舍五入保留四位小数 |
|
|
|
case STRING: |
|
|
|
try { |
|
|
|
BigDecimal stringValue = new BigDecimal(cell.getStringCellValue()); |
|
|
|
return stringValue.setScale(4, RoundingMode.HALF_UP); // 四舍五入保留四位小数 |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
throw new RuntimeException("无效的数值格式: " + cell.getStringCellValue()); |
|
|
|
} |
|
|
|
default: |
|
|
|
throw new RuntimeException("不支持的单元格类型: " + cell.getCellType()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |