public void CreateByLayoutAndProject(PedestalInput input) { // 检查台座上是否有梁片,被占用报错 if (_repository.GetAll().Where(q => q.ProjectId == input.ProjectId) .Include(v => v.SubProject) .Any(v => v.SubProject != null)) { throw new UserFriendlyException("台座被占用无法切换台座"); } //如果项目存在布局实例进行删除操作,保证项目布局唯一 //q.WorkshopLayoutId == input.LayoutId var entity = _repository.FirstOrDefault(q => q.ProjectId == input.ProjectId); if (entity != null) { _repository.Delete(q => q.ProjectId == input.ProjectId); } var workshopLayoutEntity = _workshopLayoutRepository.Get(input.LayoutId); WorkshopLayoutInput workshopLayoutInput = new WorkshopLayoutInput(); workshopLayoutInput.IsSave = true; workshopLayoutInput.LayoutId = input.LayoutId; workshopLayoutInput.ProjectId = input.ProjectId; workshopLayoutInput.ProductionLine = workshopLayoutEntity.ProductionLine; workshopLayoutInput.BeamPedestal = workshopLayoutEntity.BeamPedestal; workshopLayoutInput.SaveBeam = workshopLayoutEntity.SaveBeam; workshopLayoutInput.BindRebar = workshopLayoutEntity.BindRebar; _workshopLayoutAppService.Generate(workshopLayoutInput); }
public List <GenerateOutput> Generate(WorkshopLayoutInput input) { List <GenerateOutput> list = new List <GenerateOutput>(); for (int i = 0; i < input.ProductionLine; i++) { #region 返回生成的布局信息 GenerateOutput output = new GenerateOutput(); output.ProductionLine = (i + 1).ToString(); PedestalDto pedestalDto = new PedestalDto(); pedestalDto.ProductionLine = i + 1; //如果要保存到数据库,即生成模板实例, if (input.IsSave) { pedestalDto.WorkshopLayoutId = input.LayoutId; pedestalDto.ProjectId = input.ProjectId; } //左部或上部制梁台 pedestalDto.Area = "LU"; pedestalDto.Type = "ZL"; List <PedestalDto> LU_ZL_blocks = GenerateBlocks(pedestalDto, input.BeamPedestal, input.IsSave); //左部或上部存梁台 pedestalDto.Type = "CL"; List <PedestalDto> LU_CL_blocks = GenerateBlocks(pedestalDto, input.SaveBeam, input.IsSave); //左部或上部钢筋绑扎台 pedestalDto.Type = "GJ"; List <PedestalDto> LU_BZ_blocks = GenerateBlocks(pedestalDto, input.BindRebar, input.IsSave); //右部或下部制梁台 pedestalDto.Area = "RD"; pedestalDto.Type = "ZL"; List <PedestalDto> RD_ZL_blocks = GenerateBlocks(pedestalDto, input.BeamPedestal, input.IsSave); //右部或下部存梁台 pedestalDto.Type = "CL"; List <PedestalDto> RD_CL_blocks = GenerateBlocks(pedestalDto, input.SaveBeam, input.IsSave); //右部或下部钢筋绑扎台 pedestalDto.Type = "GJ"; List <PedestalDto> RD_BZ_blocks = GenerateBlocks(pedestalDto, input.BindRebar, input.IsSave); output.LU_BeamPedestal = LU_ZL_blocks; output.LU_SaveBeam = LU_CL_blocks; output.LU_BindRebar = LU_BZ_blocks; output.RD_BeamPedestal = RD_ZL_blocks; output.RD_SaveBeam = RD_CL_blocks; output.RD_BindRebar = RD_BZ_blocks; list.Add(output); #endregion } return(list); }