Commit bc381f49 by yiyu.li
parents ca08ddf1 0b92b558
......@@ -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,18 @@ 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);
}
if (parent == null)
{
}
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 +84,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)
......@@ -92,7 +97,6 @@ namespace Siger.ApiACC.Controllers
}
}
[HttpPost]
public IActionResult Update([FromBody]RequestUpdateFixtureToolAssembly req)
{
......@@ -100,19 +104,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 +129,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 +140,46 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(CommonEnum.Fail);
}
}
[HttpGet]
public IActionResult Delete(int id)
{
var entity = _toolsRepository.Get(q => q.projectId == ProjectId && q.id == id);
if (entity == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
_toolsAssemblyRepository.Delete(entity);
if (_unitOfWork.Commit() > 0)
{
return new ObjectResult(CommonEnum.Succefull);
}
else
{
throw new BadRequestException(CommonEnum.Fail);
}
}
[HttpPost]
public IActionResult Deletes([FromBody]RequestDeleteRange req)
{
if (req.ids == null || !req.ids.Any())
{
throw new BadRequestException(RequestEnum.ParameterMiss);
}
var entities = _toolsAssemblyRepository.GetList(t => req.ids.Contains(t.id) && t.projectId == ProjectId).ToList();
if (!entities.Any())
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
foreach (var entity in entities)
{
_toolsAssemblyRepository.Delete(entity);
}
if (_unitOfWork.Commit() > 0)
return new ObjectResult(CommonEnum.Succefull);
throw new BadRequestException(CommonEnum.Fail);
}
}
}
......@@ -34,7 +34,24 @@ namespace Siger.ApiACC.Controllers
public IActionResult GetPageList(string category, string code, string name, string state, int page, int pagesize)
{
var data = _toolsRepository.GetPagedList(category.ToInt(), code, name, string.IsNullOrEmpty(state) ? -1 : state.ToInt(), ProjectId, page, pagesize);
return new PagedObjectResult(data.Data, data.Total, page, pagesize);
var list = new List<ResponseFixtureTools>();
var categorys = _toolsCategoryRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).ToList();
foreach(var item in data.Data)
{
var cates = GetParentCategoryList(item.cate_guid, categorys);
var cateIds = cates.Select(q => q.id).ToList();
cateIds.Reverse();
item.categoryids = cateIds;
list.Add(item);
}
return new PagedObjectResult(list, data.Total, page, pagesize);
}
private IEnumerable<siger_automation_fixture_tools_category> GetParentCategoryList(string parentId, List<siger_automation_fixture_tools_category> sections)
{
var query = from c in sections where c.guid == parentId select c;
return query.ToList().Concat(query.ToList().SelectMany(t => GetParentCategoryList(t.parent, sections)));
}
[HttpPost]
......@@ -45,8 +62,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 +88,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 +113,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 +138,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 +153,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 +176,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,12 +27,13 @@ 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,
name = q.name,
guid = q.guid,
cate_guid = p.guid,
categoryid = p.id,
category = p.name,
managetype = q.managetype,
......
......@@ -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
......
......@@ -30,6 +30,7 @@ namespace Siger.Middlelayer.AccRepository.Response
{
public int id { get; set; }
public string guid { get; set; }
public string cate_guid { get; set; }
/// <summary>
/// 工装类别ID
/// </summary>
......@@ -77,6 +78,8 @@ namespace Siger.Middlelayer.AccRepository.Response
public int status { get; set; }
public string updatetime { get; set; }
public List<int> categoryids { get; set; } = new List<int>();
}
......
......@@ -207,6 +207,7 @@ CREATE TABLE IF NOT EXISTS `siger_automation_fixture_tools` (
`attachment` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '附件',
`filename` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '附件名称',
`code` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工装编号',
`projectid` int(11) NOT NULL DEFAULT 0,
`status` int(11) NOT NULL DEFAULT 1 COMMENT '状态',
`createtime` datetime(0) NOT NULL,
`creator` int(11) NOT NULL DEFAULT 0,
......@@ -273,6 +274,8 @@ CREATE TABLE IF NOT EXISTS `siger_automation_location` (
`remark` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
`updator` int(11) NOT NULL DEFAULT 0,
`updatetime` datetime(0) NULL DEFAULT NULL,
`projectid` int(11) NOT NULL DEFAULT 0,
`status` int(11) NOT NULL DEFAULT 1,
`extend1` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
......
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