| | |
| | | return request.SetIsDisabled<DictionaryData>(cancellationToken: cancellationToken); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 同步人力资源地区字典数据 |
| | | /// </summary> |
| | | /// <param name="request"></param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public async Task<int> Handle(SyncHumanResourcesAreaDictionaryDataCommand request, CancellationToken cancellationToken) |
| | | { |
| | | var repHumanResourcesBaseArea = Db.GetRepository<BaseArea, HumanResourcesDbContextLocator>(); |
| | |
| | | CategoryId = categoryId |
| | | }); |
| | | var parentAreas = areas.Where(it => it.ParentId == 0).ToList(); |
| | | LoopAdd(categoryId, entities, areas, parentAreas); |
| | | LoopSyncHumanResourcesAreaDictionaryData(categoryId, entities, areas, parentAreas); |
| | | await rep.Context.BulkInsertAsync(entities); |
| | | return entities.Count; |
| | | } |
| | | |
| | | public void LoopAdd(Guid categoryId, List<DictionaryData> entities, List<BaseArea> all, List<BaseArea> areas) |
| | | /// <summary> |
| | | /// 递归同步人力资源地区字典数据 |
| | | /// </summary> |
| | | /// <param name="categoryId"></param> |
| | | /// <param name="entities"></param> |
| | | /// <param name="all"></param> |
| | | /// <param name="areas"></param> |
| | | private void LoopSyncHumanResourcesAreaDictionaryData(Guid categoryId, List<DictionaryData> entities, List<BaseArea> all, List<BaseArea> areas) |
| | | { |
| | | if (areas.IsNotNull()) |
| | | { |
| | |
| | | entities.Add(entity); |
| | | |
| | | var children = all.Where(it => it.ParentId == area.AreaCode).ToList(); |
| | | LoopAdd(categoryId, entities, all, children); |
| | | LoopSyncHumanResourcesAreaDictionaryData(categoryId, entities, all, children); |
| | | } |
| | | } |
| | | } |