用友NC在获取单据行的操作上还是很方便的,前提是你得拿到卡片面板。
BillCardPanel bcp = editor.getBillCardPanel();
// 获取表体选择的行
int[] rows = bcp.getBillTable().getSelectedRows();
// 表体行数量
int rowCount = bcp.getBillTable().getRowCount();
// 没有选择行的时候直接获取全部值
if (rows.length == 0 && rowCount > 0) {
for (int i = 0; i < rowCount; i++) {
CircularlyAccessibleValueObject row = bcp.getBillModel().getBodyValueRowVO(i, SaleOrderBVO.class.getName());
Product product = processProduct(row);
products.add(product);
}
} else {
for (int i = 0; i < rows.length; i++) {
CircularlyAccessibleValueObject row = bcp.getBillModel().getBodyValueRowVO(rows[i], SaleOrderBVO.class.getName());
Product product = processProduct(row);
products.add(product);
}
}
/**
* 转换销售订单行为配送任务商品信息
* @param row
* @return
*/
private Product processProduct(CircularlyAccessibleValueObject row) {
Product product = new CreateDeliveryTaskDTO.Product();
String materialId = WuTools.getString(row.getAttributeValue(SaleOrderBVO.CMATERIALID));
SuperVO material = null;
try {
material = HYPubBO_Client.queryByPrimaryKey(MaterialVO.class, materialId);
product.setProductCode(WuTools.getString(material.getAttributeValue(MaterialVO.CODE)));
product.setProductDesc(WuTools.getString(material.getAttributeValue(MaterialVO.NAME)));
} catch (UifException e) {
e.printStackTrace();
}
product.setIsSample(0);
product.setProductId(materialId);
product.setQuantity(WuTools.getUFD(row.getAttributeValue(SaleOrderBVO.NASTNUM)).intValue());
product.setReturnNum(0); // 退货数量
return product;
}
文章评论