private async Task BuildDataByMaterialAsync(TDCheckConditionDTO model, TD_Check data) { var _Op = _provider.GetRequiredService <IOperator>(); var materialList = (from u in model.MaterialIdList select new TD_CheckMaterial() { CheckId = data.Id, MaterialId = u }).Distinct().ToList(); await _provider.GetRequiredService <ITD_CheckMaterialBusiness>().PushAsync(materialList); var localList = await _provider.GetRequiredService <IIT_LocalMaterialBusiness>() .LoadCheckDataByMaterialAsync(_Op.Property.DefaultStorageId, model.MaterialIdList); var checkdata = (from u in localList select new TD_CheckData() { BatchNo = u.BatchNo, CheckId = data.Id, CreateTime = DateTime.Now, CreatorId = _Op.UserId, Id = IdHelper.GetId(), localId = u.LocalId, LocalNum = u.Num, MaterialId = u.MaterialId, StorId = u.StorId }).ToList(); await _provider.GetRequiredService <ITD_CheckDataBusiness>().PushDataAsync(checkdata); }
public async Task PushData(TDCheckConditionDTO model) { var _Op = _provider.GetRequiredService <IOperator>(); var data = model.Data; if (data.Id.IsNullOrEmpty()) { InitEntity(data); data.StorId = _Op.Property.DefaultStorageId; data.EquId = "1"; data.IsComplete = false; data.Status = 0; if (string.IsNullOrWhiteSpace(data.Code)) { data.Code = await _provider.GetRequiredService <IPB_BarCodeTypeBusiness>().Generate("TD_Check"); } await _tD_CheckBus.AddDataAsync(data); } else { await _tD_CheckBus.UpdateDataAsync(data); await _provider.GetRequiredService <ITD_CheckDataBusiness>().ClearDataAsync(data.Id); await _provider.GetRequiredService <ITD_CheckMaterialBusiness>().ClearDataAsync(data.Id); await _provider.GetRequiredService <ITD_CheckAreaBusiness>().ClearDataAsync(data.Id); } if (data.Type == "Storage") { var arealist = await _provider.GetRequiredService <IPB_StorAreaBusiness>().QueryAsync(_Op.Property.DefaultStorageId); await BuildDataByAreaAsync((from u in arealist select u.Id).ToList(), data); } else if (data.Type == "Area") { await BuildDataByAreaAsync(model.AreaIdList, data); } else if (data.Type == "Material" || data.Type == "Random") { await BuildDataByMaterialAsync(model, data); } }