bom: 修复 BOM 版本号计算异常
- 优化了 BOM 版本号计算逻辑,确保在查询不到数据时默认版本号为 1 - 使用 BigInteger 替代 Long 类型,避免数据类型转换异常 - 重构了代码结构,提高了可读性和维护性
This commit is contained in:
		
							parent
							
								
									d75f090ab0
								
							
						
					
					
						commit
						6d7e67b8bf
					
				| 
						 | 
				
			
			@ -1600,15 +1600,14 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
 | 
			
		|||
            sql.append("AND hcmaterialid = ? ");
 | 
			
		||||
            param.addParam(hcmaterialid);
 | 
			
		||||
 | 
			
		||||
			// 只查询数字版本号,排除非数字版本
 | 
			
		||||
            // 只查询数字版本号,排除非数字版本
 | 
			
		||||
            sql.append("AND REGEXP_LIKE(hversion, '^[0-9]+$') ");
 | 
			
		||||
            // 如果查询不到数据,默认版本号为1;否则最大版本号加1
 | 
			
		||||
            Object mayBeNullVersion = DAO.executeQuery(sql.toString(), param, new ColumnProcessor());
 | 
			
		||||
            String number = Objects.isNull(mayBeNullVersion) ? "1" : DAO.executeQuery(sql.toString(), param, new ColumnProcessor()).toString();
 | 
			
		||||
            return String.valueOf(Long.parseLong(number)+1);
 | 
			
		||||
 | 
			
		||||
			Long maxVersion = (Long) DAO.executeQuery(sql.toString(), param, new ColumnProcessor());
 | 
			
		||||
 | 
			
		||||
			// 如果查询不到数据,默认版本号为1;否则最大版本号加1
 | 
			
		||||
			return String.valueOf((maxVersion != null ? maxVersion : 0) + 1);
 | 
			
		||||
 | 
			
		||||
		} catch (Exception e) {
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
			throw new BusinessException("计算BOM版本号异常:" + e.getMessage());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue