diff --git a/WCS.BLL/DbModels/ShelfInfo.cs b/WCS.BLL/DbModels/ShelfInfo.cs
index 2a40365..2452ba7 100644
--- a/WCS.BLL/DbModels/ShelfInfo.cs
+++ b/WCS.BLL/DbModels/ShelfInfo.cs
@@ -49,17 +49,18 @@ namespace WCS.DAL.DbModels
public DateTime SetCurrentModeTime { get; set; }
///
- /// 货架行数
+ /// 货架行数 对应单灯的第几行
///
[SugarColumn(ColumnName = "row_counts", IsNullable = false, ColumnDescription = "货架行数")]
- public int Rowcounts { get; set; }
+ public int Rowcounts { get; set; }
///
- /// 货架列数
+ /// 货架列数 对应一行有几个
///
[SugarColumn(ColumnName = "column_counts", IsNullable = false, ColumnDescription = "货架列数")]
public int Columncounts { get; set; }
+
///
/// 货架对应警示灯的Id
///
diff --git a/WCS.BLL/Services/Service/SingleLightService.cs b/WCS.BLL/Services/Service/SingleLightService.cs
index 5cfd6ad..77e8086 100644
--- a/WCS.BLL/Services/Service/SingleLightService.cs
+++ b/WCS.BLL/Services/Service/SingleLightService.cs
@@ -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 })
diff --git a/WCS.WebApi/Controllers/SingleLightController.cs b/WCS.WebApi/Controllers/SingleLightController.cs
index 09f416a..8d6bd9b 100644
--- a/WCS.WebApi/Controllers/SingleLightController.cs
+++ b/WCS.WebApi/Controllers/SingleLightController.cs
@@ -100,5 +100,114 @@ namespace WCS.WebApi.Controllers
}
}
+
+ [Route("GenerateSingleLightStoreInfo")]
+ [HttpGet(Name = "GenerateSingleLightStoreInfo")]
+ public async Task GenerateSingleLightStoreInfo()
+ {
+ try
+ {
+ //获取单灯类型的货架
+ var shelfInfo = DbHelp.db.Queryable()
+ .Where(t => t.ShelfTypeName == "信息化货架")
+ .OrderBy(t => t.ShelfCode)
+ .ToList();
+ var storesToSave = new List();
+ 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,
+ };
+ }
+ }
+
}
}