!提交代码
This commit is contained in:
93
WCS.WebApi/Controllers/HomeController.cs
Normal file
93
WCS.WebApi/Controllers/HomeController.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.Home;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 主页面的接口
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class HomeController : ControllerBase
|
||||
{
|
||||
public IHomerService _homerService { get; set; }
|
||||
|
||||
public HomeController(IHomerService homerService)
|
||||
{
|
||||
_homerService = homerService;
|
||||
}
|
||||
|
||||
[Route("getShelfTypes")]
|
||||
[HttpPost(Name = "getShelfTypes")]
|
||||
public async Task<ResponseBase> getShelfTypes(RequestBase request)
|
||||
{
|
||||
try
|
||||
{
|
||||
//直接获取当前所有货架类型并返回
|
||||
var shelfTypes = DbHelp.db.Queryable<ShelfTypeInfo>()
|
||||
.Select(t => new ShelfTypeModel()
|
||||
{
|
||||
Id = t.Id,
|
||||
ShelfTypeName = t.ShelfTypeName
|
||||
})
|
||||
.ToList();
|
||||
return new PageQueryResponse<ShelfTypeModel>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = new PageQueryResponseData<ShelfTypeModel>
|
||||
{
|
||||
Lists = shelfTypes,
|
||||
Count = shelfTypes.Count
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<ShelfTypeModel>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"查询失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Route("getShelfStatus")]
|
||||
[HttpPost(Name = "getShelfStatus")]
|
||||
public async Task<ResponseBase> getShelfStatus(GetShelfStatusRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var shelfs = ShelfManager.Shelves
|
||||
.WhereIF(request.GroupNames?.Count > 0, t => request.GroupNames!.Contains(t.GroupName))
|
||||
.ToList();
|
||||
//直接返回当前内存中缓存的货架和状态
|
||||
return new GetShelfStatusResponse()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = shelfs.Select(t => new Shelf
|
||||
{
|
||||
ShelfId = t.ShelfId,
|
||||
ShelfCode = t.ShelfCode,
|
||||
CurentMode = (int)t.CurentMode,
|
||||
ModulesStr = t.ModulesStr,
|
||||
GroupName = t.GroupName
|
||||
}).ToList(),
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user