update 配方新增跳转维护页面

master
yinq 4 days ago
parent 1586a6e853
commit aed2afd549

@ -131,11 +131,11 @@ public class ProdRecipeInfoController extends BaseController {
/** /**
* ++ * ++
*/ */
@SaCheckPermission("mes:recipeInfo:edit") @SaCheckPermission({"mes:recipeInfo:add", "mes:recipeInfo:edit"})
@Log(title = "配方明细", businessType = BusinessType.UPDATE) @Log(title = "配方明细", businessType = BusinessType.UPDATE)
@RepeatSubmit() @RepeatSubmit()
@PostMapping("/saveDetail") @PostMapping("/saveDetail")
public R<Void> saveDetail(@Validated @RequestBody RecipeDetailSaveBo bo) { public R<Long> saveDetail(@Validated @RequestBody RecipeDetailSaveBo bo) {
return toAjax(prodRecipeInfoService.saveDetail(bo)); return R.ok(prodRecipeInfoService.saveDetail(bo));
} }
} }

@ -73,9 +73,9 @@ public interface IProdRecipeInfoService {
* ++ * ++
* *
* @param bo * @param bo
* @return * @return IDIDID
*/ */
Boolean saveDetail(RecipeDetailSaveBo bo); Long saveDetail(RecipeDetailSaveBo bo);
/** /**
* ID * ID

@ -205,14 +205,20 @@ public class ProdRecipeInfoServiceImpl implements IProdRecipeInfoService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean saveDetail(RecipeDetailSaveBo bo) { public Long saveDetail(RecipeDetailSaveBo bo) {
ProdRecipeInfoBo recipeInfo = bo.getRecipeInfo(); ProdRecipeInfoBo recipeInfo = bo.getRecipeInfo();
if (recipeInfo == null || recipeInfo.getRecipeId() == null) { if (recipeInfo == null) {
throw new IllegalArgumentException("配方ID不能为空"); throw new IllegalArgumentException("配方基本信息不能为空");
} }
Long recipeId = recipeInfo.getRecipeId(); Long recipeId = recipeInfo.getRecipeId();
// 新增时 recipeId 为空,先创建配方
if (recipeId == null) {
insertByBo(recipeInfo);
recipeId = recipeInfo.getRecipeId();
} else {
// 1. 更新配方基本信息 // 1. 更新配方基本信息
updateByBo(recipeInfo); updateByBo(recipeInfo);
}
// 2. 称量信息:有主键则更新,无主键则插入;删除提交列表中已不存在的原记录 // 2. 称量信息:有主键则更新,无主键则插入;删除提交列表中已不存在的原记录
List<ProdRecipeWeightBo> weightList = bo.getWeightList() != null ? bo.getWeightList() : new ArrayList<>(); List<ProdRecipeWeightBo> weightList = bo.getWeightList() != null ? bo.getWeightList() : new ArrayList<>();
@ -291,7 +297,7 @@ public class ProdRecipeInfoServiceImpl implements IProdRecipeInfoService {
prodRecipeMixingService.insertByBo(m); prodRecipeMixingService.insertByBo(m);
} }
} }
return true; return recipeId;
} }
@Override @Override

Loading…
Cancel
Save