生成单灯货架的库位接口

This commit is contained in:
hehaibing-1996
2025-04-10 16:44:53 +08:00
parent 710eaec35d
commit 917a13b197
3 changed files with 115 additions and 5 deletions

View File

@ -49,17 +49,18 @@ namespace WCS.DAL.DbModels
public DateTime SetCurrentModeTime { get; set; }
/// <summary>
/// 货架行数
/// 货架行数 对应单灯的第几行
/// </summary>
[SugarColumn(ColumnName = "row_counts", IsNullable = false, ColumnDescription = "货架行数")]
public int Rowcounts { get; set; }
/// <summary>
/// 货架列数
/// 货架列数 对应一行有几个
/// </summary>
[SugarColumn(ColumnName = "column_counts", IsNullable = false, ColumnDescription = "货架列数")]
public int Columncounts { get; set; }
/// <summary>
/// 货架对应警示灯的Id
/// </summary>

View File

@ -192,8 +192,8 @@ namespace WCS.BLL.Services.Service
//更新数据库灯的状态
stores.ForEach(t =>
{
t.LightMode = request.ColorMode;
t.ColorMode = request.LightMode;
t.LightMode = request.LightMode;
t.ColorMode = request.ColorMode;
});
DbHelp.db.Updateable(stores)
.UpdateColumns(t => new { t.LightMode, t.ColorMode })

View File

@ -100,5 +100,114 @@ namespace WCS.WebApi.Controllers
}
}
[Route("GenerateSingleLightStoreInfo")]
[HttpGet(Name = "GenerateSingleLightStoreInfo")]
public async Task<ResponseBase> GenerateSingleLightStoreInfo()
{
try
{
//获取单灯类型的货架
var shelfInfo = DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.ShelfTypeName == "信息化货架")
.OrderBy(t => t.ShelfCode)
.ToList();
var storesToSave = new List<StoreInfo>();
foreach (var shelf in shelfInfo)
{
if (shelf.ShelfCode == "C07-4")
;
var row = shelf.Rowcounts % 2;
//如果是奇数行
if (row == 1)
{
//之前已经占用的id
var id = (shelf.Rowcounts - 1) * (shelf.Columncounts + 7);
//奇数行 灯Id是最后一个灯
for (int i = shelf.Columncounts; i > 0; i--)
{
var storeInfo = new StoreInfo()
{
StoreCode = shelf.ShelfCode + "-" + i.ToString(),
ShelfTypeId = shelf.ShelfTypeId,
ModuleId = 0,
ModuleCode = shelf.ShelfCode + "-" + i.ToString(),
ShelfId = shelf.Id,
ShelfCode = shelf.ShelfCode,
BoardId = ++id,
LightNumber = 1,
Priority = 0,
R = shelf.Rowcounts.ToString(),
C = i.ToString(),
Wei = "1",
SingleLightNumber = 1,
LightMode = 0,
ColorMode = 0,
GroupName = shelf.GroupName,
Area = shelf.ShelfCode.Substring(0,1),
};
storesToSave.Add(storeInfo);
}
shelf.LightId = ++id;
}
//偶数行
else
{
//之前已经占用的id
var id = (shelf.Rowcounts - 1) * (shelf.Columncounts + 7);
shelf.LightId = ++id;
//灯占7个ID
id = id + 6;
//奇数行 灯Id是最后一个灯
for (int i = 1; i <= shelf.Columncounts; i++)
{
var storeInfo = new StoreInfo()
{
StoreCode = shelf.ShelfCode + "-" + i.ToString(),
ShelfTypeId = shelf.ShelfTypeId,
ModuleId = 0,
ModuleCode = shelf.ShelfCode + "-" + i.ToString(),
ShelfId = shelf.Id,
ShelfCode = shelf.ShelfCode,
BoardId = ++id,
LightNumber = 1,
Priority = 0,
R = shelf.Rowcounts.ToString(),
C = i.ToString(),
Wei = "1",
SingleLightNumber = 1,
LightMode = 0,
ColorMode = 0,
GroupName = shelf.GroupName,
Area = shelf.ShelfCode.Substring(0, 1),
};
storesToSave.Add(storeInfo);
}
}
}
DbHelp.db.Insertable(storesToSave).ExecuteCommand();
DbHelp.db.Updateable(shelfInfo).ExecuteCommand();
return new ResponseCommon()
{
Code = 200,
Message = "success",
Data = null
};
}
catch (Exception ex)
{
return new ResponseBase()
{
Code = 300,
Message = "操作失败:" + ex.Message,
};
}
}
}
}