Commit 94559985 by yiyu.li
parents ad1f8c9d 115547fe
...@@ -536,6 +536,15 @@ export default { ...@@ -536,6 +536,15 @@ export default {
this.addstatus = '1';//状态 1可用 0停用 this.addstatus = '1';//状态 1可用 0停用
}, },
addPost() { addPost() {
if(!this.toolingId1){
this.$Message.error("请选择父工装");
return false;
}
if(!this.toolingId2){
this.$Message.error("请选择子工装");
return false;
}
let url = ""; let url = "";
let data = { let data = {
parentid: this.toolingId1, //父级工装ID parentid: this.toolingId1, //父级工装ID
......
...@@ -90,7 +90,7 @@ namespace Siger.ApiACC.Controllers ...@@ -90,7 +90,7 @@ namespace Siger.ApiACC.Controllers
} }
if (toexcel.ToInt() == 1) if (toexcel.ToInt() == 1)
{ {
return ExportExcel(data.Data); return ExportExcel(list);
} }
else else
{ {
......
...@@ -38,12 +38,23 @@ namespace Siger.ApiACC.Controllers ...@@ -38,12 +38,23 @@ namespace Siger.ApiACC.Controllers
_toolsAssemblyRepository = toolsAssemblyRepository; _toolsAssemblyRepository = toolsAssemblyRepository;
} }
/// <summary>
///TODO 子类查询可优化掉
/// </summary>
/// <param name="category"></param>
/// <param name="code"></param>
/// <param name="name"></param>
/// <param name="state"></param>
/// <param name="page"></param>
/// <param name="pagesize"></param>
/// <param name="toexcel"></param>
/// <returns></returns>
[HttpGet] [HttpGet]
public IActionResult GetPageList(string category, string code, string name, string state, int page, int pagesize, string toexcel = "") public IActionResult GetPageList(string category, string code, string name, string state, int page, int pagesize, string toexcel = "")
{ {
var data = _toolsAssemblyRepository.GetPagedList(category.ToInt(), code, name, state, ProjectId, page, pagesize, toexcel); var data = _toolsAssemblyRepository.GetPagedList(category.ToInt(), code, name, state, ProjectId, page, pagesize, toexcel);
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();
var list = new List<ResponseAumationFixtureToolsAssembly>(); var list = new List<ResponseAumationFixtureToolsAssemblys>();
foreach(var item in data.Data) foreach(var item in data.Data)
{ {
var cates = GetParentCategoryList(item.cate_guid, categorys); var cates = GetParentCategoryList(item.cate_guid, categorys);
...@@ -57,7 +68,7 @@ namespace Siger.ApiACC.Controllers ...@@ -57,7 +68,7 @@ namespace Siger.ApiACC.Controllers
item.parentcategoryids = parentcateIds; item.parentcategoryids = parentcateIds;
var models = new List<ResponseAumationFixtureToolsAssembly>(); var models = new List<ResponseAumationFixtureToolsAssembly>();
var details = _toolsAssemblyRepository.GetDetailList(item.fixtureguid, ProjectId); var details = _toolsAssemblyRepository.GetDetailList(item.fixtureguid, category.ToInt(), code, name, state, 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);
...@@ -81,7 +92,7 @@ namespace Siger.ApiACC.Controllers ...@@ -81,7 +92,7 @@ namespace Siger.ApiACC.Controllers
if(toexcel.ToInt() == 1) if(toexcel.ToInt() == 1)
{ {
return ExportExcel(data.Data); return ExportExcel(list);
} }
return new PagedObjectResult(list, data.Total, page, pagesize); return new PagedObjectResult(list, data.Total, page, pagesize);
} }
...@@ -172,7 +183,7 @@ namespace Siger.ApiACC.Controllers ...@@ -172,7 +183,7 @@ namespace Siger.ApiACC.Controllers
[HttpGet] [HttpGet]
public IActionResult GetDetail(string guid) public IActionResult GetDetail(string guid)
{ {
var data = _toolsAssemblyRepository.GetDetailList(guid, ProjectId); var data = _toolsAssemblyRepository.GetDetailList(guid, 0 , "", "", "", ProjectId);
return new ObjectResult(data); return new ObjectResult(data);
} }
......
...@@ -61,7 +61,7 @@ namespace Siger.ApiACC.Controllers ...@@ -61,7 +61,7 @@ namespace Siger.ApiACC.Controllers
} }
if (toexcel.ToInt() == 1) if (toexcel.ToInt() == 1)
{ {
return ExportExcel(data.Data); return ExportExcel(list);
} }
return new PagedObjectResult(list, data.Total, page, pagesize); return new PagedObjectResult(list, data.Total, page, pagesize);
} }
......
...@@ -57,7 +57,7 @@ namespace Siger.ApiACC.Controllers ...@@ -57,7 +57,7 @@ namespace Siger.ApiACC.Controllers
} }
if(toexcel.ToInt() == 1) if(toexcel.ToInt() == 1)
{ {
return ExportExcel(data.Data); return ExportExcel(list);
} }
return new PagedObjectResult(list, data.Total, page, pagesize); return new PagedObjectResult(list, data.Total, page, pagesize);
} }
......
...@@ -680,13 +680,12 @@ namespace Siger.ApiWMS.Controllers ...@@ -680,13 +680,12 @@ namespace Siger.ApiWMS.Controllers
//title //title
excelData.Add(GetExcelTitle()); excelData.Add(GetExcelTitle());
//data //data
int id = 1;
foreach (var item in data) foreach (var item in data)
{ {
var tmp = new List<string>(); var tmp = new List<string>();
tmp.Add(id++.ToString()); tmp.Add(item.storeID.ToString());
tmp.Add(item.storageName); tmp.Add(item.storageName);
tmp.AddRange(item.field.Select(q => q.name)); tmp.AddRange(item.field.Select(q => q.val));
tmp.Add(item.state == (int)RowState.Valid ? "否" : "是"); tmp.Add(item.state == (int)RowState.Valid ? "否" : "是");
tmp.Add(item.serialNumber); tmp.Add(item.serialNumber);
excelData.Add(tmp); excelData.Add(tmp);
......
...@@ -24,7 +24,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -24,7 +24,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
_context = context; _context = context;
} }
public IPagedCollectionResult<ResponseAumationFixtureToolsAssembly> GetPagedList(int category, string code, string name, string state, int projectid, int page, int pagesize, string toexcel = "") public IPagedCollectionResult<ResponseAumationFixtureToolsAssemblys> GetPagedList(int category, string code, string name, string state, int projectid, int page, int pagesize, string toexcel = "")
{ {
var query = from q in _context.siger_automation_fixture_tools_assembly var query = from q in _context.siger_automation_fixture_tools_assembly
join t1 in _context.siger_automation_fixture_tools on q.parent equals t1.guid into tt1 join t1 in _context.siger_automation_fixture_tools on q.parent equals t1.guid into tt1
...@@ -35,8 +35,14 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -35,8 +35,14 @@ namespace Siger.Middlelayer.AccRepository.Repositories
join c2 in _context.siger_automation_fixture_tools_category on t2.category equals c2.guid join c2 in _context.siger_automation_fixture_tools_category on t2.category equals c2.guid
join u in _context.siger_project_user on q.updator equals u.mid into uu join u in _context.siger_project_user on q.updator equals u.mid into uu
from u in uu.DefaultIfEmpty() from u in uu.DefaultIfEmpty()
join s in _context.siger_automation_fixture_tools_assembly on q.son equals s.parent into ss
from s in ss.DefaultIfEmpty()
join st2 in _context.siger_automation_fixture_tools on s.son equals st2.guid into stt2
from st2 in stt2.DefaultIfEmpty()
join sc2 in _context.siger_automation_fixture_tools_category on st2.category equals sc2.guid into scc2
from sc2 in scc2.DefaultIfEmpty()
where q.projectId == projectid && string.IsNullOrEmpty(q.parent) where q.projectId == projectid && string.IsNullOrEmpty(q.parent)
select new ResponseAumationFixtureToolsAssembly select new ResponseAumationFixtureToolsAssemblys
{ {
id = q.id, id = q.id,
parentid = t1 == null ? 0 : t1.id, parentid = t1 == null ? 0 : t1.id,
...@@ -62,43 +68,47 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -62,43 +68,47 @@ namespace Siger.Middlelayer.AccRepository.Repositories
parentcategory = c1.name ?? "", parentcategory = c1.name ?? "",
parentpartnumber = t1.partnumber ?? "", parentpartnumber = t1.partnumber ?? "",
parentspecfication = t1.specification ?? "", parentspecfication = t1.specification ?? "",
parentcode = t1.code ?? "" parentcode = t1.code ?? "",
son_code = st2.code ?? "",
son_name = st2.code ?? "",
son_categoryid = sc2 == null ? 0 : sc2.id,
son_status = s == null ? -1 : s.status,
}; };
Expression<Func<ResponseAumationFixtureToolsAssembly, bool>> categoryExpression = f => true; Expression<Func<ResponseAumationFixtureToolsAssemblys, bool>> categoryExpression = f => true;
if (category > 0) if (category > 0)
{ {
categoryExpression = q => q.categoryid == category; categoryExpression = q => (q.categoryid == category || q.son_categoryid == category);
} }
Expression<Func<ResponseAumationFixtureToolsAssembly, bool>> codeExpression = f => true; Expression<Func<ResponseAumationFixtureToolsAssemblys, bool>> codeExpression = f => true;
if (!string.IsNullOrEmpty(code)) if (!string.IsNullOrEmpty(code))
{ {
categoryExpression = q => q.code.Contains(code); codeExpression = q => (q.code.Contains(code) || q.son_code.Contains(code));
} }
Expression<Func<ResponseAumationFixtureToolsAssembly, bool>> nameExpression = f => true; Expression<Func<ResponseAumationFixtureToolsAssemblys, bool>> nameExpression = f => true;
if (!string.IsNullOrEmpty(name)) if (!string.IsNullOrEmpty(name))
{ {
nameExpression = q => q.name.Contains(name); nameExpression = q => (q.name.Contains(name) || q.son_name.Contains(name));
} }
Expression<Func<ResponseAumationFixtureToolsAssembly, bool>> stateExpression = f => true; Expression<Func<ResponseAumationFixtureToolsAssemblys, bool>> stateExpression = f => true;
if (!string.IsNullOrEmpty(state)) if (!string.IsNullOrEmpty(state))
{ {
stateExpression = q => q.status == state.ToInt(); stateExpression = q => (q.status == state.ToInt() || q.son_status == state.ToInt());
} }
var expression = categoryExpression.And(codeExpression).And(nameExpression).And(stateExpression); var expression = categoryExpression.And(codeExpression).And(nameExpression).And(stateExpression);
if (toexcel.ToInt() == 1) if (toexcel.ToInt() == 1)
{ {
var entities = query.Where(expression).OrderByDescending(q => q.id).AsNoTracking().ToList(); var entities = query.Where(expression).GroupBy(q => q.fixtureguid).Select(q => q.FirstOrDefault()).OrderByDescending(q => q.id).AsNoTracking().ToList();
return new PagedCollectionResult<ResponseAumationFixtureToolsAssembly>(entities, entities.Count); return new PagedCollectionResult<ResponseAumationFixtureToolsAssemblys>(entities, entities.Count);
} }
else else
{ {
var entities = query.Where(expression).OrderByDescending(q => q.id).Skip((page - 1) * pagesize).Take(pagesize).AsNoTracking().ToList(); var entities = query.Where(expression).GroupBy(q=>q.fixtureguid).Select(q=>q.FirstOrDefault()).OrderByDescending(q => q.id).Skip((page - 1) * pagesize).Take(pagesize).AsNoTracking().ToList();
var totalCount = query.Where(expression).Count(); var totalCount = query.Where(expression).GroupBy(q => q.fixtureguid).Select(q => q.FirstOrDefault()).Count();
return new PagedCollectionResult<ResponseAumationFixtureToolsAssembly>(entities, totalCount); return new PagedCollectionResult<ResponseAumationFixtureToolsAssemblys>(entities, totalCount);
} }
} }
public IEnumerable<ResponseAumationFixtureToolsAssembly> GetDetailList(string parent, int projectid) public IEnumerable<ResponseAumationFixtureToolsAssembly> GetDetailList(string parent, int category, string code, string name, string state, int projectid)
{ {
var query = from q in _context.siger_automation_fixture_tools_assembly var query = from q in _context.siger_automation_fixture_tools_assembly
join t1 in _context.siger_automation_fixture_tools on q.parent equals t1.guid into tt1 join t1 in _context.siger_automation_fixture_tools on q.parent equals t1.guid into tt1
...@@ -137,7 +147,28 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -137,7 +147,28 @@ namespace Siger.Middlelayer.AccRepository.Repositories
parentspecfication = t1.specification ?? "", parentspecfication = t1.specification ?? "",
parentcode = t1.code ?? "" parentcode = t1.code ?? ""
}; };
var entities = query.OrderByDescending(q => q.id).AsNoTracking().ToList(); Expression<Func<ResponseAumationFixtureToolsAssembly, bool>> categoryExpression = f => true;
if (category > 0)
{
categoryExpression = q => q.categoryid == category;
}
Expression<Func<ResponseAumationFixtureToolsAssembly, bool>> codeExpression = f => true;
if (!string.IsNullOrEmpty(code))
{
codeExpression = q => q.code.Contains(code);
}
Expression<Func<ResponseAumationFixtureToolsAssembly, bool>> nameExpression = f => true;
if (!string.IsNullOrEmpty(name))
{
nameExpression = q => q.name.Contains(name);
}
Expression<Func<ResponseAumationFixtureToolsAssembly, bool>> stateExpression = f => true;
if (!string.IsNullOrEmpty(state))
{
stateExpression = q => q.status == state.ToInt();
}
var expression = categoryExpression.And(codeExpression).And(nameExpression).And(stateExpression);
var entities = query.Where(expression).OrderByDescending(q => q.id).AsNoTracking().ToList();
return entities; return entities;
} }
......
...@@ -9,9 +9,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface ...@@ -9,9 +9,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
{ {
public interface IAutomationFixtureToolsAssemblyRepository : IAccRepositoryBase<siger_automation_fixture_tools_assembly> public interface IAutomationFixtureToolsAssemblyRepository : IAccRepositoryBase<siger_automation_fixture_tools_assembly>
{ {
IPagedCollectionResult<ResponseAumationFixtureToolsAssembly> GetPagedList(int category, string code, string name, string state, int projectid, int page, int pagesize, string toexcel = ""); IPagedCollectionResult<ResponseAumationFixtureToolsAssemblys> GetPagedList(int category, string code, string name, string state, int projectid, int page, int pagesize, string toexcel = "");
IEnumerable<ResponseAumationFixtureToolsAssembly> GetDetailList(string parent, int projectid); IEnumerable<ResponseAumationFixtureToolsAssembly> GetDetailList(string parent, int category, string code, string name, string state, int projectid);
CommonImportResult ImportData(IEnumerable<FixtureToolsAssmeblyTemplate> list, int projectid, int userid); CommonImportResult ImportData(IEnumerable<FixtureToolsAssmeblyTemplate> list, int projectid, int userid);
} }
......
...@@ -154,4 +154,12 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -154,4 +154,12 @@ namespace Siger.Middlelayer.AccRepository.Response
public string parentspecfication { get; set; } public string parentspecfication { get; set; }
public string parentcode { get; set; } public string parentcode { get; set; }
} }
public class ResponseAumationFixtureToolsAssemblys : ResponseAumationFixtureToolsAssembly
{
public string son_code { get; set; }
public string son_name { get; set; }
public int son_categoryid { get; set; }
public int son_status { get; set; }
}
} }
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