Commit a4ab1188 by jiawei.su
parents e41af7d6 16d27a70
......@@ -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;
......
......@@ -370,5 +370,13 @@ namespace Siger.ApiACC.Controllers
}
return resp;
}
[HttpGet]
public IActionResult GetFixtureToolList()
{
var list = _toolsRepository.GetDataList(ProjectId);
return new ObjectResult(list);
}
}
}
......@@ -1127,5 +1127,67 @@ namespace Siger.ApiWMS.Controllers
return query.ToList().Concat(query.ToList().SelectMany(t => GetSonTypes(t.id, types)));
}
[HttpGet]
public IActionResult GetLocationTree(int warehouseid)
{
var locationTypes = locationtype.GetList(q => q.projectid == ProjectId && q.status == (int)RowState.Valid).ToList();
var sonLocationTypes = GetSonTypes(0, locationTypes).ToList();
var lastLocationId = sonLocationTypes.LastOrDefault()?.id ?? 0;
var allLocas = location.GetList(q => q.projectid == ProjectId && q.status == (int)RowState.Valid).ToList();
var locations = allLocas.Where(q => q.typeid == lastLocationId);
if(warehouseid > 0)
{
locations = locations.Where(q => q.storageid == warehouseid);
}
var locationTreeList = new List<LevelSectionTree>();
foreach(var loca in locations)
{
var locas = GetParentLocations(loca.id, allLocas.Select(q => new LevelSectionTree
{
id = q.id,
pid = q.parentid,
title = q.name,
name = q.name
}));
locationTreeList.AddRange(locas);
}
var locationTree = locationTreeList.GroupBy(q => q.id).Select(q => q.FirstOrDefault()).ToList();
return new ObjectResult(ConvertToTree(locationTree));
}
private IEnumerable<LevelSectionTree> GetParentLocations(int pid, IEnumerable<LevelSectionTree> types)
{
var query = from c in types where c.id == pid select c;
return query.ToList().Concat(query.ToList().SelectMany(t => GetParentLocations(t.pid, types)));
}
private IList<LevelSectionTree> ConvertToTree(IEnumerable<LevelSectionTree> models)
{
var section = new Dictionary<int, LevelSectionTree>();
foreach (var item in models)
{
section.Add(item.id, item);
}
var result = new List<LevelSectionTree>();
foreach (var item in section.Values)
{
if (item.pid == 0)
{
result.Add(item);
}
else
{
if (section.ContainsKey(item.pid))
{
section[item.pid].AddChilrden(item);
}
}
}
return result;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
......@@ -73,5 +74,32 @@ namespace Siger.Middlelayer.AccRepository.Repositories
var totalCount = query.Where(expression).Count();
return new PagedCollectionResult<ResponseFixtureTools>(entities, totalCount);
}
public IEnumerable<ResponseFixtureTools> GetDataList(int projectid)
{
var query = from q in _context.siger_automation_fixture_tools
join p in _context.siger_automation_fixture_tools_category on q.category equals p.guid
where q.projectId == projectid && q.status == (int)RowState.Valid
select new ResponseFixtureTools
{
id = q.id,
name = q.name,
guid = q.guid,
cate_guid = p.guid,
categoryid = p.id,
category = p.name,
managetype = q.managetype,
partnumber = q.partnumber,
specification = q.specification,
number = q.number,
remark = q.remark,
code = q.code,
status = q.status,
updatetime = q.updatetime.HasValue && q.updatetime > DateTime.MinValue ? q.updatetime.Value.ToString(ParameterConstant.DateTimeFormat) : ""
};
var entities = query.OrderByDescending(q => q.id).AsNoTracking().ToList();
return entities;
}
}
}
......@@ -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)
......
......@@ -2,6 +2,7 @@
using Siger.Middlelayer.AccRepository.Response;
using Siger.Middlelayer.Repository.Data.Acc;
using Siger.Middlelayer.Repository.Paged;
using System.Collections.Generic;
namespace Siger.Middlelayer.AccRepository.Repositories.Interface
{
......@@ -9,5 +10,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
{
IPagedCollectionResult<ResponseFixtureTools> GetPagedList(int category, string code, string name, int state,
int projectid, int page, int pagesize);
IEnumerable<ResponseFixtureTools> 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