mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
初始化货品单位
This commit is contained in:
@@ -20,6 +20,9 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
@@ -68,4 +71,26 @@ public class WarehouseGoodsUnitService
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
|
||||
public void init(String orgId) {
|
||||
|
||||
List<WarehouseGoodsUnitEntity> all = this.repository.findByOrganizationId(orgId);
|
||||
|
||||
if (!all.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> units = Set.of(
|
||||
"吨", "千克", "克", "升", "毫升", "个", "件", "台", "套", "箱", "包", "袋", "桶", "瓶", "罐", "卷",
|
||||
"支", "根", "条", "片", "块", "颗", "粒", "对", "双", "只", "张", "本", "盒");
|
||||
|
||||
|
||||
for (String unit : units) {
|
||||
WarehouseGoodsUnitEntity entity = new WarehouseGoodsUnitEntity();
|
||||
entity.setName(unit);
|
||||
entity.setOrganizationId(orgId);
|
||||
this.repository.save(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user