-
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;
}
}
}
复制代码
出处:https://www.cnblogs.com/chillsrc/p/13874349.html
栏目列表
最新更新
python爬虫及其可视化
使用python爬取豆瓣电影短评评论内容
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
uniapp/H5 获取手机桌面壁纸 (静态壁纸)
[前端] DNS解析与优化
为什么在js中需要添加addEventListener()?
JS模块化系统
js通过Object.defineProperty() 定义和控制对象
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比