是否参考过文档: jmix/jmix-dataimport at master · jmix-framework/jmix · GitHub

Import configuration:

Values for the “number”, “date”, “amount” properties are taken from the “Order Number”, “Order Date”, “Order Amount” columns respectively.

The “customer” property is a reference property represented in the input data by one property - “name”. The value for the “name” property contains in the “Customer Name” column. The “name” property is a lookup property by which an existing customer will be searched. If an existing customer is not found by name, a new one is NOT created (because of ReferenceImportPolicy.IGNORE_IF_MISSING).

Before import, it is checked whether there is an order with the same number, date, and customer name. If such an order exists, the number, date, amount, and customer name will be updated by values from input data.

ImportConfiguration importConfiguration = ImportConfiguration.builder(Order.class, InputDataFormat.XLSX)
.addSimplePropertyMapping(“number”, “Order Number”)
.addSimplePropertyMapping(“date”, “Order Date”)
.addSimplePropertyMapping(“amount”, “Order Amount”)
.addReferencePropertyMapping(“customer”, “Customer Name”, “name”, ReferenceImportPolicy.IGNORE_IF_MISSING)
.addUniqueEntityConfiguration(DuplicateEntityPolicy.UPDATE, “number”, “date”, “”)
.withDateFormat(“dd/MM/yyyy HH:mm”)

如上, 通过 addReferencePropertyMapping 方法添加引用属性映射。