Commit 429f84ce by xin.yang

some update

parent abc0a987
......@@ -42,6 +42,7 @@ namespace Siger.ApiACC.Controllers
{
var data = _autoLocationRepository.GetPagedList(wavehouseid.ToInt(), locationid.ToInt(), ProjectId, page, pagesize);
var list = new List<ResponseAutomationLocation>();
var locations = _autoLocationRepository.GetLocationList(ProjectId);
foreach(var item in data.Data)
{
if(item.fixturetoolid > 0 && string.IsNullOrEmpty(item.sn))
......@@ -72,10 +73,26 @@ namespace Siger.ApiACC.Controllers
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);
}
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]
public IActionResult Add([FromBody]RequestAddAutomationLocation req)
{
......@@ -103,7 +120,7 @@ namespace Siger.ApiACC.Controllers
var entity = new siger_automation_location
{
guid = Guid.NewGuid().ToString(),
locationid = req.locationid.ToInt(),
locationid = location.locationid,
fixturetools = fixturetool.guid,
attachment = req.fileurl,
filename = req.filename,
......@@ -152,7 +169,7 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(RequestEnum.DataExist);
}
entity.locationid = req.locationid.ToInt();
entity.locationid = location.locationid;
entity.fixturetools = fixturetool.guid;
entity.attachment = req.fileurl;
entity.filename = req.filename;
......
......@@ -1153,13 +1153,6 @@ namespace Siger.ApiWMS.Controllers
}));
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();
return new ObjectResult(ConvertToTree(locationTree));
......
......@@ -68,7 +68,12 @@ namespace Siger.Middlelayer.AccRepository.Repositories
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)
......
......@@ -14,5 +14,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
siger_wms_storage_location GetLocation(int id, int projectid);
IEnumerable<ResponseAutomationLocationList> GetDataList(int projectid);
IEnumerable<siger_wms_storage_location> GetLocationList(int projectid);
}
}
......@@ -47,6 +47,8 @@ namespace Siger.Middlelayer.AccRepository.Response
public string updatetime { get; set; }
public int status { get; set; }
public List<int> locationIds { get; set; } = new List<int>();
}
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