A表和B表是一对多关系,B表中有A表中的一个属性存的是id,在对B表进行导入时,Excel中AB两表关联的属性是填入的字面值,在进行导入时怎么处理
你好,
是否参考过文档: 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”, “customer.name”)
.withDateFormat(“dd/MM/yyyy HH:mm”)
.withTransactionStrategy(ImportTransactionStrategy.TRANSACTION_PER_ENTITY)
.build();
如上, 通过 addReferencePropertyMapping
方法添加引用属性映射。
先看看,有问题再沟通。