for each piSubformRecord in piSubform
{
mp = Map();
mp.put("id",piSubformRecord.get("id"));
//获取PI单子表单的产品代码
piProductId = piSubformRecord.get("field").get("id");
info piProductId;
fanHao = piSubformRecord.get("field17");
info "番号:" + fanHao;
piPaichan = 0;
//如果有排产单相关列表
if(piRelatedList.size() > 0)
{
//遍历排产单
//根据产品代码id和番号调用接口查找排产单明细表
for each paiChan in piRelatedList
{
//获取排产单Id,
parentId = paiChan.get("id");
//调用接口查找排产产品明细中已排产数量
map = {"select_query":"select id,field1 from LinkingModule4 where (field.id = '" + piProductId + "' and Parent_Id='" + parentId + "') and field5='" + fanHao + "' "};
resp = invokeurl
[
type :POST
parameters:map.toString()
connection:"crm"
];
info "查询结果:" + resp;
if(!resp.isNull())
{
data = resp.get("data");
for each paiChanProduct in data
{
//更新PI单子表单的已排产数量
piPaichan = piPaichan + paiChanProduct.get("field1");
}
}
}
}
info "已排产数量:" + piPaichan;
mp.put("field13",piPaichan);
list1.add(mp);
info list1;
}