优化商品导入模块

This commit is contained in:
季圣华
2020-08-16 21:18:42 +08:00
parent 619d4cbe28
commit 6cd19dc94d
2 changed files with 27 additions and 2 deletions

View File

@@ -296,4 +296,17 @@ public class MaterialExtendService {
}
return list;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public Long selectIdByMaterialIdAndDefaultFlag(Long materialId, String defaultFlag)throws Exception {
Long id = 0L;
MaterialExtendExample example = new MaterialExtendExample();
example.createCriteria().andMaterialIdEqualTo(materialId).andDefaultFlagEqualTo(defaultFlag)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<MaterialExtend> list = materialExtendMapper.selectByExample(example);
if(list!=null && list.size()>0) {
id = list.get(0).getId();
}
return id;
}
}

View File

@@ -493,7 +493,13 @@ public class MaterialService {
basicMaterialExtend.setUpdateTime(System.currentTimeMillis());
basicMaterialExtend.setCreateSerial(user.getLoginName());
basicMaterialExtend.setUpdateSerial(user.getLoginName());
materialExtendMapper.insertSelective(basicMaterialExtend);
Long meId = materialExtendService.selectIdByMaterialIdAndDefaultFlag(mId, "1");
if(meId==0L){
materialExtendMapper.insertSelective(basicMaterialExtend);
} else {
basicMaterialExtend.setId(meId);
materialExtendMapper.updateByPrimaryKeySelective(basicMaterialExtend);
}
}
if(StringUtil.isExist(materialExObj.get("other"))) {
String otherStr = materialExObj.getString("other");
@@ -504,7 +510,13 @@ public class MaterialService {
otherMaterialExtend.setUpdateTime(System.currentTimeMillis());
otherMaterialExtend.setCreateSerial(user.getLoginName());
otherMaterialExtend.setUpdateSerial(user.getLoginName());
materialExtendMapper.insertSelective(otherMaterialExtend);
Long meId = materialExtendService.selectIdByMaterialIdAndDefaultFlag(mId, "0");
if(meId==0L){
materialExtendMapper.insertSelective(otherMaterialExtend);
} else {
otherMaterialExtend.setId(meId);
materialExtendMapper.updateByPrimaryKeySelective(otherMaterialExtend);
}
}
//给商品初始化库存
Map<Long, BigDecimal> stockMap = m.getStockMap();