using Model.ModelDto.SysDto;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WMS.Entity.Context;
|
using WMS.Entity.SysEntity;
|
using WMS.IDAL.ISysInterface;
|
|
namespace WMS.DAL.SysInfrastructure
|
{
|
public class ExceptionRepository : BaseRepository<SysException>, IExceptionRepository
|
{
|
private static readonly SqlSugarScope Db = DataContext.Db;
|
public ExceptionRepository() : base(DataContext.Db)
|
{
|
}
|
|
|
/// <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> GetExceptionList(string exceptionNo, string palletNo, string excLocatNo, string orderNo, string taskNo, string type, string status)
|
{
|
string str = "select exception.*,user1.UserName CreateUserName from SysException exception left join SysUserInfor user1 on exception.CreateUser = user1.Id where exception.IsDel = @isdel";
|
//判断异常号
|
if (!string.IsNullOrEmpty(exceptionNo))
|
{
|
str += " and exception.ExceptionNo like @exceptionno";
|
}
|
//判断托盘号
|
if (!string.IsNullOrEmpty(palletNo))
|
{
|
str += " and exception.PalletNo like @palletno";
|
}
|
//判断异常储位号
|
if (!string.IsNullOrEmpty(excLocatNo))
|
{
|
str += " and exception.ExcLocatNo like @exclocatno";
|
}
|
//判断关联单号
|
if (!string.IsNullOrEmpty(orderNo))
|
{
|
str += " and exception.OrderNo like @orderno";
|
}
|
//判断关联任务号
|
if (!string.IsNullOrEmpty(taskNo))
|
{
|
str += " and exception.TaskNo like @taskno";
|
}
|
//判断异常类型
|
if (!string.IsNullOrEmpty(type))
|
{
|
str += " and exception.Type = @type";
|
}
|
//判断状态
|
if (!string.IsNullOrEmpty(status))
|
{
|
str += " and exception.Status = @status";
|
}
|
str += " order by exception.CreateTime desc";
|
List<ExceptionDto> tablelist = Db.Ado.SqlQuery<ExceptionDto>(str, new
|
{
|
isdel = "0", //是否删除
|
exceptionno = "%" + exceptionNo + "%", //异常号
|
palletno = "%" + palletNo + "%", //托盘号
|
exclocatno = "%" + excLocatNo + "%", //异常储位
|
orderno = "%" + orderNo + "%", //关联单号
|
taskno = "%" + taskNo + "%", //关联任务号
|
type, //异常类型
|
status //状态
|
});
|
return tablelist;
|
}
|
|
/// <summary>
|
/// 根据id获取异常信息
|
/// </summary>
|
/// <param name="id">异常id</param>
|
/// <returns></returns>
|
public SysException GetExceptionById(int id)
|
{
|
string str = "select * from SysException where IsDel = @isdel and Id = @id";
|
SysException exception = Db.Ado.SqlQuerySingle<SysException>(str, new
|
{
|
isdel = "0", //是否删除
|
id //id
|
});
|
return exception;
|
}
|
|
/// <summary>
|
/// 新增异常处理
|
/// </summary>
|
/// <param name="exceptionNo">异常号</param>
|
/// <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>
|
public async Task<int> InsertException(string exceptionNo, string type, string palletNo, string excLocatNo, string orderNo, string taskNo, string demo, int uid)
|
{
|
string str = "Insert into SysException values(@exceptionno, @type, @palletno, @exclocatno, @orderno, @taskno, @status, @text, @demo, @isdel, @createtime, @createuser, null, null)";
|
int i = await Db.Ado.ExecuteCommandAsync(str, new
|
{
|
exceptionno = exceptionNo, //异常号
|
type, //异常类型
|
palletno = palletNo, //托盘号
|
exclocatno = excLocatNo, //异常储位
|
orderno = orderNo, //关联单号
|
taskno = taskNo, //关联任务号
|
status = "0", //状态
|
text = "", //处理描述
|
demo, //备注
|
isdel = "0",//是否删除
|
createtime = Db.GetDate(), //创建时间
|
createuser = uid //创建人
|
});
|
return i;
|
|
//异常号获取最大值加一 ExceptionNo 1
|
//异常类型 0:空取 要去一个库取东西 到了以后发现没东西 1:满入 要去一个地方放东西 到了以后发现放不下 2:双工位异常 例如:目标区域有两个地方可以放东西 我要把东西放在二号区域 二号区域被一号区域挡住了 放不了 取货反之Type
|
//托盘号PalletNo
|
//异常储位 多储位用;号区分ExcLocatNo
|
//关联单号 入库单、出库单、移库单OrderNo
|
//关联任务号TaskNo
|
//状态Status 默认未处理
|
//处理描述Text //空
|
//备注Demo 1
|
|
//是否删除 0 1
|
//创建时间 Db.GetDate(); 1
|
//创建人 :操作人 1
|
|
}
|
|
/// <summary>
|
/// 处理异常状态
|
/// </summary>
|
/// <param name="exception"></param>
|
/// <returns></returns>
|
public async Task<int> EditStatus(SysException exception)
|
{
|
string str = "update SysException set Status = @status,Demo = @demo,Text = @text,UpdateTime = @updatetime,UpdateUser = @updateuser where Id = @id";
|
int i = await Db.Ado.ExecuteCommandAsync(str, new
|
{
|
status = "1", //状态
|
demo = exception.Demo, //备注
|
text = exception.Text, //处理描述
|
updatetime = Db.GetDate(), //更改时间
|
updateuser = exception.UpdateUser, //更改人
|
id = exception.Id //id
|
});
|
return i;
|
}
|
|
/// <summary>
|
/// 获取最大异常号
|
/// </summary>
|
/// <returns></returns>
|
public SysException GetMaxExceptionNo()
|
{
|
string str = "select MAX(ExceptionNo) ExceptionNo from SysException";
|
SysException table = Db.Ado.SqlQuerySingle<SysException>(str);
|
return table;
|
}
|
}
|
}
|