提交 6896c1d7 authored 作者: inroi's avatar inroi

微调

上级 a1a945ac
......@@ -5,7 +5,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author Inori
......@@ -96,8 +98,8 @@ public class BillOfMaterialKingDeeApi {
fEntityMap.put("FMaterialID2", new HashMap<String, Object>(1) {{
put("FNumber", map.get("mtrl_code"));
}});
//用量
fEntityMap.put("FMustQty", map.get("dosage"));
//用量(应发数量)
//fEntityMap.put("FMustQty", map.get("dosage"));
//净需求数量
fEntityMap.put("FStdQty", map.get("nn_qty"));
//实际需求数量
......@@ -111,6 +113,16 @@ public class BillOfMaterialKingDeeApi {
}
}
}
//使用比例
List<Map<String, Object>> tempList = this.tree(list, String.valueOf(map.get("mtrl_code")));
if (!CollectionUtils.isEmpty(tempList)) {
int dosage = tempList.stream().mapToInt(m -> Integer.parseInt(String.valueOf(m.get("dosage")))).sum();
double value = new BigDecimal(Integer.parseInt(String.valueOf(map.get("dosage"))) / dosage).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
fEntityMap.put("FUseRate", value);
} else {
fEntityMap.put("FUseRate", 100);
}
entryList.add(fEntityMap);
}
......@@ -118,5 +130,15 @@ public class BillOfMaterialKingDeeApi {
return modelMap;
}
public List<Map<String, Object>> tree(List<Map<String, Object>> dataList, String code) {
List<Map<String, Object>> tempList = dataList.stream()
.filter(m -> code.equals(String.valueOf(m.get("main_code"))) && !code.equals(String.valueOf(m.get("mtrl_code"))))
.collect(Collectors.toList());
for (Map<String, Object> temp : tempList) {
tempList.addAll(this.tree(dataList, String.valueOf(temp.get("mtrl_code"))));
}
return tempList;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论