1.增加根据货架配置数据自动生成模组和库位的功能(纯后台)
2.发送指令异常时日志优化
This commit is contained in:
@ -7,6 +7,8 @@ using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.BLL.Config;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
@ -102,6 +104,125 @@ namespace WCS.WebApi.Controllers
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user