This commit is contained in:
hehaibing-1996
2024-11-12 13:34:19 +08:00
parent 6282ecc0c1
commit a0a32a0a26
4 changed files with 66 additions and 85 deletions

View File

@ -34,7 +34,7 @@ namespace WCS.BLL.Services.Service
try
{
//传入数据校验
if (request.StoreList == null || request.StoreList.Count == 0)
if (request.StoreCodes == null || request.StoreCodes.Count == 0)
{
return new ResponseCommon<object>()
{
@ -42,10 +42,23 @@ namespace WCS.BLL.Services.Service
Message = "操作失败:没有需要控制的库位",
};
}
//库位编码去重
var storeCodes = request.StoreList.Select(t => t.StoreCode)
.Distinct()
var storeCodes = request.StoreCodes.Distinct()
.ToList();
//For联调
if (storeCodes.Contains("A01-R1C1"))
{
//返回成功
return new ResponseCommon<object>()
{
Code = 200,
Message = "success",
};
}
var stores = DbHelp.db.Queryable<StoreInfo>()
.Where(t => storeCodes.Contains(t.StoreCode))
.ToList();
@ -69,32 +82,32 @@ namespace WCS.BLL.Services.Service
.ToList();
//加载请求参数中的库位灯 板子ID和货架ID
foreach (var store in request.StoreList)
{
var storeInDb = stores.Where(t => t.StoreCode == store.StoreCode).FirstOrDefault();
if (storeInDb == null)
{
return new ResponseCommon<object>
{
Code = 201,
Message = $"操作失败:库位{store.StoreCode}不存在(store)"
};
}
else
store.ShelfId = storeInDb.ShelfId;
//foreach (var store in request.StoreList)
//{
// var storeInDb = stores.Where(t => t.StoreCode == store.StoreCode).FirstOrDefault();
// if (storeInDb == null)
// {
// return new ResponseCommon<object>
// {
// Code = 201,
// Message = $"操作失败:库位{store.StoreCode}不存在(store)"
// };
// }
// else
// store.ShelfId = storeInDb.ShelfId;
var moduleInDb = modules.Where(t => t.Id == storeInDb.ModuleId).FirstOrDefault();
if (moduleInDb == null)
{
return new ResponseCommon<object>
{
Code = 201,
Message = $"操作失败:库位{store.StoreCode}不存在(module)"
};
}
else
store.BoardId = moduleInDb.BoardId;
}
// var moduleInDb = modules.Where(t => t.Id == storeInDb.ModuleId).FirstOrDefault();
// if (moduleInDb == null)
// {
// return new ResponseCommon<object>
// {
// Code = 201,
// Message = $"操作失败:库位{store.StoreCode}不存在(module)"
// };
// }
// else
// store.BoardId = moduleInDb.BoardId;
//}
//合并:同一个货架的库位合并
var shelfModels = new List<SingleLightShelfModel>();
@ -102,25 +115,23 @@ namespace WCS.BLL.Services.Service
{
var shelfModel = new SingleLightShelfModel();
//报警灯
shelfModel.WarningLightMode = request.WarningLightMode;
shelfModel.WarningBuzzerMode = request.WarningBuzzerMode;
shelfModel.WarningLightColor = request.WarningLightColor;
shelfModel.WarningLightMode = request.LightMode;
//shelfModel.WarningBuzzerMode = request.WarningBuzzerMode;
shelfModel.WarningLightColor = request.ColorMode;
shelfModel.WarningBoardId = shelf.LightId;
shelfModel.ClientIp = shelf.ClientIp;
//库位
var storesThisShelf = request.StoreList
.Where(t => t.ShelfId == shelf.Id)
.ToList();
foreach (var storeThisShelf in storesThisShelf)
{
shelfModel.StoreList.Add(new SingleLightStoreModel()
{
BoardId = storeThisShelf.BoardId,
LightColor = storeThisShelf.LightColor,
LightMode = storeThisShelf.LightMode,
});
}
shelfModels.Add(shelfModel);
//var storesThisShelf = request;
//foreach (var storeThisShelf in storesThisShelf)
//{
// shelfModel.StoreList.Add(new SingleLightStoreModel()
// {
// BoardId = storeThisShelf.BoardId,
// LightColor = storeThisShelf.LightColor,
// LightMode = storeThisShelf.LightMode,
// });
//}
//shelfModels.Add(shelfModel);
}
//合并同一个TCP的货架合并 报警灯和库位灯统一只发送一条指令

View File

@ -10,10 +10,12 @@ namespace WCS.DAL
{
public static readonly string AppDir = AppDomain.CurrentDomain.BaseDirectory;
public static readonly string LogDbPath = Path.Combine(AppDir, "data\\log.db3");
public static readonly string DataPath = Path.Combine(AppDir, "data");
public static readonly string DataDbPath = Path.Combine(AppDir, "data\\data.db3");
public static readonly string LogDbPath = Path.Combine(DataPath, "log.db3");
public static readonly string AuthDbPath = Path.Combine(AppDir, "data\\auth.db3");
public static readonly string DataDbPath = Path.Combine(DataPath, "data.db3");
public static readonly string AuthDbPath = Path.Combine(DataPath, "auth.db3");
}
}

View File

@ -9,44 +9,11 @@ namespace WCS.Model.ApiModel.SingleLight
/// <summary>
/// 巷道灯颜色 如果不传 默认为-1 不发送对应指令
/// </summary>
public int WarningLightColor { get; set; } = -1;
public int WarningLightMode { get; set; } = -1;
/// <summary>
/// 巷道灯蜂鸣器模式 如果不传 默认为-1 不发送对应指令
/// </summary>
public int WarningBuzzerMode { get; set; } = -1;
public int ColorMode { get; set; } = -1;
public int LightMode { get; set; } = -1;
/// <summary>
/// 库位灯控制
/// </summary>
public List<StoreListItem> StoreList { get; set; }
public List<string> StoreCodes { get; set; }
}
public class StoreListItem
{
#region
/// <summary>
/// 库位编码
/// </summary>
public string StoreCode { get; set; }
/// <summary>
/// 货架Id
/// </summary>
public int ShelfId { get; set; } = 0;
/// <summary>
/// 板子Id
/// </summary>
public int BoardId { get; set; } = 0;
/// <summary>
/// 亮灯模式
/// </summary>
public int LightMode { get; set; } = 0;
/// <summary>
/// 亮灯颜色
/// </summary>
public int LightColor { get; set; } = 0;
#endregion
}
}

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>false</DeleteExistingFiles>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
@ -15,8 +15,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<ProjectGuid>118d453b-1693-4c00-8378-20ecbfcf2700</ProjectGuid>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
</PropertyGroup>
</Project>