解决条码查询报错的bug
This commit is contained in:
@@ -98,7 +98,7 @@ public interface MaterialMapperEx {
|
|||||||
|
|
||||||
List<Material> getMaterialListByUnitIds(@Param("unitIds") String[] unitIds);
|
List<Material> getMaterialListByUnitIds(@Param("unitIds") String[] unitIds);
|
||||||
|
|
||||||
String getMaxBarCode();
|
List<String> getBarCodeList();
|
||||||
|
|
||||||
List<MaterialVo4Unit> getMaterialByMeId(
|
List<MaterialVo4Unit> getMaterialByMeId(
|
||||||
@Param("meId") Long meId);
|
@Param("meId") Long meId);
|
||||||
|
|||||||
@@ -1307,12 +1307,15 @@ public class MaterialService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getMaxBarCode() {
|
public String getMaxBarCode() {
|
||||||
String maxBarCodeOld = materialMapperEx.getMaxBarCode();
|
List<String> barCodeOldList = materialMapperEx.getBarCodeList();
|
||||||
if(StringUtil.isNotEmpty(maxBarCodeOld)) {
|
// 使用 Stream API 处理条码列表
|
||||||
return Long.parseLong(maxBarCodeOld)+"";
|
OptionalLong maxBarcode = barCodeOldList.stream()
|
||||||
} else {
|
.filter(StringUtil::isNumeric) // 过滤掉非数字条码
|
||||||
return "1000";
|
.mapToLong(Long::parseLong) // 将字符串转换为 Long 类型
|
||||||
}
|
.max(); // 获取最大值
|
||||||
|
// 如果存在最大值,返回它;否则返回 1000L
|
||||||
|
Long maxBarCodeOld = maxBarcode.orElse(1000L);
|
||||||
|
return maxBarCodeOld + "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getMaterialNameList() {
|
public List<String> getMaterialNameList() {
|
||||||
|
|||||||
@@ -444,4 +444,17 @@ public class StringUtil {
|
|||||||
return originStr.replaceAll("(?i)" + regex, "");
|
return originStr.replaceAll("(?i)" + regex, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断字符串是否为纯数字
|
||||||
|
* @param str 输入的字符串
|
||||||
|
* @return 如果字符串为纯数字,返回 true;否则返回 false
|
||||||
|
*/
|
||||||
|
public static boolean isNumeric(String str) {
|
||||||
|
if (str == null || str.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 使用正则表达式判断字符串是否为纯数字
|
||||||
|
return str.matches("\\d+");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -524,10 +524,9 @@
|
|||||||
and ifnull(delete_flag,'0') !='1'
|
and ifnull(delete_flag,'0') !='1'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getMaxBarCode" resultType="java.lang.String">
|
<select id="getBarCodeList" resultType="java.lang.String">
|
||||||
select max(CAST(me.bar_code AS SIGNED)) bar_code from jsh_material_extend me
|
select me.bar_code from jsh_material_extend me
|
||||||
where 1=1
|
where ifnull(me.delete_Flag,'0') !='1'
|
||||||
and ifnull(me.delete_Flag,'0') !='1'
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getMaterialByMeId" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
|
<select id="getMaterialByMeId" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
|
||||||
@@ -790,4 +789,5 @@
|
|||||||
and ifnull(m.delete_flag,'0') !='1'
|
and ifnull(m.delete_flag,'0') !='1'
|
||||||
limit 0,1
|
limit 0,1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user