Commit 6c2dc0df by xin.yang

some update

parent 75a573f5
......@@ -36,9 +36,9 @@ namespace Siger.ApiACC.Controllers
_materialsRepository = materialsRepository;
}
public IActionResult GetPageList(string category, string code, string name, string state, int page, int pagesize)
public IActionResult GetPageList(string wavehouseid, string locationid, int page, int pagesize)
{
var data = _toolsRepository.GetPagedList(category.ToInt(), code, name, string.IsNullOrEmpty(state) ? -1 : state.ToInt(), ProjectId, page, pagesize);
var data = _autoLocationRepository.GetPagedList(wavehouseid.ToInt(), locationid.ToInt(), ProjectId, page, pagesize);
return new PagedObjectResult(data.Data, data.Total, page, pagesize);
}
......@@ -84,7 +84,8 @@ namespace Siger.ApiACC.Controllers
materialid = req.materialid.ToInt(),
processid = req.processid.ToInt(),
materialstate = state,
attachment = req.attachment,
attachment = req.fileurl,
filename = req.filename,
remark = req.remark,
projectId = ProjectId,
updatetime = DateTime.Now,
......@@ -141,7 +142,8 @@ namespace Siger.ApiACC.Controllers
entity.materialid = req.materialid.ToInt();
entity.processid = req.processid.ToInt();
entity.materialstate = state;
entity.attachment = req.attachment;
entity.attachment = req.fileurl;
entity.filename = req.filename;
entity.remark = req.remark;
entity.updatetime = DateTime.Now;
entity.updator = UserId;
......
......@@ -33,10 +33,107 @@ namespace Siger.ApiACC.Controllers
_toolsAssemblyRepository = toolsAssemblyRepository;
}
public IActionResult GetPageList(string category, int page, int pagesize)
[HttpGet]
public IActionResult GetPageList(string category, string code, string name, int projectid, int page, int pagesize)
{
var data = _toolsAssemblyRepository.GetPagedList(category.ToInt(), ProjectId, page, pagesize);
var data = _toolsAssemblyRepository.GetPagedList(category.ToInt(), code, name, ProjectId, page, pagesize);
return new PagedObjectResult(data.Data, data.Total, page, pagesize);
}
[HttpGet]
public IActionResult GetDetail(string id)
{
var data = _toolsAssemblyRepository.GetDetailList(id.ToInt(), ProjectId);
return new ObjectResult(data);
}
[HttpPost]
public IActionResult Add([FromBody]RequestAddFixtureToolAssembly req)
{
if (string.IsNullOrEmpty(req.fixturetoolid))
{
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);
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);
if (exsit != null)
{
throw new BadRequestException(RequestEnum.DataExist);
}
var entity = new siger_automation_fixture_tools_assembly
{
guid = Guid.NewGuid().ToString(),
parent = parent?.guid ?? "",
son = son.guid,
creator = UserId,
createtime = DateTime.Now,
attachment = req.fileurl,
filename = req.filename,
projectId = ProjectId,
updatetime = DateTime.Now,
updator = UserId,
};
_toolsAssemblyRepository.Insert(entity);
if (_unitOfWork.Commit() > 0)
{
return new ObjectResult(CommonEnum.Succefull);
}
else
{
throw new BadRequestException(CommonEnum.Fail);
}
}
[HttpPost]
public IActionResult Update([FromBody]RequestUpdateFixtureToolAssembly req)
{
if (string.IsNullOrEmpty(req.fixturetoolid))
{
throw new BadRequestException(RequestEnum.ParameterMiss);
}
var entity = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && 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);
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 &&
q.id != req.id);
if (exsit != null)
{
throw new BadRequestException(RequestEnum.DataExist);
}
entity.parent = parent?.guid ?? "";
entity.son = son.guid;
entity.attachment = req.fileurl;
entity.filename = req.filename;
entity.updatetime = DateTime.Now;
entity.updator = UserId;
_toolsAssemblyRepository.Update(entity);
if (_unitOfWork.Commit() > 0)
{
return new ObjectResult(CommonEnum.Succefull);
}
else
{
throw new BadRequestException(CommonEnum.Fail);
}
}
}
}
......@@ -68,7 +68,8 @@ namespace Siger.ApiACC.Controllers
specification = req.specifition,
number = req.number.ToInt(),
remark = req.remark,
attachment = req.attachment,
attachment = req.fileurl,
filename = req.filename,
code = req.code,
projectId = ProjectId,
createtime = DateTime.Now,
......@@ -116,7 +117,8 @@ namespace Siger.ApiACC.Controllers
entity.specification = req.specifition;
entity.number = req.number.ToInt();
entity.remark = req.remark;
entity.attachment = req.attachment;
entity.attachment = req.fileurl;
entity.filename = req.filename;
entity.code = req.code;
entity.updatetime = DateTime.Now;
entity.updator = UserId;
......@@ -176,6 +178,23 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(CommonEnum.Fail);
}
[HttpGet]
public IActionResult GetFxitureTooolList()
{
var list = _toolsRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).Select(
q => new
{
q.id,
q.code,
q.partnumber,
q.name,
q.specification,
q.number
}).ToList();
return new ObjectResult(list);
}
[HttpGet]
......
......@@ -42,6 +42,7 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 附件
/// </summary>
public string attachment { get; set; }
public string filename { get; set; }
/// <summary>
/// 工装编号
/// </summary>
......
......@@ -18,6 +18,15 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 工装GUID
/// </summary>
public string son { get; set; }
/// <summary>
/// 附件
/// </summary>
public string attachment { get; set; }
public string fileurl { get; set; }
/// <summary>
/// 附件名称
/// </summary>
public string filename { get; set; }
public int creator { get; set; }
public DateTime createtime { get; set; }
public int updator { get; set; }
......
......@@ -34,6 +34,7 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 附件
/// </summary>
public string attachment { get; set; }
public string filename { get; set; }
/// <summary>
/// 备注
/// </summary>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
......@@ -20,7 +21,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
_context = context;
}
public IPagedCollectionResult<ResponseAumationFixtureToolsAssembly> GetPagedList(int categor, int projectid, int page, int pagesize)
public IPagedCollectionResult<ResponseAumationFixtureToolsAssembly> GetPagedList(int category, string code, string name, int projectid, int page, int pagesize)
{
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
......@@ -36,15 +37,71 @@ namespace Siger.Middlelayer.AccRepository.Repositories
id = q.id,
parentid = t1 == null ? 0 : t1.id,
parentname = t1.name ?? "",
sonid = t2.id,
sonname = t2.name ??"",
fixturetoolid = t2.id,
name = t2.name,
code = t2.code,
partnumber = t2.partnumber,
specfication = t2.specification,
updator = u.name ?? "",
status = q.status,
fileurl = q.attachment,
filename = q.filename,
categoryid = c2.id,
category = c2.name,
updatetime = q.updatetime.HasValue && q.updatetime > DateTime.MinValue ? q.updatetime.Value.ToString(ParameterConstant.DateTimeFormat) : ""
};
var entities = query.OrderByDescending(q => q.id).Skip((page - 1) * pagesize).Take(pagesize).AsNoTracking().ToList();
var totalCount = query.Count();
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))
{
categoryExpression = q => q.code.Contains(code);
}
Expression<Func<ResponseAumationFixtureToolsAssembly, bool>> nameExpression = f => true;
if (!string.IsNullOrEmpty(name))
{
nameExpression = q => q.name.Contains(name);
}
var expression = categoryExpression.And(codeExpression).And(nameExpression);
var entities = query.Where(expression).OrderByDescending(q => q.id).Skip((page - 1) * pagesize).Take(pagesize).AsNoTracking().ToList();
var totalCount = query.Where(expression).Count();
return new PagedCollectionResult<ResponseAumationFixtureToolsAssembly>(entities, totalCount);
}
public IEnumerable<ResponseAumationFixtureToolsAssembly> GetDetailList(int id, int projectid)
{
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
from t1 in tt1.DefaultIfEmpty()
join c1 in _context.siger_automation_fixture_tools_category on t1.category equals c1.guid
join t2 in _context.siger_automation_fixture_tools on q.son equals t2.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
from u in uu.DefaultIfEmpty()
where q.projectId == projectid && q.status == (int)RowState.Valid && q.id == id
select new ResponseAumationFixtureToolsAssembly
{
id = q.id,
parentid = t1 == null ? 0 : t1.id,
parentname = t1.name ?? "",
fixturetoolid = t2.id,
name = t2.name,
code = t2.code,
partnumber = t2.partnumber,
specfication = t2.specification,
updator = u.name ?? "",
status = q.status,
fileurl = q.attachment,
filename = q.filename,
categoryid = c2.id,
category = c2.name,
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;
}
}
}
......@@ -40,7 +40,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
specification = q.specification,
number = q.number,
remark = q.remark,
attachment = q.attachment,
fileurl = q.attachment ?? "",
filename = q.filename ?? "",
code = q.code,
updator = u.name ?? "",
status = q.status,
......
......@@ -36,23 +36,24 @@ namespace Siger.Middlelayer.AccRepository.Repositories
select new ResponseAutomationLocation
{
id = q.id,
locationid=l.id,
location=l.name,
wavehouseid=w.id,
wavehouse=w.name,
fixturetoolid=t.id,
fixturetool=t.name,
category=c.name,
code=t.code,
specfication=t.specification,
materialid=q.materialid,
materialcode=m.pn,
locationid = l.id,
location = l.name,
wavehouseid = w.id,
wavehouse = w.name,
fixturetoolid = t.id,
fixturetool = t.name,
category = c.name,
code = t.code,
specfication = t.specification,
materialid = q.materialid,
materialcode = m.pn,
processid = q.processid,
processnumber = p == null ? 0 : p.Process_Seq,
processname = p.Process_name??"",
processname = p.Process_name ?? "",
materialstate = q.materialstate,
attachment=q.attachment,
remark=q.remark,
fileurl = q.attachment ?? "",
filename = q.filename ?? "",
remark = q.remark,
updator = u.name ?? "",
status = q.status,
updatetime = q.updatetime.HasValue && q.updatetime > DateTime.MinValue ? q.updatetime.Value.ToString(ParameterConstant.DateTimeFormat) : ""
......
......@@ -2,11 +2,14 @@
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
{
public interface IAutomationFixtureToolsAssemblyRepository : IAccRepositoryBase<siger_automation_fixture_tools_assembly>
{
IPagedCollectionResult<ResponseAumationFixtureToolsAssembly> GetPagedList(int categor, int projectid, int page, int pagesize);
IPagedCollectionResult<ResponseAumationFixtureToolsAssembly> GetPagedList(int category, string code, string name, int projectid, int page, int pagesize);
IEnumerable<ResponseAumationFixtureToolsAssembly> GetDetailList(int id, int projectid);
}
}
......@@ -57,7 +57,8 @@ namespace Siger.Middlelayer.AccRepository.Request
/// <summary>
/// 附件
/// </summary>
public string attachment { get; set; }
public string fileurl { get; set; }
public string filename { get; set; }
/// <summary>
/// 工装编号
/// </summary>
......@@ -114,7 +115,8 @@ namespace Siger.Middlelayer.AccRepository.Request
/// <summary>
/// 附件
/// </summary>
public string attachment { get; set; }
public string fileurl { get; set; }
public string filename { get; set; }
/// <summary>
/// 备注
/// </summary>
......@@ -125,4 +127,17 @@ namespace Siger.Middlelayer.AccRepository.Request
{
public int id { get; set; }
}
public class RequestAddFixtureToolAssembly
{
public string parentid { get; set; }
public string fixturetoolid { get; set; }
public string fileurl { get; set; }
public string filename { get; set; }
}
public class RequestUpdateFixtureToolAssembly : RequestAddFixtureToolAssembly
{
public int id { get; set; }
}
}
......@@ -65,7 +65,8 @@ namespace Siger.Middlelayer.AccRepository.Response
/// <summary>
/// 附件
/// </summary>
public string attachment { get; set; }
public string fileurl { get; set; }
public string filename { get; set; }
/// <summary>
/// 工装编号
/// </summary>
......@@ -109,8 +110,9 @@ namespace Siger.Middlelayer.AccRepository.Response
public int id { get; set; }
public int parentid { get; set; }
public string parentname { get; set; }
public int sonid { get; set; }
public string sonname { get; set; }
public int categoryid { get; set; }
public string category { get; set; }
public int fixturetoolid { get; set; }
public string partnumber { get; set; }
public string name { get; set; }
public string specfication { get; set; }
......@@ -118,5 +120,7 @@ namespace Siger.Middlelayer.AccRepository.Response
public string updator { get; set; }
public string updatetime { get; set; }
public int status { get; set; }
public string fileurl { get; set; }
public string filename { get; set; }
}
}
......@@ -40,7 +40,8 @@ namespace Siger.Middlelayer.AccRepository.Response
/// <summary>
/// 附件
/// </summary>
public string attachment { get; set; }
public string fileurl { get; set; }
public string filename { get; set; }
/// <summary>
/// 备注
/// </summary>
......
......@@ -204,7 +204,8 @@ CREATE TABLE IF NOT EXISTS `siger_automation_fixture_tools` (
`specification` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '规格型号',
`number` int(11) NOT NULL DEFAULT 0 COMMENT '数量',
`remark` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
`attachment` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '附件',
`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 '工装编号',
`status` int(11) NOT NULL DEFAULT 1 COMMENT '状态',
`createtime` datetime(0) NOT NULL,
......@@ -224,6 +225,8 @@ CREATE TABLE IF NOT EXISTS `siger_automation_fixture_tools_assembly` (
`guid` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`parent` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '父类工装GUID',
`son` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工装GUID',
`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 '附件名称',
`projectid` int(11) NOT NULL DEFAULT 0,
`status` int(11) NOT NULL DEFAULT 1,
`creator` int(11) NOT NULL DEFAULT 0,
......@@ -266,6 +269,7 @@ CREATE TABLE IF NOT EXISTS `siger_automation_location` (
`processid` int(11) NOT NULL DEFAULT 0 COMMENT '工序ID',
`materialstate` int(11) NOT NULL DEFAULT 0 COMMENT '物料状态',
`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 '附件名称',
`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,
......
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