解决商品导入excel,如果单个单位切换多个单位遇到的bug

This commit is contained in:
jishenghua 2024-11-18 23:27:22 +08:00
parent fd057938b9
commit 9726c47d31

View File

@ -716,6 +716,7 @@ public class MaterialService {
Long unitId = unitService.getUnitIdByParam(unit, manyUnit, new BigDecimal(ratio.trim())); Long unitId = unitService.getUnitIdByParam(unit, manyUnit, new BigDecimal(ratio.trim()));
if(unitId != null) { if(unitId != null) {
m.setUnitId(unitId); m.setUnitId(unitId);
m.setUnit("");
} else { } else {
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_MATE_CODE, throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_MATE_CODE,
String.format(ExceptionConstants.MATERIAL_UNIT_MATE_MSG, manyBarCode)); String.format(ExceptionConstants.MATERIAL_UNIT_MATE_MSG, manyBarCode));
@ -730,6 +731,7 @@ public class MaterialService {
materialExObj.put("other", otherObj); materialExObj.put("other", otherObj);
} else { } else {
m.setUnit(unit); m.setUnit(unit);
m.setUnitId(null);
} }
m.setMaterialExObj(materialExObj); m.setMaterialExObj(materialExObj);
m.setEnabled("1".equals(enabled)); m.setEnabled("1".equals(enabled));
@ -771,6 +773,14 @@ public class MaterialService {
Material material = JSONObject.parseObject(materialJson, Material.class); Material material = JSONObject.parseObject(materialJson, Material.class);
material.setId(mId); material.setId(mId);
materialMapper.updateByPrimaryKeySelective(material); materialMapper.updateByPrimaryKeySelective(material);
//更新多单位
if(material.getUnitId() == null) {
materialMapperEx.setUnitIdToNull(material.getId());
}
//如果之前有保质期则更新保质期
if(materials.get(0).getExpiryNum()!=null && material.getExpiryNum() == null) {
materialMapperEx.setExpiryNumToNull(material.getId());
}
} }
//给商品新增或更新条码与价格相关信息 //给商品新增或更新条码与价格相关信息
JSONObject materialExObj = m.getMaterialExObj(); JSONObject materialExObj = m.getMaterialExObj();