abp(net core)+easyui+efcore實現倉儲管理系統——出庫管理之三(五十二)

abp(net core)+easyui+efcore實現倉儲管理系統目錄

abp(net core)+easyui+efcore實現倉儲管理系統——EasyUI前端頁面框架 (十八) html

abp(net core)+easyui+efcore實現倉儲管理系統——出庫管理之三(五十一)
 

    咱們已經在ABP中實現瞭如何調用存儲過程的方法 ,接下來咱們要來實現應用層的具體代碼。前端

 

6、定義應用層接口

1. 在Visual Studio 2017的「解決方案資源管理器」中,鼠標右鍵單擊「OutStocks」文件夾,而後選擇「添加」 > 「新建項」,在彈出對話框中選擇「接口」。爲應用服務定義一個名爲 IOutStockOrderAppService 的接口。代碼以下。app

using System; using System.Collections.Generic; using System.Text; using Abp.Application.Services; using ABP.TPLMS.OutStocks.Dto; namespace ABP.TPLMS.OutStocks { public  interface IOutStockOrderAppService : IAsyncCrudAppService<//定義了CRUD方法
             OutStockOrderDto, //用來展現出庫單信息
             int, //出庫單實體的主鍵
             PagedOutStockResultRequestDto, //獲取出庫單信息的時候用於分頁
             CreateUpdateOutStockOrderDto, //用於建立出庫單信息
             CreateUpdateOutStockOrderDto> //用於更新出庫單信息
 { /// <summary>
        /// 建立單號 /// </summary>
        /// <returns></returns>

        string GetNo(); /// <summary>
        /// 保存出庫單數據 /// </summary>
        /// <param name="iso"></param>
        /// <returns></returns>
        string Save(OutStockOrderDto iso); /// <summary>
        /// 導入貨物信息 /// </summary>
        /// <param name="ids">導出庫貨物信息的ID</param>
        /// <param name="No">出庫單單號</param>
        /// <returns></returns>
        string ImportInStockDetail(string ids,string No); /// <summary>
        /// 批量刪除 /// </summary>
        /// <param name="ids">出庫單ID集合</param>
        /// <returns></returns>
        bool DeleteById(string ids); } }

 

2. 在Visual Studio 2017的「解決方案資源管理器」中,鼠標右鍵單擊「OutStocks」文件夾,而後選擇「添加」 > 「新建項」,在彈出對話框中選擇「接口」。爲應用服務定義一個名爲 IOutStockOrderDetailAppService 的接口。代碼以下。框架

using System; using System.Collections.Generic; using System.Text; using Abp.Application.Services; using ABP.TPLMS.OutStocks.Dto; namespace ABP.TPLMS.OutStocks { public  interface IOutStockOrderDetailAppService : IAsyncCrudAppService<//定義了CRUD方法 OutStockOrderDetailDto, //用來展現出庫單明細信息
             int, //出庫單實體的主鍵
             PagedOutStockDetailResultRequestDto, //獲取出庫單信息的時候用於分頁
             CreateUpdateOutStockOrderDetailDto, //用於建立出庫單明細信息
              CreateUpdateOutStockOrderDetailDto > //用於更新出庫單明細信息
 { } } 

 


7、實現OutStockOrderAppService

    3.在Visual Studio 2017的「解決方案資源管理器」中,右鍵單擊「OutStocks」文件夾,而後選擇「添加」 > 「新建項」,在彈出對話框中選擇「類」。爲應用服務定義一個名爲 OutStockOrderAppService 的服務類,實現IOutStockOrderAppService接口中的方法。特別注意在構造函數中定義IOutStockOrderRepository 接口,方便注入代碼以下。ide

using Abp.Application.Services; using Abp.Application.Services.Dto; using Abp.Domain.Repositories; using Abp.Web.Models; using ABP.TPLMS.Entitys; using ABP.TPLMS.OutStocks.Dto; using ABP.TPLMS.IRepositories; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABP.TPLMS.OutStocks { public class OutStockOrderAppService : AsyncCrudAppService<OutStockOrder, OutStockOrderDto, 
int, PagedOutStockResultRequestDto, CreateUpdateOutStockOrderDto, CreateUpdateOutStockOrderDto>,
IOutStockOrderAppService { IOutStockOrderRepository rep
= null; IOutStockOrderDetailAppService outDetApp=null; public OutStockOrderAppService(IRepository<OutStockOrder, int> repository, IOutStockOrderRepository isdRepository,IOutStockOrderDetailAppService outodAppser) : base(repository) { rep = isdRepository; outDetApp = outodAppser; } public override Task<PagedResultDto<OutStockOrderDto>> GetAll
(PagedOutStockResultRequestDto input) {
return base.GetAll(input); } [DontWrapResult] public PagedOutStockOrderResultDto<OutStockOrderDto> GetAllOutStockOrders
(PagedOutStockResultRequestDto input) { PagedOutStockOrderResultDto
<OutStockOrderDto> outODs =
new PagedOutStockOrderResultDto<OutStockOrderDto>(); var allOrgs=GetAll(input); outODs.Rows = allOrgs.Result.Items; outODs.Total = allOrgs.Result.TotalCount; return outODs; } protected override IQueryable<OutStockOrder> CreateFilteredQuery
(PagedOutStockResultRequestDto input) {
var qry= base.CreateFilteredQuery(input) .Where(t=>t.OwnerName.Contains(input.OwnerName==null?string.Empty:input.OwnerName)) .Where(t => t.No.Contains(input.No == null ? string.Empty : input.No)) .Where(t => t.CreationTime>input.BeginTime) .Where(t => t.CreationTime<input.EndTime); return qry; } [DontWrapResult] public string GetNo() { string no = rep.GetNo("ODO"); return no; } [DontWrapResult] public string ImportInStockDetail(string ids,string No) { try { //導入貨物信息 rep.ImportInStockOrder(ids, No); } catch (Exception ex) { throw ex; } return "OK"; } public string Save(OutStockOrderDto iso) { try { CreateUpdateOutStockOrderDto order =
ObjectMapper.Map<CreateUpdateOutStockOrderDto>(iso); foreach (var item in order.OutStockOrderDetail) { CreateUpdateOutStockOrderDetailDto outODet =
ObjectMapper.Map<CreateUpdateOutStockOrderDetailDto>(item); if (outODet.Id > 0) { outDetApp.Update(outODet); } else outDetApp.Create(outODet); } order.OutStockOrderDetail = null; order.Status = 1 ; Update(order); } catch (Exception ex) { throw ex; } return "OK"; } public bool DeleteById(string Ids) { var idList = Ids.Split(','); bool result = true; try { foreach (var id in idList) { int.TryParse(id, out int intId); var odo = GetEntityByIdAsync(intId).GetAwaiter().GetResult(); PagedOutStockDetailResultRequestDto PagedDetail =
new PagedOutStockDetailResultRequestDto { InStockNo = odo.No }; var isods = outDetApp.GetAll(PagedDetail).GetAwaiter().GetResult(); OutStockOrderDto order = ObjectMapper.Map<OutStockOrderDto>(odo); Delete(order); } } catch (Exception ex) { result = false; throw ex; } return result; } } }

 


  4.在Visual Studio 2017的「解決方案資源管理器」中,右鍵單擊「OutStocks」文件夾,而後選擇「添加」 > 「新建項」,在彈出對話框中選擇「類」。爲應用服務定義一個名爲 OutStockOrderDetailAppService 的服務類,實現IOutStockOrderDetailAppService接口。代碼以下。函數

 using Abp.Application.Services; using Abp.Application.Services.Dto; using Abp.Domain.Repositories; using Abp.Web.Models; using ABP.TPLMS.Entitys; using ABP.TPLMS.OutStocks.Dto; using ABP.TPLMS.IRepositories; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABP.TPLMS.OutStocks { public class OutStockOrderDetailAppService : AsyncCrudAppService<OutStockOrderDetail
, OutStockOrderDetailDto, int , PagedOutStockDetailResultRequestDto, CreateUpdateOutStockOrderDetailDto, CreateUpdateOutStockOrderDetailDto>
, IOutStockOrderDetailAppService { public OutStockOrderDetailAppService( IRepository<OutStockOrderDetail, int> repository) : base(repository) { } protected override IQueryable<OutStockOrderDetail>
CreateFilteredQuery(PagedOutStockDetailResultRequestDto input) {
var qry = base.CreateFilteredQuery(input) .Where(t => t.OutStockNo == input.OutStockNo); return qry; } } }
相關文章
相關標籤/搜索