2 Commits

3 changed files with 135 additions and 1 deletions

View File

@ -103,6 +103,18 @@ namespace WCS.DAL.DbModels
[SugarColumn(ColumnName = "Bind_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")] [SugarColumn(ColumnName = "Bind_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")]
public string? BigShelfCode { get; set; } = string.Empty; public string? BigShelfCode { get; set; } = string.Empty;
/// <summary>
/// 每块板子的灯数量
/// </summary>
[SugarColumn(ColumnName = "light_count", IsNullable = true, ColumnDescription = "每块板子的灯数量")]
public int LightCount { get; set; }
/// <summary>
/// 每块板子的灯数量
/// </summary>
[SugarColumn(ColumnName = "first_board_id", IsNullable = true, ColumnDescription = "左上角的板子id")]
public int FirtstBoardId { get; set; }
/// <summary> /// <summary>
/// 序号 /// 序号
/// </summary> /// </summary>

View File

@ -260,7 +260,8 @@ namespace WCS.BLL
} }
catch (Exception ex) catch (Exception ex)
{ {
Logs.Write("【发送指令时发生异常】" + ex.Message, LogsType.Instructions); var clientIpHost = tcpClient.IP + ":" + tcpClient.Port;
Logs.Write($"【发送指令时发生异常{clientIpHost}】" + ex.Message, LogsType.Instructions);
//因异常断连时(网线已经被断了) 手动重连一次 //因异常断连时(网线已经被断了) 手动重连一次
if (ex is NotConnectedException) if (ex is NotConnectedException)
{ {

View File

@ -7,6 +7,8 @@ using WCS.Model.ApiModel.StoreInfo;
using WCS.BLL.DbModels; using WCS.BLL.DbModels;
using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.MatBaseInfo;
using WCS.DAL.DbModels; using WCS.DAL.DbModels;
using WCS.DAL.Db;
using WCS.BLL.Config;
namespace WCS.WebApi.Controllers namespace WCS.WebApi.Controllers
{ {
@ -102,6 +104,125 @@ namespace WCS.WebApi.Controllers
{ {
return await _storeInfoService.getDisablePercent(); return await _storeInfoService.getDisablePercent();
} }
[Route("genModuleStoreInfos")]
[HttpPost(Name = "genModuleStoreInfos")]
public async Task<ResponseBase> genModuleStoreInfos(RequestBase request)
{
try
{
if (request.UserName != "aaa")
{
return new ResponseBase()
{
Code = 300,
Message = "用户名不对头!无法生成模组库位"
};
}
//获取货架 此组后端管的货架
var shelfInfos = DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.GroupName == LocalFile.Config.GroupName)
.OrderBy(t => t.BigShelfCode)
.OrderBy(t => t.ShelfCode)
.ToList();
var lastBindBigShelfCode = string.Empty;
var lastColumnCount = 1;
List<ModuleInfo> moduleInfos = new List<ModuleInfo>();
//生成模组
foreach (var shelfInfo in shelfInfos)
{
var modulePreFix = shelfInfo.IsBind ? shelfInfo.BigShelfCode : shelfInfo.ShelfCode;
//不绑定或者绑定换了面 重新从1开始计数
if (shelfInfo.BigShelfCode != lastBindBigShelfCode)
{
lastColumnCount = 1;
}
lastBindBigShelfCode = shelfInfo.BigShelfCode;
for (int rowIndex = 0; rowIndex < shelfInfo.Rowcounts; rowIndex++)
{
for (int columnIndex = 0; columnIndex < shelfInfo.Columncounts; columnIndex++)
{
var moduleCode = modulePreFix + "-R" + (rowIndex + 1).ToString() + "C" + (lastColumnCount + columnIndex).ToString();
var moduleInfo = new ModuleInfo()
{
ModuleCode = moduleCode,
ShelfTypeId = shelfInfo.ShelfTypeId,
ShelfId = shelfInfo.Id,
ShelfCode = shelfInfo.ShelfCode,
BoardId = shelfInfo.FirtstBoardId++,
LightCount = shelfInfo.LightCount,
CleintIp = shelfInfo.ClientIp,
GroupName = shelfInfo.GroupName,
R = (rowIndex + 1).ToString(),
C = (lastColumnCount + columnIndex).ToString(),
Bigshelfcode = shelfInfo.BigShelfCode,
IsEnable = true,
CurrentMode = BLL.HardWare.Mode.,
};
moduleInfos.Add(moduleInfo);
}
}
lastColumnCount = lastColumnCount + shelfInfo.Columncounts;
}
DbHelp.db.Insertable(moduleInfos).ExecuteCommand();
//生成库位
moduleInfos = DbHelp.db.Queryable<ModuleInfo>()
.Where(t => t.GroupName == LocalFile.Config.GroupName)
.OrderBy(t => t.Id)
.ToList();
List<StoreInfo> storeInfos = new List<StoreInfo>();
foreach (var moduleInfo in moduleInfos)
{
for (int wei = 0; wei < moduleInfo.LightCount; wei++)
{
var storeCode = moduleInfo.ModuleCode + "-" + (wei + 1).ToString();
var stroreInfo = new StoreInfo()
{
StoreCode = storeCode,
ShelfTypeId = moduleInfo.ShelfTypeId,
ModuleId = moduleInfo.Id,
ModuleCode = moduleInfo.ModuleCode,
ShelfId = moduleInfo.ShelfId,
ShelfCode = moduleInfo.ShelfCode,
BoardId = moduleInfo.BoardId,
LightNumber = wei + 1,
Priority = 0,
CurrentMatSn = string.Empty,
CurrentVoltage = 0,
StandardVoltage = 0,
OffsetVoltage = 0,
BigShelfCode = moduleInfo.Bigshelfcode,
R = moduleInfo.R,
C = moduleInfo.C,
Wei = (wei + 1).ToString(),
GroupName = moduleInfo.GroupName
};
storeInfos.Add(stroreInfo);
}
}
DbHelp.db.Insertable(storeInfos).ExecuteCommand();
return new ResponseBase()
{
Code = 200,
Message = "生成库位成功"
};
}
catch (Exception ex)
{
return new ResponseBase()
{
Code = 300,
Message = ex.Message
};
}
}
#endregion #endregion
} }
} }