using System;
|
using System.Collections.Generic;
|
using System.Linq.Expressions;
|
using System.Text;
|
using System.Threading.Tasks;
|
using AutoMapper;
|
using Model.ModelDto.SysDto;
|
using SqlSugar;
|
using WMS.DAL;
|
using WMS.Entity.SysEntity;
|
using WMS.IBLL.ISysServer;
|
using WMS.IDAL.ISysInterface;
|
|
namespace WMS.BLL.SysServer
|
{
|
public class ExceptionServer : IExceptionServer
|
{
|
public IExceptionRepository ExceptionRst { get; set; }
|
private readonly IMapper _mapper;
|
public ExceptionServer(IExceptionRepository exceptionRst, IMapper mapper)
|
{
|
ExceptionRst = exceptionRst;
|
_mapper = mapper;
|
}
|
/// <summary>
|
/// 查询异常处理表信息
|
/// </summary>
|
/// <param name="palletNo">托盘号</param>
|
/// <param name="excLocatNo">储位号</param>
|
/// <param name="orderNo">单据号 入库单 出库单 移库单</param>
|
/// <param name="taskNo">任务号</param>
|
/// <param name="status">状态 0:未处理 1:已处理</param>
|
/// <param name="text">处理描述</param>
|
/// <param name="type">异常类型 0:空取 1:满入 2:双工位异常</param>
|
/// <param name="page"></param>
|
/// <param name="limit"></param>
|
/// <returns></returns>
|
public async Task<List<SysException>> GetExceptionList(string palletNo, string excLocatNo, string orderNo,
|
string taskNo, string status, string text, string type, int page = 0, int limit = 10)
|
{
|
try
|
{
|
Expression<Func<SysException, bool>> item = Expressionable.Create<SysException>()
|
.AndIF(!string.IsNullOrWhiteSpace(palletNo), it => it.PalletNo.Contains(palletNo.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(excLocatNo), it => it.ExcLocatNo.Contains(excLocatNo.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(orderNo), it => it.OrderNo.Contains(orderNo.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(taskNo), it => it.TaskNo.Contains(taskNo.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(text), it => it.Text.Contains(text.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(status), it => it.Status == type)
|
.AndIF(!string.IsNullOrWhiteSpace(type), it => it.Type == type)
|
.ToExpression();//注意 这一句 不能少
|
|
var data = await ExceptionRst.GetAllByOrderPageAsync(item, limit, page, out int counts).ToListAsync();
|
return data;
|
}
|
catch (Exception e)
|
{
|
throw new Exception(e.Message);
|
}
|
}
|
/// <summary>
|
/// 添加异常处理信息
|
/// </summary>
|
/// <param name="type">异常类型 0:空取 1:满入 2:双工位异常</param>
|
/// <param name="palletNo">托盘号</param>
|
/// <param name="excLocatNo">储位号</param>
|
/// <param name="orderNo">单据号 入库单 出库单 移库单</param>
|
/// <param name="taskNo">任务号</param>
|
/// <param name="text">处理描述</param>
|
/// <param name="userId">操作人</param>
|
/// <returns></returns>
|
public async Task<bool> AddException(string type, string palletNo, string excLocatNo, string orderNo, string taskNo, string text, int userId)
|
{
|
try
|
{
|
var exNo = new Common().GetMaxNo("EX");
|
var num = await ExceptionRst.AddAsync(new SysException()
|
{
|
Type = type,
|
ExceptionNo = exNo,
|
PalletNo = palletNo,
|
ExcLocatNo = excLocatNo,
|
OrderNo = orderNo,
|
TaskNo = taskNo,
|
Text = text,
|
CreateUser = userId
|
});
|
if (num > 0)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
catch (Exception e)
|
{
|
throw new Exception(e.Message);
|
}
|
}
|
|
|
/// <summary>
|
/// 获取异常处理信息列表
|
/// </summary>
|
/// <param name="exceptionNo">异常号</param>
|
/// <param name="palletNo">托盘号</param>
|
/// <param name="excLocatNo">异常储位</param>
|
/// <param name="orderNo">关联单号</param>
|
/// <param name="taskNo">关联任务号</param>
|
/// <param name="type">异常类型</param>
|
/// <param name="status">状态</param>
|
/// <returns></returns>
|
public List<ExceptionDto> GetTableList(string exceptionNo, string palletNo, string excLocatNo, string orderNo, string taskNo, string type, string status)
|
{
|
List<ExceptionDto> tablelist = ExceptionRst.GetExceptionList(exceptionNo, palletNo, excLocatNo, orderNo, taskNo, type, status);
|
return tablelist;
|
}
|
|
/// <summary>
|
/// 根据id获取异常信息
|
/// </summary>
|
/// <param name="id">异常id</param>
|
/// <returns></returns>
|
public SysException GetTableById(int id)
|
{
|
SysException table = ExceptionRst.GetExceptionById(id);
|
return table;
|
}
|
|
/// <summary>
|
/// 新增异常处理
|
/// </summary>
|
/// <param name="type">异常类型</param>
|
/// <param name="palletNo">托盘号</param>
|
/// <param name="excLocatNo">异常储位</param>
|
/// <param name="orderNo">关联单号</param>
|
/// <param name="taskNo">关联任务号</param>
|
/// <param name="demo">备注</param>
|
/// <param name="uid">创建人</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
public async Task<int> InsertTableName(string type, string palletNo, string excLocatNo, string orderNo, string taskNo, string demo, int uid)
|
{
|
//捕获异常
|
try
|
{
|
//获取最大异常号
|
string ExceptionNo = ExceptionRst.GetMaxExceptionNo().ExceptionNo;
|
//判断获取到的异常号是否为空
|
if (!string.IsNullOrEmpty(ExceptionNo))
|
{
|
ExceptionNo = "1000";
|
}
|
else
|
{
|
ExceptionNo = (int.Parse(ExceptionNo) + 1).ToString();
|
}
|
int i = await ExceptionRst.InsertException(ExceptionNo, type, palletNo, excLocatNo, orderNo, taskNo, demo, uid);
|
return i;
|
}
|
catch (Exception ex)
|
{
|
//抛出异常
|
throw new Exception("新增异常处理", ex);
|
}
|
}
|
|
/// <summary>
|
/// 处理异常状态
|
/// </summary>
|
/// <param name="tabledto">异常处理dto</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
public async Task<int> EditStatus(ExceptionDto tabledto)
|
{
|
//捕获异常
|
try
|
{
|
SysException table = _mapper.Map<SysException>(tabledto);
|
int i = await ExceptionRst.EditStatus(table);
|
return i;
|
}
|
catch (Exception ex)
|
{
|
//抛出异常
|
throw new Exception("处理状态异常", ex);
|
}
|
}
|
}
|
}
|