我有以下功能,即使订单状态验证中存在错误,也会在db中插入空列表。我怀疑它是因为for循环在用户点击屏幕中的提交按钮后被调用多次,但无法找到多次调用该函数的跟踪,
for (int i=0; i<unassigned.getCount(); i++){
refund = unassigned.getRefund(i);
orderRefNum = refund.getOrderRefNum();
if (refund.getStatus()==Order.NOT_PRINTED){
boolean result = updateRefundList();
colOfRefunds.add(refund);
updateNewOrAmended(refund);
} else {
log.info("Error in validating Order");
}
}
if (colOfRefunds.size()>0){
updateRefundListTable();
if (listNumbersCount>0){
listNumbersString += "|";
}
listNumbersString += refundListRefNum;
listNumbersCount++;
}
现在我移动了在for循环中插入空结果集的条件,如下所示,并且不确定它在我的实时环境中如何工作,因为我没有任何本地或非prod环境来测试逻辑,
for (int i=0; i<unassigned.getCount(); i++){
refund = unassigned.getRefund(i);
orderRefNum = refund.getOrderRefNum();
if (refund.getStatus()==Order.NOT_PRINTED){
boolean result = updateRefundList();
colOfRefunds.add(refund);
updateNewOrAmended(refund);
if (colOfRefunds.size()>0){
updateRefundListTable();
if (listNumbersCount>0){
listNumbersString += "|";
}
listNumbersString += refundListRefNum;
listNumbersCount++;
}
} else {
log.info("Error in validating Order");
}
}
所以,只是想澄清上述更改是否会导致列表创建中的任何问题,或者是否会像以前的逻辑那样按预期工作。