abp(net core)+easyui+efcore实现仓储管理系统——出库管理之三(五十二)

abp(net core)+easyui+efcore实现仓储管理系统目录

abp(net core)+easyui+efcore实现仓储管理系统——EasyUI前端页面框架 (十八)

abp(net core)+easyui+efcore实现仓储管理系统——出库管理之三(五十一)
 

    我们已经在ABP中实现了如何调用存储过程的方法 ,接下来我们要来实现应用层的具体代码。

 

六、定义应用层接口

1. 在Visual Studio 2017的“解决方案资源管理器”中,鼠标右键单击“OutStocks”文件夹,然后选择“添加” > “新建项”,在弹出对话框中选择“接口”。为应用服务定义一个名为 IOutStockOrderAppService 的接口。代码如下。

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 > //用于更新出库单明细信息

    {

    }
 
}

 

 


七、实现OutStockOrderAppService

    3.在Visual Studio 2017的“解决方案资源管理器”中,右键单击“OutStocks”文件夹,然后选择“添加” > “新建项”,在弹出对话框中选择“类”。为应用服务定义一个名为 OutStockOrderAppService 的服务类,实现IOutStockOrderAppService接口中的方法。特别注意在构造函数中定义IOutStockOrderRepository 接口,方便注入代码如下。

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; } } }

 

 
 
posted @ 2020-10-25 17:59  DotNet菜园  阅读(642)  评论(1编辑  收藏  举报