1.修改物料绑定功能
2.增加数据修改记录表和对应的操作数据的时候增加记录
This commit is contained in:
@ -5,11 +5,12 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model.ApiModel.MatDetailHistoryInfo;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前库存盘点表
|
||||
/// 数据更新记录表
|
||||
/// </summary>
|
||||
[SugarTable("wcs_mat_detail_history_info")]
|
||||
public class MatDetailHistoryInfo
|
||||
@ -20,13 +21,13 @@ namespace WCS.BLL.DbModels
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架库存明细当前的ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_detail_current_id", IsNullable = false, ColumnDescription = "库存明细当前的ID")]
|
||||
public int MatDetailCurrentId { get; set; }
|
||||
|
||||
#region 货架属性
|
||||
/// <summary>
|
||||
/// 货架类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type", Length = 64, IsNullable = true, ColumnDescription = "货架类型")]
|
||||
public string ShelfType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架ID
|
||||
/// </summary>
|
||||
@ -38,19 +39,6 @@ namespace WCS.BLL.DbModels
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_code", Length = 64, IsNullable = false, ColumnDescription = "货架编码")]
|
||||
public string ShelfCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type", Length = 64, IsNullable = true, ColumnDescription = "货架类型")]
|
||||
public string ShelfType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架区域
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_area", Length = 64, IsNullable = true, ColumnDescription = "货架区域")]
|
||||
public string ShelfArea { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 物料属性
|
||||
@ -59,7 +47,8 @@ namespace WCS.BLL.DbModels
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_code", Length = 100, IsNullable = true, ColumnDescription = "物料编号")]
|
||||
public string MatCode { get; set; }
|
||||
/// <summary>
|
||||
|
||||
// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_name", Length = 150, IsNullable = true, ColumnDescription = "物料名称")]
|
||||
@ -69,7 +58,7 @@ namespace WCS.BLL.DbModels
|
||||
/// 物料规格
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")]
|
||||
public string MatSpec { get; set; }
|
||||
public string? MatSpec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料数量(更新前物料数量)
|
||||
@ -96,12 +85,6 @@ namespace WCS.BLL.DbModels
|
||||
public string? MatCustomer { get; set; }
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "modify_user", IsNullable = true, Length = 50, ColumnDescription = "更新人")]
|
||||
public string? ModifyUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
@ -109,7 +92,25 @@ namespace WCS.BLL.DbModels
|
||||
public DateTime? ModifyTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 是否已删除
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "modify_user", IsNullable = true, Length = 50, ColumnDescription = "更新人")]
|
||||
public string? ModifyUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 记录类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "record_type", IsNullable = false, ColumnDescription = "记录类型")]
|
||||
public RecordTypeEnum RecordType { get; set; } = RecordTypeEnum.修改;
|
||||
|
||||
/// <summary>
|
||||
/// 功能
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "function_type", IsNullable = false, ColumnDescription = "功能")]
|
||||
public FunctionTypeEnum FunctionType { get; set; } = FunctionTypeEnum.PDA物料绑定;
|
||||
|
||||
/// <summary>
|
||||
/// 是否已删除 假删除
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_delete", IsNullable = false, ColumnDescription = "是否已删除")]
|
||||
public bool IsDelete { get; set; } = false;
|
||||
|
@ -64,7 +64,7 @@ namespace WCS.BLL.Manager
|
||||
//如果不配置此参数 每次启动都会持续几十秒才能成功启动后端
|
||||
//if (LocalFile.Config.IsResetDBOrTable)//开发阶段暂时屏蔽初始化限制
|
||||
{
|
||||
#region 建库建表 只在表有变动时运行
|
||||
#region 建库建表
|
||||
DbHelp.db.DbMaintenance.CreateDatabase();
|
||||
//新部署时 日志需要建表 不然没得接口记录
|
||||
DbHelp.dbLog.DbMaintenance.CreateDatabase();
|
||||
@ -72,7 +72,7 @@ namespace WCS.BLL.Manager
|
||||
|
||||
DbHelp.db.CodeFirst.InitTables(typeof(ShelfInfo), typeof(MatBaseInfo), typeof(ShelfTypeInfo)
|
||||
, typeof(LocationInfo), typeof(LocationAreaInfo), typeof(MatDetailCurrentInfo), typeof(OrderTypeInfo)
|
||||
, typeof(MatDetailStocktakingInfo), typeof(AgvTask)
|
||||
, typeof(MatDetailStocktakingInfo), typeof(AgvTask),typeof(MatDetailHistoryInfo)
|
||||
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
|
||||
, typeof(MatInfo), typeof(StoreInfo)
|
||||
, typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord)
|
||||
|
@ -20,6 +20,7 @@ using WCS.Model.ApiModel.BatchBindMatDetail;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.Model.ApiModel.MatDetailCurrentInfo;
|
||||
using WCS.Model.ApiModel.MatDetailHistoryInfo;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
@ -40,9 +41,11 @@ namespace WCS.BLL.Services.Service
|
||||
.LeftJoin<ShelfInfo>((mci, si) => mci.ShelfId == si.Id)
|
||||
.LeftJoin<LocationInfo>((mci, si, li) => (si.TransStatus == TransStatusEnum.静止 && si.CurrentLocationId == li.Id)
|
||||
|| (si.TransStatus == TransStatusEnum.运输中 && si.DestinationLocationId == li.Id))
|
||||
.Where((mci, si, li) => !string.IsNullOrEmpty(mci.StationCode))
|
||||
.WhereIF(request.OrderTypeId != null && request.OrderTypeId != 0, (mci, si, li) => mci.OrderTypeId == request.OrderTypeId)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.ShelfCode), (mci, si, li) => si.ShelfCode.Contains(request.ShelfCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.StationCode), (mci, si, li) => mci.StationCode.Contains(request.StationCode))
|
||||
|
||||
.WhereIF(!string.IsNullOrEmpty(request.StationCode) && request.StationCode.ToLower() != "admin", (mci, si, li) => mci.StationCode.Contains(request.StationCode))
|
||||
.Select((mci, si, li) => new MatDetailCurrentInfoModel()
|
||||
{
|
||||
Id = mci.Id,
|
||||
@ -120,14 +123,37 @@ namespace WCS.BLL.Services.Service
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
DbHelp.db.BeginTran();
|
||||
//新增数据修改记录表
|
||||
var historyInfo = new MatDetailHistoryInfo()
|
||||
{
|
||||
ShlefId = matDetailCurrentInfo.ShelfId,
|
||||
ShelfType = matDetailCurrentInfo.ShelfType,
|
||||
ShelfCode = matDetailCurrentInfo.ShelfCode,
|
||||
|
||||
MatCode = matDetailCurrentInfo.MatCode,
|
||||
MatName = matDetailCurrentInfo.MatName,
|
||||
MatSpec = matDetailCurrentInfo.MatSpec,
|
||||
MatCustomer = matDetailCurrentInfo?.MatCustomer,
|
||||
MatSupplier = matDetailCurrentInfo?.MatSupplier,
|
||||
|
||||
BeforeQty = matDetailCurrentInfo.MatQty,
|
||||
AfterQty = request.LocationInfo.MatQty,
|
||||
|
||||
ModifyTime = DateTime.Now,
|
||||
ModifyUser = request.UserName,
|
||||
RecordType = RecordTypeEnum.修改,
|
||||
FunctionType = FunctionTypeEnum.客户端物料绑定,
|
||||
};
|
||||
await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync();
|
||||
//更新货架存量数据
|
||||
matDetailCurrentInfo.MatQty = request.LocationInfo.MatQty;
|
||||
matDetailCurrentInfo.ModifyUser = request.UserName;
|
||||
matDetailCurrentInfo.ModifyTime = DateTime.Now;
|
||||
|
||||
var rowNum = await DbHelp.db.Updateable(matDetailCurrentInfo).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
@ -137,6 +163,7 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
else
|
||||
{
|
||||
DbHelp.db.CommitTran();
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
@ -144,16 +171,14 @@ namespace WCS.BLL.Services.Service
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
Message = $"更新货架存量信息失败:{ex.Message}",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
@ -162,14 +187,42 @@ namespace WCS.BLL.Services.Service
|
||||
|
||||
public async Task<ResponseCommon<object>> deleteMatDetailCurrentInfo(DeleteInfosRequest request)
|
||||
{
|
||||
//先查询出具体的Id
|
||||
var MatDetailCurrentInfos = await DbHelp.db.Queryable<MatDetailCurrentInfo>()
|
||||
//先查询出具体的数据
|
||||
var matDetailCurrentInfos = await DbHelp.db.Queryable<MatDetailCurrentInfo>()
|
||||
.Where(t => request.needDeleteIds.Contains(t.Id))
|
||||
.ToListAsync();
|
||||
//执行删除
|
||||
try
|
||||
{
|
||||
var deleteRows = await DbHelp.db.Deleteable(MatDetailCurrentInfos).ExecuteCommandAsync();
|
||||
DbHelp.db.BeginTran();
|
||||
//新增数据删除记录
|
||||
foreach (var matDetailCurrentInfo in matDetailCurrentInfos)
|
||||
{
|
||||
var historyInfo = new MatDetailHistoryInfo()
|
||||
{
|
||||
ShlefId = matDetailCurrentInfo.ShelfId,
|
||||
ShelfType = matDetailCurrentInfo.ShelfType,
|
||||
ShelfCode = matDetailCurrentInfo.ShelfCode,
|
||||
|
||||
MatCode = matDetailCurrentInfo.MatCode,
|
||||
MatName = matDetailCurrentInfo.MatName,
|
||||
MatSpec = matDetailCurrentInfo.MatSpec,
|
||||
MatCustomer = matDetailCurrentInfo?.MatCustomer,
|
||||
MatSupplier = matDetailCurrentInfo?.MatSupplier,
|
||||
|
||||
BeforeQty = matDetailCurrentInfo.MatQty,
|
||||
AfterQty = 0,//删除数据 为0
|
||||
|
||||
ModifyTime = DateTime.Now,
|
||||
ModifyUser = request.UserName,
|
||||
RecordType = RecordTypeEnum.删除,
|
||||
FunctionType = FunctionTypeEnum.客户端物料绑定,
|
||||
};
|
||||
await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync();
|
||||
}
|
||||
var deleteRows = await DbHelp.db.Deleteable(matDetailCurrentInfos).ExecuteCommandAsync();
|
||||
|
||||
DbHelp.db.CommitTran();
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
@ -179,6 +232,7 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
@ -199,33 +253,64 @@ namespace WCS.BLL.Services.Service
|
||||
public async Task<ResponseCommon<List<string>>> importMatDetailCurrentInfo(List<MatDetailCurrentInfoImportModel> lists, string userName, string deviceType, string stationCode)
|
||||
{
|
||||
#region 校验
|
||||
//工位校验 工位是否有货架校验
|
||||
var station = await DbHelp.db.Queryable<LocationInfo>()
|
||||
.Where(t => t.LocationCode == stationCode && t.IsEnable == true)
|
||||
.FirstAsync();
|
||||
if (station == null)
|
||||
////工位校验 工位是否有货架校验
|
||||
//var station = await DbHelp.db.Queryable<LocationInfo>()
|
||||
// .Where(t => t.LocationCode == stationCode && t.IsEnable == true)
|
||||
// .FirstAsync();
|
||||
//if (station == null)
|
||||
//{
|
||||
// return new ResponseCommon<List<string>>()
|
||||
// {
|
||||
// Code = 201,
|
||||
// Message = $"导入失败:工位[{stationCode}]不存在或已被禁用!",
|
||||
// Data = null,
|
||||
// };
|
||||
//}
|
||||
|
||||
//var shelfInfo = await DbHelp.db.Queryable<ShelfInfo>()
|
||||
// .Where(t => (t.TransStatus == TransStatusEnum.静止 && t.CurrentLocationId == station.Id) ||
|
||||
// t.TransStatus == TransStatusEnum.运输中 && t.DestinationLocationId == station.Id)
|
||||
// .Where(t => t.IsEnable)
|
||||
// .FirstAsync();
|
||||
//if (shelfInfo == null)
|
||||
//{
|
||||
// return new ResponseCommon<List<string>>()
|
||||
// {
|
||||
// Code = 201,
|
||||
// Message = $"导入失败:当前工位不存在货架,请呼叫货架后再进行操作!",
|
||||
// Data = null,
|
||||
// };
|
||||
//}
|
||||
//货架编码校验
|
||||
var shelfCodes = lists.Select(t => t.货架编码).Distinct().ToList();
|
||||
|
||||
var shelfInfosInDb = await DbHelp.db.Queryable<ShelfInfo>()
|
||||
.Where(t => shelfCodes.Contains(t.ShelfCode))
|
||||
.Where(t => t.IsEnable)
|
||||
.ToListAsync();
|
||||
if (shelfInfosInDb == null)
|
||||
{
|
||||
return new ResponseCommon<List<string>>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"导入失败:工位[{stationCode}]不存在或已被禁用!",
|
||||
Message = $"导入失败:货架编码无效!请重试!",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
|
||||
var shelfInfo = await DbHelp.db.Queryable<ShelfInfo>()
|
||||
.Where(t => (t.TransStatus == TransStatusEnum.静止 && t.CurrentLocationId == station.Id) ||
|
||||
t.TransStatus == TransStatusEnum.运输中 && t.DestinationLocationId == station.Id)
|
||||
.Where(t => t.IsEnable)
|
||||
.FirstAsync();
|
||||
if (shelfInfo == null)
|
||||
//判断如果导入表中的货架编码数量与数据库中有效的货架数量不一致证明中间有无效的货架编码
|
||||
if (shelfInfosInDb != null && shelfInfosInDb.Count < shelfCodes.Count)
|
||||
{
|
||||
return new ResponseCommon<List<string>>()
|
||||
var shelfCodesInDb = shelfInfosInDb.Select(t => t.ShelfCode).ToList();
|
||||
shelfCodes.RemoveAll(t => shelfCodesInDb.Contains(t));
|
||||
if (shelfCodes.Count > 0)
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"导入失败:当前工位不存在货架,请呼叫货架后再进行操作!",
|
||||
Data = null,
|
||||
};
|
||||
return new ResponseCommon<List<string>>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"导入失败:以下货架编码无效!\r\n{string.Join(",", shelfCodes)}",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//单据类型校验 物料类型数量较小 不会对内存造成负担
|
||||
@ -264,15 +349,16 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(matDetailCurrentInfo.货架编码) && matDetailCurrentInfo.货架编码 == shelfInfo.ShelfCode)
|
||||
{
|
||||
return new ResponseCommon<List<string>>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"导入失败:货架[{matDetailCurrentInfo.货架编码}]不是当前工位的货架!",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
//不校验货架
|
||||
//if (!string.IsNullOrEmpty(matDetailCurrentInfo.货架编码) && matDetailCurrentInfo.货架编码 == shelfInfo.ShelfCode)
|
||||
//{
|
||||
// return new ResponseCommon<List<string>>()
|
||||
// {
|
||||
// Code = 201,
|
||||
// Message = $"导入失败:货架[{matDetailCurrentInfo.货架编码}]不是当前工位的货架!",
|
||||
// Data = null,
|
||||
// };
|
||||
//}
|
||||
}
|
||||
|
||||
#region 物料编码校验
|
||||
@ -320,9 +406,10 @@ namespace WCS.BLL.Services.Service
|
||||
foreach (var info in lists)
|
||||
{
|
||||
var matBaseInfo = matBaseInfoInDb?.Where(t => t.MatCode == info.物料编码).First();
|
||||
var shelfInfo = shelfInfosInDb?.Where(t => t.ShelfCode == info.货架编码).First();
|
||||
var orderType = orderTypesInDb?.Where(t => t.OrderTypeName == info.单据类型).FirstOrDefault();
|
||||
//应该是不能走进的分支
|
||||
if (matBaseInfo == null)
|
||||
if (matBaseInfo == null || shelfInfo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -350,6 +437,29 @@ namespace WCS.BLL.Services.Service
|
||||
|
||||
};
|
||||
await DbHelp.db.Insertable(matDetailCurrentInfo).ExecuteCommandAsync();
|
||||
|
||||
var historyInfo = new MatDetailHistoryInfo()
|
||||
{
|
||||
ShlefId = matDetailCurrentInfo.ShelfId,
|
||||
ShelfType = matDetailCurrentInfo.ShelfType,
|
||||
ShelfCode = matDetailCurrentInfo.ShelfCode,
|
||||
|
||||
MatCode = matDetailCurrentInfo.MatCode,
|
||||
MatName = matDetailCurrentInfo.MatName,
|
||||
MatSpec = matDetailCurrentInfo.MatSpec,
|
||||
MatCustomer = matDetailCurrentInfo?.MatCustomer,
|
||||
MatSupplier = matDetailCurrentInfo?.MatSupplier,
|
||||
|
||||
BeforeQty = 0,
|
||||
AfterQty = matDetailCurrentInfo.MatQty,
|
||||
|
||||
ModifyTime = DateTime.Now,
|
||||
ModifyUser = userName,
|
||||
RecordType = RecordTypeEnum.新增,
|
||||
FunctionType = FunctionTypeEnum.客户端物料绑定,
|
||||
};
|
||||
await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
await DbHelp.db.CommitTranAsync();
|
||||
return new ResponseCommon<List<string>>()
|
||||
|
@ -19,6 +19,7 @@ using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.Model.ApiModel.MatDetailCurrentInfo;
|
||||
using WCS.Model.ApiModel.MatDetailHistoryInfo;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
@ -114,14 +115,37 @@ namespace WCS.BLL.Services.Service
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
DbHelp.db.BeginTran();
|
||||
//新增数据修改记录表
|
||||
var historyInfo = new MatDetailHistoryInfo()
|
||||
{
|
||||
ShlefId = matDetailCurrentInfo.ShelfId,
|
||||
ShelfType = matDetailCurrentInfo.ShelfType,
|
||||
ShelfCode = matDetailCurrentInfo.ShelfCode,
|
||||
|
||||
MatCode = matDetailCurrentInfo.MatCode,
|
||||
MatName = matDetailCurrentInfo.MatName,
|
||||
MatSpec = matDetailCurrentInfo.MatSpec,
|
||||
MatCustomer = matDetailCurrentInfo?.MatCustomer,
|
||||
MatSupplier = matDetailCurrentInfo?.MatSupplier,
|
||||
|
||||
BeforeQty = matDetailCurrentInfo.MatQty,
|
||||
AfterQty = request.LocationInfo.MatQty,
|
||||
|
||||
ModifyTime = DateTime.Now,
|
||||
ModifyUser = request.UserName,
|
||||
RecordType = RecordTypeEnum.修改,
|
||||
FunctionType = FunctionTypeEnum.客户端货架存量,
|
||||
};
|
||||
await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync();
|
||||
//更新货架存量数据
|
||||
matDetailCurrentInfo.MatQty = request.LocationInfo.MatQty;
|
||||
matDetailCurrentInfo.ModifyUser = request.UserName;
|
||||
matDetailCurrentInfo.ModifyTime = DateTime.Now;
|
||||
|
||||
var rowNum = await DbHelp.db.Updateable(matDetailCurrentInfo).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 201,
|
||||
@ -131,6 +155,7 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
else
|
||||
{
|
||||
DbHelp.db.CommitTran();
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
@ -141,10 +166,11 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
Message = $"更新货架存量信息失败:{ex.Message}",
|
||||
Data = null
|
||||
};
|
||||
return response;
|
||||
@ -156,13 +182,41 @@ namespace WCS.BLL.Services.Service
|
||||
public async Task<ResponseCommon<object>> deleteMatDetailCurrentInfo(DeleteInfosRequest request)
|
||||
{
|
||||
//先查询出具体的Id
|
||||
var MatDetailCurrentInfos = await DbHelp.db.Queryable<MatDetailCurrentInfo>()
|
||||
var matDetailCurrentInfos = await DbHelp.db.Queryable<MatDetailCurrentInfo>()
|
||||
.Where(t => request.needDeleteIds.Contains(t.Id))
|
||||
.ToListAsync();
|
||||
//执行删除
|
||||
try
|
||||
{
|
||||
var deleteRows = await DbHelp.db.Deleteable(MatDetailCurrentInfos).ExecuteCommandAsync();
|
||||
DbHelp.db.BeginTran();
|
||||
//新增数据删除记录
|
||||
foreach (var matDetailCurrentInfo in matDetailCurrentInfos)
|
||||
{
|
||||
var historyInfo = new MatDetailHistoryInfo()
|
||||
{
|
||||
ShlefId = matDetailCurrentInfo.ShelfId,
|
||||
ShelfType = matDetailCurrentInfo.ShelfType,
|
||||
ShelfCode = matDetailCurrentInfo.ShelfCode,
|
||||
|
||||
MatCode = matDetailCurrentInfo.MatCode,
|
||||
MatName = matDetailCurrentInfo.MatName,
|
||||
MatSpec = matDetailCurrentInfo.MatSpec,
|
||||
MatCustomer = matDetailCurrentInfo?.MatCustomer,
|
||||
MatSupplier = matDetailCurrentInfo?.MatSupplier,
|
||||
|
||||
BeforeQty = matDetailCurrentInfo.MatQty,
|
||||
AfterQty = 0,//删除数据 为0
|
||||
|
||||
ModifyTime = DateTime.Now,
|
||||
ModifyUser = request.UserName,
|
||||
RecordType = RecordTypeEnum.删除,
|
||||
FunctionType = FunctionTypeEnum.客户端货架存量,
|
||||
};
|
||||
await DbHelp.db.Insertable(historyInfo).ExecuteCommandAsync();
|
||||
}
|
||||
var deleteRows = await DbHelp.db.Deleteable(matDetailCurrentInfos).ExecuteCommandAsync();
|
||||
|
||||
DbHelp.db.CommitTran();
|
||||
return new ResponseCommon<Object>
|
||||
{
|
||||
Code = 200,
|
||||
@ -172,6 +226,7 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
var response = new ResponseCommon<Object>
|
||||
{
|
||||
Code = 300,
|
||||
|
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.MatDetailHistoryInfo
|
||||
{
|
||||
public class MatDetailHistoryInfoModel : INotifyPropertyChanged
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
#region 货架属性
|
||||
public string ShelfType { get; set; }
|
||||
|
||||
public int ShlefId { get; set; }
|
||||
|
||||
public string ShelfCode { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 物料属性
|
||||
public string MatCode { get; set; }
|
||||
|
||||
public string MatName { get; set; }
|
||||
|
||||
public string MatSpec { get; set; }
|
||||
|
||||
public int BeforeQty { get; set; }
|
||||
|
||||
public int AfterQty { get; set; }
|
||||
|
||||
public string? MatSupplier { get; set; }
|
||||
|
||||
public string? MatCustomer { get; set; }
|
||||
#endregion
|
||||
|
||||
public DateTime? ModifyTime { get; set; } = DateTime.Now;
|
||||
|
||||
public string? ModifyUser { get; set; }
|
||||
|
||||
public RecordTypeEnum RecordType { get; set; } = RecordTypeEnum.修改;
|
||||
|
||||
public FunctionTypeEnum FunctionType { get; set; } = FunctionTypeEnum.PDA物料绑定;
|
||||
|
||||
public bool IsDelete { get; set; } = false;
|
||||
|
||||
public int RowNumber { get; set; }
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return isSelected; }
|
||||
set
|
||||
{
|
||||
isSelected = value;
|
||||
OnPropertyChanged(nameof(IsSelected));
|
||||
}
|
||||
}
|
||||
public bool isSelected;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据更新类型
|
||||
/// </summary>
|
||||
public enum RecordTypeEnum
|
||||
{
|
||||
新增 = 0,
|
||||
修改 = 1,
|
||||
删除 = 2,
|
||||
清空 = 3,
|
||||
}
|
||||
|
||||
//具体是哪个功能
|
||||
public enum FunctionTypeEnum
|
||||
{
|
||||
PDA物料绑定,
|
||||
PDA绑定查询,
|
||||
PDA货架送回,
|
||||
库存盘点,
|
||||
客户端货架存量,
|
||||
客户端物料绑定,
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ using WCS.Model.ApiModel.BatchBindMatDetail;
|
||||
using WCS.Model.ApiModel.Home;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.Model.ApiModel.PDAMatBind;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.Model.ApiModel.User;
|
||||
using WCS.Model.WebSocketModel;
|
||||
|
||||
@ -65,39 +66,58 @@ namespace WCS.WebApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Route("getMatDetailCurrentInfosByStationCode")]
|
||||
[HttpPost(Name = "getMatDetailCurrentInfosByStationCode")]
|
||||
public async Task<ResponseBase> GetMatDetailCurrentInfosByStationCode(GetMatDetailCurrentInfosByStationCodeRequest request)
|
||||
{
|
||||
//判断参数
|
||||
if (string.IsNullOrEmpty(request.StationCode))
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "工位编码为空,请联系相关人员进行配置!",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
//判断工位是否存在
|
||||
var isExsistLocation = await DbHelp.db.Queryable<LocationInfo>()
|
||||
.Where(t => t.LocationCode == request.StationCode)
|
||||
.AnyAsync();
|
||||
//不存在工位
|
||||
if (!isExsistLocation)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"工位[{request.StationCode}]不存在,暂时无法使用此功能!",
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
|
||||
////判断参数
|
||||
//if (string.IsNullOrEmpty(request.StationCode))
|
||||
//{
|
||||
// return new ResponseCommon()
|
||||
// {
|
||||
// Code = 201,
|
||||
// Message = "工位编码为空,请联系相关人员进行配置!",
|
||||
// Data = null,
|
||||
// };
|
||||
//}
|
||||
////判断工位是否存在
|
||||
//var isExsistLocation = await DbHelp.db.Queryable<LocationInfo>()
|
||||
// .Where(t => t.LocationCode == request.StationCode)
|
||||
// .AnyAsync();
|
||||
////不存在工位
|
||||
//if (!isExsistLocation)
|
||||
//{
|
||||
// return new ResponseCommon()
|
||||
// {
|
||||
// Code = 201,
|
||||
// Message = $"工位[{request.StationCode}]不存在,暂时无法使用此功能!",
|
||||
// Data = null,
|
||||
// };
|
||||
//}
|
||||
return await _batchBindMatDetailService.GetMatDetailCurrentInfosByStationCode(request);
|
||||
}
|
||||
|
||||
[HttpPost("updateMatDetailCurrentInfoForBind")]
|
||||
public async Task<ResponseCommon<object>> updateMatDetailCurrentInfoForBind(AddLocaionInfoRequest<MatDetailCurrentInfo> request)
|
||||
{
|
||||
return await _batchBindMatDetailService.updateMatDetailCurrentInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("deleteMatDetailCurrentInfoForBind")]
|
||||
public async Task<ResponseCommon<object>> deleteMatDetailCurrentInfoForBind(DeleteInfosRequest request)
|
||||
{
|
||||
//校验
|
||||
if (request.needDeleteIds == null || request.needDeleteIds.Count == 0)
|
||||
{
|
||||
return new ResponseCommon<object>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "操作失败:参数校验失败(ID)."
|
||||
};
|
||||
}
|
||||
return await _batchBindMatDetailService.deleteMatDetailCurrentInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("importMatDetailCurrentInfos")]
|
||||
public async Task<ResponseBase> importMatDetailCurrentInfos([FromForm] IFormFile excelFile, [FromForm] string userName
|
||||
|
@ -43,11 +43,6 @@ namespace 智慧物流软件系统
|
||||
|
||||
public string ModuleCodePattern { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工位编码 WCS前端当前的工位编码
|
||||
/// </summary>
|
||||
public string LocationCode { get; set; }
|
||||
|
||||
|
||||
#region 导入相关配置
|
||||
//点击导入选择文件时 是否自动加载下载导入模板得路径
|
||||
|
@ -35,7 +35,7 @@ namespace 智慧物流软件系统.ViewModel
|
||||
public BatchBindMatDetailViewModel()
|
||||
{
|
||||
//绑定工位编码
|
||||
StationCode = LocalFile.Config.LocationCode;
|
||||
StationCode = LocalStatic.CurrentUser;
|
||||
}
|
||||
|
||||
#region Property
|
||||
@ -181,7 +181,7 @@ namespace 智慧物流软件系统.ViewModel
|
||||
OrderTypeId = SelectedOrderTypeItem?.Id,
|
||||
OrderNumber = OrderNumber,
|
||||
ShelfCode = ShelfCode,
|
||||
StationCode = LocalFile.Config.LocationCode,
|
||||
StationCode = StationCode,
|
||||
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
@ -223,7 +223,7 @@ namespace 智慧物流软件系统.ViewModel
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateView = new MatDetailCurrentInfoUpdateView("修改货架存量", info);
|
||||
var updateView = new MatDetailCurrentInfoUpdateView("修改绑定数据", info);
|
||||
updateView.ShowDialog();
|
||||
if (updateView.DialogResult == true)
|
||||
{
|
||||
@ -256,7 +256,7 @@ namespace 智慧物流软件系统.ViewModel
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
needDeleteIds = needDeleteIds,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseBase<UserModel>>(LocalFile.Config.ApiIpHost + "matDetailCurrenInfo/deleteMatDetailCurrentInfo", body, "POST");
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseBase<UserModel>>(LocalFile.Config.ApiIpHost + "batchBindMatDetail/deleteMatDetailCurrentInfoForBind", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
BtnSearch();
|
||||
@ -344,7 +344,7 @@ namespace 智慧物流软件系统.ViewModel
|
||||
string path = ofd.FileName;
|
||||
|
||||
var result = await ApiHelp.StationPostImportFileAsync<ResponseCommon<List<string>>>(path, System.Net.Http.HttpMethod.Post,
|
||||
LocalFile.Config.ApiIpHost + "batchBindMatDetail/importMatDetailCurrentInfos", LocalStatic.CurrentUser, LocalFile.Config.DeviceType,LocalFile.Config.LocationCode);
|
||||
LocalFile.Config.ApiIpHost + "batchBindMatDetail/importMatDetailCurrentInfos", LocalStatic.CurrentUser, LocalFile.Config.DeviceType,StationCode);
|
||||
if (result.Code == 200)
|
||||
{
|
||||
Growl.Success("成功导入!");
|
||||
|
@ -7,7 +7,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="737" d:DesignWidth="1192" LoadedVisibleFirst="LoadedVisible">
|
||||
d:DesignHeight="737" d:DesignWidth="1192" Loaded="LoadedVisible">
|
||||
<Border Margin="0" Background="AliceBlue" CornerRadius="3" Padding="0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@ -87,14 +87,14 @@
|
||||
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||
|
||||
<Button MinHeight="40"
|
||||
<!--<Button MinHeight="40"
|
||||
FontSize="18"
|
||||
Margin="5"
|
||||
Content="新 增"
|
||||
FontFamily="{StaticResource IconFont}"
|
||||
Foreground="WhiteSmoke"
|
||||
Background="HotPink"
|
||||
Command="{Binding BtnAddCommand}"></Button>
|
||||
Command="{Binding BtnAddCommand}"></Button>-->
|
||||
|
||||
<Button MinHeight="40" FontSize="18" Margin="5"
|
||||
Content="修 改" FontFamily="{StaticResource IconFont}"
|
||||
@ -139,12 +139,12 @@
|
||||
<TextBlock MinHeight="40"
|
||||
FontSize="25"
|
||||
Margin="20 0 0 0 "
|
||||
VerticalAlignment="Center">站位编号:</TextBlock>
|
||||
VerticalAlignment="Center">绑定人:</TextBlock>
|
||||
<TextBlock MinHeight="40"
|
||||
FontSize="25"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding StationCode}"></TextBlock>
|
||||
<Button MinHeight="40"
|
||||
<!--<Button MinHeight="40"
|
||||
FontSize="18"
|
||||
Margin="5"
|
||||
Content="呼叫货架"
|
||||
@ -159,7 +159,7 @@
|
||||
FontFamily="{StaticResource IconFont}"
|
||||
Command="{Binding BtnSend}"
|
||||
Foreground="WhiteSmoke"
|
||||
Background="OrangeRed"></Button>
|
||||
Background="OrangeRed"></Button>-->
|
||||
</StackPanel>
|
||||
|
||||
<DataGrid Grid.Row="1"
|
||||
@ -199,7 +199,7 @@
|
||||
<DataGridTextColumn Header="货架编码"
|
||||
Binding="{Binding ShelfCode}"></DataGridTextColumn>
|
||||
|
||||
<DataGridTextColumn IsReadOnly="True" Header="更新人" Binding="{Binding ModifyUser}"></DataGridTextColumn>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="绑定人" Binding="{Binding StationCode}"></DataGridTextColumn>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="更新时间" Binding="{Binding ModifyTime ,StringFormat='yyyy-MM-dd HH:mm:ss'}"></DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
@ -18,7 +18,7 @@ namespace 智慧物流软件系统
|
||||
{
|
||||
public partial class BatchBindMatDetailView : UserControlBase
|
||||
{
|
||||
public BatchBindMatDetailViewModel viewModel { get; set; } = new BatchBindMatDetailViewModel();
|
||||
public static BatchBindMatDetailViewModel viewModel { get; set; } = new BatchBindMatDetailViewModel();
|
||||
public BatchBindMatDetailView()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -28,6 +28,7 @@ namespace 智慧物流软件系统
|
||||
|
||||
private void LoadedVisible(object sender, EventArgs e)
|
||||
{
|
||||
viewModel.StationCode = LocalStatic.CurrentUser;
|
||||
viewModel.BtnReset();
|
||||
viewModel.BtnSearchReset();
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace 智慧物流软件系统
|
||||
ViewModel.textBox = txtMatQty;
|
||||
ViewModel.SetValues(_matDetailCurrentInfoModel);
|
||||
//绑定标题
|
||||
Title.Text = "修改货架存量";
|
||||
Title.Text = _titleText;
|
||||
|
||||
|
||||
}
|
||||
@ -57,6 +57,12 @@ namespace 智慧物流软件系统
|
||||
}
|
||||
#endregion
|
||||
|
||||
var url = LocalFile.Config.ApiIpHost + "matDetailCurrenInfo/updateMatDetailCurrentInfo";
|
||||
if (this.Title.Text == "修改绑定数据")
|
||||
{
|
||||
url = LocalFile.Config.ApiIpHost + "batchBindMatDetail/updateMatDetailCurrentInfoForBind";
|
||||
}
|
||||
|
||||
#region 保存/修改值
|
||||
var body = new AddLocaionInfoRequest<MatDetailCurrentInfoModel>()
|
||||
{
|
||||
@ -65,7 +71,7 @@ namespace 智慧物流软件系统
|
||||
LocationInfo = ViewModel.GetValues(),
|
||||
AddOrUpdate = AddOrUpdate.Update
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseBase<object>>(LocalFile.Config.ApiIpHost + "matDetailCurrenInfo/updateMatDetailCurrentInfo", body, "POST");
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseBase<object>>(url, body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
|
||||
|
@ -108,6 +108,9 @@ namespace 智慧物流软件系统
|
||||
viewModel.Roles = viewModel.User?.GetRoles;
|
||||
viewModel.IsLogin = true;
|
||||
LocalStatic.CurrentUser = loginName;
|
||||
BatchBindMatDetailView.viewModel.StationCode = loginName;
|
||||
BatchBindMatDetailView.viewModel.BtnSearchReset();
|
||||
|
||||
this.DialogResult = true;
|
||||
this.Close();
|
||||
}
|
||||
|
Reference in New Issue
Block a user