通过货架信息生成液晶货架的库位
This commit is contained in:
@ -8,6 +8,7 @@ using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.Home;
|
||||
|
||||
@ -290,5 +291,94 @@ namespace WCS.WebApi.Controllers
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成模组信息
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("generateModuleInfo")]
|
||||
[HttpPost(Name = "generateModuleInfo")]
|
||||
public async Task<ResponseBase> generateModuleInfo(RequestBase request)
|
||||
{
|
||||
try
|
||||
{
|
||||
//获取液晶的货架
|
||||
var shelfInfos = DbHelp.db.Queryable<ShelfInfo>()
|
||||
.Where(t => t.ShelfTypeName.Contains("液晶"))
|
||||
.ToList();
|
||||
var moduleInfos = new List<ModuleInfo>();
|
||||
|
||||
int boardId = 1;
|
||||
var lastClientCode = string.Empty;
|
||||
|
||||
foreach (var shelfInfo in shelfInfos)
|
||||
{
|
||||
if (lastClientCode != shelfInfo.ClientIp)
|
||||
{
|
||||
lastClientCode = shelfInfo.ClientIp;
|
||||
boardId = 1;
|
||||
}
|
||||
int shelfNumber = 1;
|
||||
int floorNumber = 1;
|
||||
int moduleNumber = 0;
|
||||
while (floorNumber <= 4)
|
||||
{
|
||||
moduleNumber++;
|
||||
if (moduleNumber > 7)
|
||||
{
|
||||
shelfNumber++;
|
||||
moduleNumber = 1;
|
||||
}
|
||||
if (shelfNumber > 4)
|
||||
{
|
||||
floorNumber++;
|
||||
shelfNumber = 1;
|
||||
}
|
||||
|
||||
if (floorNumber == 5)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var moduleCode = $"{shelfInfo.ShelfCode}-{shelfNumber}-L{floorNumber}-{moduleNumber}";
|
||||
var module = new ModuleInfo()
|
||||
{
|
||||
ModuleCode = moduleCode,
|
||||
ShelfTypeId = 3,
|
||||
ShelfId = shelfInfo.Id,
|
||||
ShelfCode = shelfInfo.ShelfCode,
|
||||
BoardId = boardId ++,
|
||||
LightCount = 1,
|
||||
CleintIp = shelfInfo.ClientIp,
|
||||
GroupName = shelfInfo.GroupName,
|
||||
R = floorNumber.ToString(),
|
||||
C = moduleNumber.ToString(),
|
||||
IsEnable = true,
|
||||
};
|
||||
moduleInfos.Add(module);
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
DbHelp.db.Insertable(moduleInfos).ExecuteCommand();
|
||||
|
||||
return new ResponseBase<object>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "生成成功!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseBase<object>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "生成失败" + ex.Message,
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user