|
|
|
|
@ -19,6 +19,7 @@ import org.dromara.mes.domain.vo.ProdRecipeInfoVo;
|
|
|
|
|
import org.dromara.mes.domain.vo.ProdRecipeWeightVo;
|
|
|
|
|
import org.dromara.mes.domain.vo.ProdRecipeMixingVo;
|
|
|
|
|
import org.dromara.mes.domain.vo.RecipeDetailVo;
|
|
|
|
|
import org.dromara.mes.domain.vo.RecipeTreeNodeVo;
|
|
|
|
|
import org.dromara.mes.domain.ProdRecipeInfo;
|
|
|
|
|
import org.dromara.mes.mapper.ProdRecipeInfoMapper;
|
|
|
|
|
import org.dromara.mes.service.IProdRecipeInfoService;
|
|
|
|
|
@ -29,6 +30,8 @@ import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -317,4 +320,49 @@ public class ProdRecipeInfoServiceImpl implements IProdRecipeInfoService {
|
|
|
|
|
return detail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<RecipeTreeNodeVo> queryRecipeTree(ProdRecipeInfoBo bo) {
|
|
|
|
|
bo.setRecipeState("1");
|
|
|
|
|
List<ProdRecipeInfoVo> recipeList = queryList(bo);
|
|
|
|
|
if (recipeList == null || recipeList.isEmpty()) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
List<RecipeTreeNodeVo> treeList = new ArrayList<>();
|
|
|
|
|
for (ProdRecipeInfoVo recipe : recipeList) {
|
|
|
|
|
Long recipeId = recipe.getRecipeId();
|
|
|
|
|
String recipeCode = StringUtils.isNotBlank(recipe.getRecipeCode()) ? recipe.getRecipeCode() : "未命名";
|
|
|
|
|
// 查询该配方的称量信息
|
|
|
|
|
ProdRecipeWeightBo weightQuery = new ProdRecipeWeightBo();
|
|
|
|
|
weightQuery.setRecipeId(recipeId);
|
|
|
|
|
List<ProdRecipeWeightVo> weights = prodRecipeWeightService.queryList(weightQuery);
|
|
|
|
|
// 按称量序号顺序构建子节点,仅显示物料名称(queryList 已关联物料表查询物料名称)
|
|
|
|
|
Set<String> addedNames = new HashSet<>();
|
|
|
|
|
List<RecipeTreeNodeVo> children = new ArrayList<>();
|
|
|
|
|
for (ProdRecipeWeightVo w : weights) {
|
|
|
|
|
Long childCode = w.getChildCode();
|
|
|
|
|
if (childCode == null) continue;
|
|
|
|
|
String materialName = StringUtils.isNotBlank(w.getMaterialName()) ? w.getMaterialName() : "未知物料";
|
|
|
|
|
if (addedNames.add(materialName)) {
|
|
|
|
|
RecipeTreeNodeVo child = new RecipeTreeNodeVo();
|
|
|
|
|
child.setId("mat_" + recipeId + "_" + childCode);
|
|
|
|
|
child.setLabel(materialName);
|
|
|
|
|
child.setRecipeId(recipeId);
|
|
|
|
|
child.setRecipeCode(recipeCode);
|
|
|
|
|
child.setMaterialId(childCode);
|
|
|
|
|
child.setMaterialName(materialName);
|
|
|
|
|
children.add(child);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RecipeTreeNodeVo parent = new RecipeTreeNodeVo();
|
|
|
|
|
parent.setId("recipe_" + recipeId);
|
|
|
|
|
parent.setLabel(recipeCode);
|
|
|
|
|
parent.setRecipeCode(recipeCode);
|
|
|
|
|
parent.setRecipeId(recipeId);
|
|
|
|
|
parent.setData(recipe);
|
|
|
|
|
parent.setChildren(children.isEmpty() ? null : children);
|
|
|
|
|
treeList.add(parent);
|
|
|
|
|
}
|
|
|
|
|
return treeList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|