Commit 31eab02c by xin.yang

fix bug

parent 20638bc8
...@@ -48,9 +48,16 @@ namespace Siger.ApiACC.Controllers ...@@ -48,9 +48,16 @@ namespace Siger.ApiACC.Controllers
[HttpGet] [HttpGet]
public IActionResult GetPageList(string wavehouseid, string locationid, int page, int pagesize, string toexcel) public IActionResult GetPageList(string wavehouseid, string locationid, int page, int pagesize, string toexcel)
{ {
var data = _autoLocationRepository.GetPagedList(wavehouseid.ToInt(), locationid.ToInt(), ProjectId, page, pagesize, toexcel);
var list = new List<ResponseAutomationLocation>();
var locations = _autoLocationRepository.GetLocationList(ProjectId); var locations = _autoLocationRepository.GetLocationList(ProjectId);
var locationids = new List<int>();
if(locationid.ToInt() > 0)
{
var searchLocations = GetSonLocations(locationid.ToInt(), locations);
locationids = searchLocations.Select(q => q.id).ToList();
locationids.Add(locationid.ToInt());
}
var data = _autoLocationRepository.GetPagedList(wavehouseid.ToInt(), locationids, ProjectId, page, pagesize, toexcel);
var list = new List<ResponseAutomationLocation>();
var categorys = _toolsCategoryRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).ToList(); var categorys = _toolsCategoryRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).ToList();
foreach (var item in data.Data) foreach (var item in data.Data)
{ {
...@@ -182,6 +189,13 @@ namespace Siger.ApiACC.Controllers ...@@ -182,6 +189,13 @@ namespace Siger.ApiACC.Controllers
return query.ToList().Concat(query.ToList().SelectMany(t => GetParentLocations(t.parentid, types))); return query.ToList().Concat(query.ToList().SelectMany(t => GetParentLocations(t.parentid, types)));
} }
private IEnumerable<siger_wms_storage_location> GetSonLocations(int id, IEnumerable<siger_wms_storage_location> types)
{
var query = from c in types where c.parentid == id select c;
return query.ToList().Concat(query.ToList().SelectMany(t => GetSonLocations(t.id, types)));
}
[HttpPost] [HttpPost]
public IActionResult Add([FromBody]RequestAddAutomationLocation req) public IActionResult Add([FromBody]RequestAddAutomationLocation req)
{ {
......
...@@ -69,6 +69,10 @@ namespace Siger.ApiACC.Controllers ...@@ -69,6 +69,10 @@ namespace Siger.ApiACC.Controllers
var models = new List<ResponseAumationFixtureToolsAssembly>(); var models = new List<ResponseAumationFixtureToolsAssembly>();
var details = _toolsAssemblyRepository.GetDetailList(item.fixtureguid, category.ToInt(), code, name, state, ProjectId); var details = _toolsAssemblyRepository.GetDetailList(item.fixtureguid, category.ToInt(), code, name, state, ProjectId);
if (!details.Any())
{
details = _toolsAssemblyRepository.GetDetailList(item.fixtureguid, 0, "", "", "", ProjectId);//这里是为了符合测试的逻辑,当父级找到,子级找不到时,也把子级全部显示出来
}
foreach(var model in details) foreach(var model in details)
{ {
var cates1 = GetParentCategoryList(model.cate_guid, categorys); var cates1 = GetParentCategoryList(model.cate_guid, categorys);
......
...@@ -24,7 +24,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -24,7 +24,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
_context = context; _context = context;
} }
public IPagedCollectionResult<ResponseAutomationLocation> GetPagedList(int wavehouseid, int locationid, int projectid, int page, int pagesize, string toexcel) public IPagedCollectionResult<ResponseAutomationLocation> GetPagedList(int wavehouseid, IEnumerable<int> locationid, int projectid, int page, int pagesize, string toexcel)
{ {
var query = from q in _context.siger_automation_location var query = from q in _context.siger_automation_location
join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid
...@@ -67,9 +67,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -67,9 +67,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories
wavehouseidExpression = q => q.wavehouseid == wavehouseid; wavehouseidExpression = q => q.wavehouseid == wavehouseid;
} }
Expression<Func<ResponseAutomationLocation, bool>> locationidExpression = f => true; Expression<Func<ResponseAutomationLocation, bool>> locationidExpression = f => true;
if (locationid > 0) if (locationid.Any())
{ {
locationidExpression = q => q.locationid == locationid; locationidExpression = q => locationid.Contains(q.locationid);
} }
var expression = wavehouseidExpression.And(locationidExpression); var expression = wavehouseidExpression.And(locationidExpression);
if(toexcel.ToInt() == 1) if(toexcel.ToInt() == 1)
......
...@@ -9,7 +9,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface ...@@ -9,7 +9,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
{ {
public interface IAutomationLocationRepository : IAccRepositoryBase<siger_automation_location> public interface IAutomationLocationRepository : IAccRepositoryBase<siger_automation_location>
{ {
IPagedCollectionResult<ResponseAutomationLocation> GetPagedList(int wavehouseid, int locationid, int projectid, int page, int pagesize, string toexcel); IPagedCollectionResult<ResponseAutomationLocation> GetPagedList(int wavehouseid, IEnumerable<int> locationid, int projectid, int page, int pagesize, string toexcel);
siger_wms_storage_location GetLocation(int id, int projectid); siger_wms_storage_location GetLocation(int id, int projectid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment