Commit 8efba8aa by xin.yang

some update

parent cbf895c3
...@@ -49,7 +49,7 @@ namespace Siger.ApiACC.Controllers ...@@ -49,7 +49,7 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
var fixturetool = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId && q.status == (int)RowState.Valid); var fixturetool = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId);
if (fixturetool == null) if (fixturetool == null)
{ {
throw new BadRequestException(RequestEnum.FixtureToolNotFound); throw new BadRequestException(RequestEnum.FixtureToolNotFound);
...@@ -76,6 +76,14 @@ namespace Siger.ApiACC.Controllers ...@@ -76,6 +76,14 @@ namespace Siger.ApiACC.Controllers
{ {
state = 2;//有工装 有工件 state = 2;//有工装 有工件
} }
else if (fixturetool == null && material == null)
{
state = 3;//无工装 无工件
}
else if (fixturetool == null && material != null)
{
state = 4;//无工装 有工件
}
var entity = new siger_automation_location var entity = new siger_automation_location
{ {
guid = Guid.NewGuid().ToString(), guid = Guid.NewGuid().ToString(),
...@@ -110,7 +118,7 @@ namespace Siger.ApiACC.Controllers ...@@ -110,7 +118,7 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
var entity = _autoLocationRepository.Get(q => q.id == req.id && q.projectId == ProjectId && q.status == (int)RowState.Valid); var entity = _autoLocationRepository.Get(q => q.id == req.id && q.projectId == ProjectId && q.status == (int)RowState.Valid);
var fixturetool = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId && q.status == (int)RowState.Valid); var fixturetool = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId);
if (fixturetool == null) if (fixturetool == null)
{ {
throw new BadRequestException(RequestEnum.FixtureToolNotFound); throw new BadRequestException(RequestEnum.FixtureToolNotFound);
...@@ -137,6 +145,14 @@ namespace Siger.ApiACC.Controllers ...@@ -137,6 +145,14 @@ namespace Siger.ApiACC.Controllers
{ {
state = 2;//有工装 有工件 state = 2;//有工装 有工件
} }
else if (fixturetool == null && material == null)
{
state = 3;//无工装 无工件
}
else if (fixturetool == null && material != null)
{
state = 4;//无工装 有工件
}
entity.locationid = req.locationid.ToInt(); entity.locationid = req.locationid.ToInt();
entity.fixturetools = fixturetool.guid; entity.fixturetools = fixturetool.guid;
entity.materialid = req.materialid.ToInt(); entity.materialid = req.materialid.ToInt();
......
...@@ -55,14 +55,14 @@ namespace Siger.ApiACC.Controllers ...@@ -55,14 +55,14 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId && q.status == (int)RowState.Valid); var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId);
var son = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId && q.status == (int)RowState.Valid); var son = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId);
if (son == null) if (son == null)
{ {
throw new BadRequestException(RequestEnum.FixtureToolNotFound); throw new BadRequestException(RequestEnum.FixtureToolNotFound);
} }
var parentGuid = parent?.guid ?? ""; var parentGuid = parent?.guid ?? "";
var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.son == son.guid && q.parent == parentGuid); var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == son.guid && q.parent == parentGuid);
if (exsit != null) if (exsit != null)
{ {
throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.DataExist);
...@@ -80,6 +80,7 @@ namespace Siger.ApiACC.Controllers ...@@ -80,6 +80,7 @@ namespace Siger.ApiACC.Controllers
projectId = ProjectId, projectId = ProjectId,
updatetime = DateTime.Now, updatetime = DateTime.Now,
updator = UserId, updator = UserId,
status = req.status.ToInt() == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
}; };
_toolsAssemblyRepository.Insert(entity); _toolsAssemblyRepository.Insert(entity);
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
...@@ -100,19 +101,19 @@ namespace Siger.ApiACC.Controllers ...@@ -100,19 +101,19 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
var entity = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.id == req.id); var entity = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.id == req.id);
if(entity == null) if(entity == null)
{ {
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
} }
var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId && q.status == (int)RowState.Valid); var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId);
var son = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId && q.status == (int)RowState.Valid); var son = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId);
if (son == null) if (son == null)
{ {
throw new BadRequestException(RequestEnum.FixtureToolNotFound); throw new BadRequestException(RequestEnum.FixtureToolNotFound);
} }
var parentGuid = parent?.guid ?? ""; var parentGuid = parent?.guid ?? "";
var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.son == son.guid && q.parent == parentGuid && var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == son.guid && q.parent == parentGuid &&
q.id != req.id); q.id != req.id);
if (exsit != null) if (exsit != null)
{ {
...@@ -125,6 +126,7 @@ namespace Siger.ApiACC.Controllers ...@@ -125,6 +126,7 @@ namespace Siger.ApiACC.Controllers
entity.filename = req.filename; entity.filename = req.filename;
entity.updatetime = DateTime.Now; entity.updatetime = DateTime.Now;
entity.updator = UserId; entity.updator = UserId;
entity.status = req.status.ToInt() == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid;
_toolsAssemblyRepository.Update(entity); _toolsAssemblyRepository.Update(entity);
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
...@@ -135,5 +137,11 @@ namespace Siger.ApiACC.Controllers ...@@ -135,5 +137,11 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(CommonEnum.Fail); throw new BadRequestException(CommonEnum.Fail);
} }
} }
[HttpGet]
public IActionResult Delete()
{
return Ok();
}
} }
} }
...@@ -45,8 +45,7 @@ namespace Siger.ApiACC.Controllers ...@@ -45,8 +45,7 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
var data = _toolsRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && (q.name == req.name || var data = _toolsRepository.Get(q => q.projectId == ProjectId && (q.name == req.name || q.code == req.code || q.partnumber == req.partnumber));
q.code == req.code || q.partnumber == req.partnumber));
if (data != null) if (data != null)
{ {
throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.DataExist);
...@@ -72,6 +71,7 @@ namespace Siger.ApiACC.Controllers ...@@ -72,6 +71,7 @@ namespace Siger.ApiACC.Controllers
filename = req.filename, filename = req.filename,
code = req.code, code = req.code,
projectId = ProjectId, projectId = ProjectId,
status = req.status.ToInt() == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
createtime = DateTime.Now, createtime = DateTime.Now,
updatetime = DateTime.Now, updatetime = DateTime.Now,
creator = UserId, creator = UserId,
...@@ -96,9 +96,8 @@ namespace Siger.ApiACC.Controllers ...@@ -96,9 +96,8 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
var entity = _toolsRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.id == req.id); var entity = _toolsRepository.Get(q => q.projectId == ProjectId && q.id == req.id);
var data = _toolsRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && (q.name == req.name || var data = _toolsRepository.Get(q => q.projectId == ProjectId && (q.name == req.name || q.code == req.code || q.partnumber == req.partnumber) && q.id != req.id);
q.code == req.code || q.partnumber == req.partnumber) && q.id != req.id);
if (data != null) if (data != null)
{ {
throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.DataExist);
...@@ -122,6 +121,7 @@ namespace Siger.ApiACC.Controllers ...@@ -122,6 +121,7 @@ namespace Siger.ApiACC.Controllers
entity.code = req.code; entity.code = req.code;
entity.updatetime = DateTime.Now; entity.updatetime = DateTime.Now;
entity.updator = UserId; entity.updator = UserId;
entity.status = req.status.ToInt() == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid;
_toolsRepository.Update(entity); _toolsRepository.Update(entity);
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
...@@ -136,14 +136,12 @@ namespace Siger.ApiACC.Controllers ...@@ -136,14 +136,12 @@ namespace Siger.ApiACC.Controllers
[HttpGet] [HttpGet]
public IActionResult Delete(int id) public IActionResult Delete(int id)
{ {
var entity = _toolsRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.id == id); var entity = _toolsRepository.Get(q => q.projectId == ProjectId && q.id == id);
if (entity == null) if (entity == null)
{ {
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
} }
_toolsRepository.Delete(entity);
entity.status = (int)RowState.Invalid;
_toolsRepository.Update(entity);
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
...@@ -161,16 +159,14 @@ namespace Siger.ApiACC.Controllers ...@@ -161,16 +159,14 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
var entities = _toolsRepository.GetList(t => var entities = _toolsRepository.GetList(t => req.ids.Contains(t.id) && t.projectId == ProjectId).ToList();
req.ids.Contains(t.id) && t.projectId == ProjectId && t.status == (int)RowState.Valid).ToList();
if (!entities.Any()) if (!entities.Any())
{ {
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
} }
foreach (var entity in entities) foreach (var entity in entities)
{ {
entity.status = (int)RowState.Invalid; _toolsRepository.Delete(entity);
_toolsRepository.Update(entity);
} }
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
......
...@@ -49,7 +49,7 @@ namespace Siger.ApiACC.Controllers ...@@ -49,7 +49,7 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
var fixtureTool = _toolsRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.id == req.fixturetoolid.ToInt()); var fixtureTool = _toolsRepository.Get(q => q.projectId == ProjectId && q.id == req.fixturetoolid.ToInt());
if(fixtureTool == null) if(fixtureTool == null)
{ {
throw new BadRequestException(RequestEnum.FixtureToolNotFound); throw new BadRequestException(RequestEnum.FixtureToolNotFound);
...@@ -101,7 +101,7 @@ namespace Siger.ApiACC.Controllers ...@@ -101,7 +101,7 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
} }
var fixtureTool = _toolsRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.id == req.fixturetoolid.ToInt()); var fixtureTool = _toolsRepository.Get(q => q.projectId == ProjectId && q.id == req.fixturetoolid.ToInt());
if (fixtureTool == null) if (fixtureTool == null)
{ {
throw new BadRequestException(RequestEnum.FixtureToolNotFound); throw new BadRequestException(RequestEnum.FixtureToolNotFound);
......
...@@ -31,7 +31,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -31,7 +31,7 @@ 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()
where q.projectId == projectid && q.status == (int)RowState.Valid && string.IsNullOrEmpty(q.parent) where q.projectId == projectid && string.IsNullOrEmpty(q.parent)
select new ResponseAumationFixtureToolsAssembly select new ResponseAumationFixtureToolsAssembly
{ {
id = q.id, id = q.id,
...@@ -81,7 +81,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -81,7 +81,7 @@ 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()
where q.projectId == projectid && q.status == (int)RowState.Valid && q.id == id where q.projectId == projectid && q.id == id
select new ResponseAumationFixtureToolsAssembly select new ResponseAumationFixtureToolsAssembly
{ {
id = q.id, id = q.id,
......
...@@ -27,7 +27,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -27,7 +27,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
join p in _context.siger_automation_fixture_tools_category on q.category equals p.guid join p in _context.siger_automation_fixture_tools_category on q.category equals p.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()
where q.projectId == projectid && q.status == (int)RowState.Valid where q.projectId == projectid
select new ResponseFixtureTools select new ResponseFixtureTools
{ {
id = q.id, id = q.id,
......
...@@ -63,6 +63,8 @@ namespace Siger.Middlelayer.AccRepository.Request ...@@ -63,6 +63,8 @@ namespace Siger.Middlelayer.AccRepository.Request
/// 工装编号 /// 工装编号
/// </summary> /// </summary>
public string code { get; set; } public string code { get; set; }
public string status { get; set; }
} }
public class RequestUpdateFixtureTools : RequestAddFixtureTools public class RequestUpdateFixtureTools : RequestAddFixtureTools
...@@ -134,6 +136,8 @@ namespace Siger.Middlelayer.AccRepository.Request ...@@ -134,6 +136,8 @@ namespace Siger.Middlelayer.AccRepository.Request
public string fixturetoolid { get; set; } public string fixturetoolid { get; set; }
public string fileurl { get; set; } public string fileurl { get; set; }
public string filename { get; set; } public string filename { get; set; }
public string status { get; set; }
} }
public class RequestUpdateFixtureToolAssembly : RequestAddFixtureToolAssembly public class RequestUpdateFixtureToolAssembly : RequestAddFixtureToolAssembly
......
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