abp(net core)+easyui+efcore实现仓储管理系统——模块管理升级之上(六十一)

科技资讯 投稿 7300 0 评论

abp(net core)+easyui+efcore实现仓储管理系统——模块管理升级之上(六十一)

abp(net core+easyui+efcore实现仓储管理系统——ABP总体介绍(一)
abp(net core+easyui+efcore实现仓储管理系统——解决方案介绍(二
abp(net core+easyui+efcore实现仓储管理系统——领域层创建实体(三
 abp(net core+easyui+efcore实现仓储管理系统——定义仓储并实现 (四
abp(net core+easyui+efcore实现仓储管理系统——创建应用服务(五)
abp(net core+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十一
abp(net core+easyui+efcore实现仓储管理系统——EasyUI之货物管理一 (十九
abp(net core+easyui+efcore实现仓储管理系统——ABP WebAPI与EasyUI结合增删改查之一(二十七
abp(net core+easyui+efcore实现仓储管理系统——入库管理之一(三十七
abp(net core+easyui+efcore实现仓储管理系统——出库管理之一(四十九
abp(net core+easyui+efcore实现仓储管理系统——ABP升级7.3上(五十八

 

      有了前一篇文章(abp(net core+easyui+efcore实现仓储管理系统——模块管理升级(六十,对于模块管理的升级过程中解决升级中出现的问题的一些经验。我们对组织管理这个模块进行升级。

一、添加Profile定义文件

   1. 在Visual Studio 2022的“解决方案资源管理器”中,右键单击“ABP.TPLMS.Application”项目,使用鼠标左键展开“Orgs” > “Dto”文件夹

  2. 使用鼠标右键单击“Dto”文件夹,然后选择“添加” > “类”。 将类命名为 OrgMapProfile,然后选择“添加”。代码如下。

using ABP.TPLMS.Authorization.Users; using ABP.TPLMS.Entitys; using ABP.TPLMS.Users.Dto; using AutoMapper; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABP.TPLMS.Orgs.Dto { public class OrgMapProfile:Profile { public OrgMapProfile( { CreateMap<OrgDto, Org>(; CreateMap<OrgDto, CreateUpdateOrgDto>(; CreateMap<CreateUpdateOrgDto, Org>(; } } }

 

二、修改OrgAppService类

   3.在Visual Studio 2022的“解决方案资源管理器”中,在“Orgs”文件夹中找到OrgAppService.cs文件,双击在文本编辑器中打开,修改代码如下。

using Abp.Application.Services; using Abp.Application.Services.Dto; using Abp.Domain.Repositories; using Abp.Web.Models; using ABP.TPLMS.Entitys; using ABP.TPLMS.Modules.Dto; using ABP.TPLMS.Orgs.Dto; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABP.TPLMS.Orgs { public class OrgAppService : AsyncCrudAppService<Org, OrgDto, int, PagedOrgResultRequestDto, CreateUpdateOrgDto, CreateUpdateOrgDto>, IOrgAppService { public OrgAppService(IRepository<Org, int> repository : base(repository { } [DontWrapResult] public PagedOrgResultDto<OrgDto> GetAllOrgs(PagedOrgResultRequestDto input { PagedOrgResultDto<OrgDto> orgs = new PagedOrgResultDto<OrgDto>(; input.SkipCount = 0;//这里需要进行参数传递 input.MaxResultCount= 1000; var allOrgs=GetAllAsync(input; IReadOnlyList<OrgDto> result = AddParentOrgs(input, allOrgs.Result.Items.AsReadOnly(; orgs.Rows = result; orgs.Total = result.Count; return orgs; } private List<OrgDto> AddParentOrgs(PagedOrgResultRequestDto input,IReadOnlyList<OrgDto> list { List<OrgDto> result = new List<OrgDto>(; if (list == null return result; var qry1 = base.CreateFilteredQuery(input; List<Org> listParent = new List<Org>(; GetParentOrgs(listParent, list[0].ParentId, qry1; foreach (var item in listParent { result.Add(ObjectMapper.Map<OrgDto>(item; } result.AddRange(list.ToArray(; return result; } protected override IQueryable<Org> CreateFilteredQuery(PagedOrgResultRequestDto input { var qry = base.CreateFilteredQuery(input .Where(t => t.Name.Contains(input.OrgName == null ? string.Empty : input.OrgName .Where(t => t.BizCode.Contains(input.OrgCode == null ? string.Empty : input.OrgCode .Where(t => t.CustomCode.Contains(input.CustomCode == null ? string.Empty : input.CustomCode; return qry; } private void GetParentOrgs(List<Org> orgs, int ParentId, IQueryable<Org> listOrgs { List<Org> drs = listOrgs.Where(x => x.Id == ParentId.ToList(; if (drs == null || drs.Count <= 0 { return; } else { for (int i = 0; i < drs.Count; i++ { var dr = drs[i]; if (!orgs.Contains(dr { orgs.Add(dr; } GetParentOrgs(orgs, dr.ParentId, listOrgs; } } } } }

4. 上面代码中需要特别注意的一点,是GetAllOrgs方法中的input.SkipCount=0这一行代码,如果将这一行代码注释掉,在进行条件查询时,会报错。在组织管理页面的海关代码中输入“2011”,然后点击“查询”按钮。如下图。

5.Visual Studio 2022会弹出一个用记未处理的异常,错误信息,如下图。

 

    6.在Visual Studio 2022的解决方案资源管理器中,将刚才注释掉的那一条代码“input.SkipCount=0”,还原。按F5运行应用程序。

   7.在浏览器中的登录页面中输入管理员用户名和密码进行登录。

   8.在主界面的菜单中,选择“Business->组织管理”菜单项,浏览器中呈现一个组织信息列表与四个按钮。组织信息能正常显示。如下图。

  9. 在“组织管理”列表页面的海关代码输入框中输入“2011”,然后点击“查询”按钮。如下图。

10.这一次程序运行正常,查询出了结果,结果如下图。

11.在“组织管理”列表页面中使用鼠标点击“添加”按钮,弹出“添加组织信息”界面。如下图。

 

12.在“添加组织信息”中填写完信息,然后点击“保存”按钮,将新添加的组织信息保存到数据库。如下图。

 

 

 

编程笔记 » abp(net core)+easyui+efcore实现仓储管理系统——模块管理升级之上(六十一)

赞同 (38) or 分享 (0)
游客 发表我的评论   换个身份
取消评论

表情
(0)个小伙伴在吐槽