Commit 8efba8aa by xin.yang

some update

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