Commit 429f84ce by xin.yang

some update

parent abc0a987
...@@ -42,6 +42,7 @@ namespace Siger.ApiACC.Controllers ...@@ -42,6 +42,7 @@ namespace Siger.ApiACC.Controllers
{ {
var data = _autoLocationRepository.GetPagedList(wavehouseid.ToInt(), locationid.ToInt(), ProjectId, page, pagesize); var data = _autoLocationRepository.GetPagedList(wavehouseid.ToInt(), locationid.ToInt(), ProjectId, page, pagesize);
var list = new List<ResponseAutomationLocation>(); var list = new List<ResponseAutomationLocation>();
var locations = _autoLocationRepository.GetLocationList(ProjectId);
foreach(var item in data.Data) foreach(var item in data.Data)
{ {
if(item.fixturetoolid > 0 && string.IsNullOrEmpty(item.sn)) if(item.fixturetoolid > 0 && string.IsNullOrEmpty(item.sn))
...@@ -72,10 +73,26 @@ namespace Siger.ApiACC.Controllers ...@@ -72,10 +73,26 @@ namespace Siger.ApiACC.Controllers
item.routenumber = route.serialNumber.ToString(); item.routenumber = route.serialNumber.ToString();
} }
} }
var loca = locations.FirstOrDefault(q => q.locationid == item.locationid);
if(loca != null)
{
var locas = GetParentLocations(loca.id, locations);
var locationIds = locas.Select(q => q.id).ToList();
locationIds.Distinct().Reverse();
item.locationIds = locationIds;
}
} }
return new PagedObjectResult(data.Data, data.Total, page, pagesize); return new PagedObjectResult(data.Data, data.Total, page, pagesize);
} }
private IEnumerable<siger_wms_storage_location> GetParentLocations(int pid, IEnumerable<siger_wms_storage_location> types)
{
var query = from c in types where c.id == pid select c;
return query.ToList().Concat(query.ToList().SelectMany(t => GetParentLocations(t.parentid, types)));
}
[HttpPost] [HttpPost]
public IActionResult Add([FromBody]RequestAddAutomationLocation req) public IActionResult Add([FromBody]RequestAddAutomationLocation req)
{ {
...@@ -103,7 +120,7 @@ namespace Siger.ApiACC.Controllers ...@@ -103,7 +120,7 @@ namespace Siger.ApiACC.Controllers
var entity = new siger_automation_location var entity = new siger_automation_location
{ {
guid = Guid.NewGuid().ToString(), guid = Guid.NewGuid().ToString(),
locationid = req.locationid.ToInt(), locationid = location.locationid,
fixturetools = fixturetool.guid, fixturetools = fixturetool.guid,
attachment = req.fileurl, attachment = req.fileurl,
filename = req.filename, filename = req.filename,
...@@ -152,7 +169,7 @@ namespace Siger.ApiACC.Controllers ...@@ -152,7 +169,7 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.DataExist);
} }
entity.locationid = req.locationid.ToInt(); entity.locationid = location.locationid;
entity.fixturetools = fixturetool.guid; entity.fixturetools = fixturetool.guid;
entity.attachment = req.fileurl; entity.attachment = req.fileurl;
entity.filename = req.filename; entity.filename = req.filename;
......
...@@ -1153,13 +1153,6 @@ namespace Siger.ApiWMS.Controllers ...@@ -1153,13 +1153,6 @@ namespace Siger.ApiWMS.Controllers
})); }));
locationTreeList.AddRange(locas); locationTreeList.AddRange(locas);
} }
var locationModels = locations.Select(q => new LevelSectionTree
{
id = q.id,
pid = q.parentid,
title = q.name,
name = q.name
}).ToList();
var locationTree = locationTreeList.GroupBy(q => q.id).Select(q => q.FirstOrDefault()).ToList(); var locationTree = locationTreeList.GroupBy(q => q.id).Select(q => q.FirstOrDefault()).ToList();
return new ObjectResult(ConvertToTree(locationTree)); return new ObjectResult(ConvertToTree(locationTree));
......
...@@ -68,7 +68,12 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -68,7 +68,12 @@ namespace Siger.Middlelayer.AccRepository.Repositories
public siger_wms_storage_location GetLocation(int id, int projectid) public siger_wms_storage_location GetLocation(int id, int projectid)
{ {
return _context.siger_wms_storage_location.FirstOrDefault(q => q.locationid == id && q.projectId == projectid && q.status == (int)RowState.Valid); return _context.siger_wms_storage_location.FirstOrDefault(q => q.id == id && q.projectId == projectid && q.status == (int)RowState.Valid);
}
public IEnumerable<siger_wms_storage_location> GetLocationList(int projectid)
{
return _context.siger_wms_storage_location.Where(q => q.projectId == projectid && q.status == (int)RowState.Valid);
} }
public IEnumerable<ResponseAutomationLocationList> GetDataList(int projectid) public IEnumerable<ResponseAutomationLocationList> GetDataList(int projectid)
......
...@@ -14,5 +14,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface ...@@ -14,5 +14,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
siger_wms_storage_location GetLocation(int id, int projectid); siger_wms_storage_location GetLocation(int id, int projectid);
IEnumerable<ResponseAutomationLocationList> GetDataList(int projectid); IEnumerable<ResponseAutomationLocationList> GetDataList(int projectid);
IEnumerable<siger_wms_storage_location> GetLocationList(int projectid);
} }
} }
...@@ -47,6 +47,8 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -47,6 +47,8 @@ namespace Siger.Middlelayer.AccRepository.Response
public string updatetime { get; set; } public string updatetime { get; set; }
public int status { get; set; } public int status { get; set; }
public List<int> locationIds { get; set; } = new List<int>();
} }
public class ResponseAutomationLocationList public class ResponseAutomationLocationList
......
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