Commit 687af983 by yiyu.li
parents 6ba8c908 99b73ad8
......@@ -709,6 +709,17 @@ export default {
'9000484': '数据库创建失败',
'9000485': '数据表创建失败',
'9000486': '标签来源未维护',
'9000487': '只能读取txt文件',
'9000488': '程序版本号不能为空',
'9000489': '存在相同程序号的程序已审核,是否覆盖原来程序记录?',
'9000490': '记录已存在,请删除后添加',
'9000491': '人员未找到',
'9000492': '默认展示已存在',
'9000493': '未找到储位类别',
'9000494': '未找到工装类别',
'9000495': '未找到工装信息',
'9000496': 'ID重复',
'9000497': '父级和子级不能相同',
'9100000': 'Departments cannot be empty',
'9100001': 'Position cannot be empty',
......
......@@ -742,6 +742,11 @@ export default {
'9000490': '记录已存在,请删除后添加',
'9000491': '人员未找到',
'9000492': '默认展示已存在',
'9000493': '未找到储位类别',
'9000494': '未找到工装类别',
'9000495': '未找到工装信息',
'9000496': 'ID重复',
'9000497': '父级和子级不能相同',
'9100000': '部门不能为空',
......
......@@ -38,6 +38,7 @@ namespace Siger.ApiACC.Controllers
_routeRepository = routeRepository;
}
[HttpGet]
public IActionResult GetPageList(string wavehouseid, string locationid, int page, int pagesize)
{
var data = _autoLocationRepository.GetPagedList(wavehouseid.ToInt(), locationid.ToInt(), ProjectId, page, pagesize);
......@@ -61,18 +62,6 @@ namespace Siger.ApiACC.Controllers
{
item.materialstate = 4;//无工装有工件
}
var monitor = _fixtureMonitor.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.locationId == item.locationid).
OrderByDescending(q => q.updatetime).FirstOrDefault();
if(monitor != null)
{
item.sn = monitor.sn;
var route = _routeRepository.Get(q => q.id == monitor.route && q.projectId == ProjectId && q.status == (int)RowState.Valid);
if(route != null)
{
item.route = route.name;
item.routenumber = route.serialNumber.ToString();
}
}
var loca = locations.FirstOrDefault(q => q.locationid == item.locaid);
if(loca != null)
......
......@@ -141,6 +141,8 @@ namespace Siger.ApiACC.Controllers
var result = new ResponsePlanlFixtureInfo
{
OrderNumber = monitor.ordernumber,
FixtureGuid=monitor.fixtureguid,
FixtureName=monitor.fixturename,
ProductCode=monitor.productCode,
ProductName=monitor.productName,
Sn=monitor.sn,
......@@ -251,6 +253,7 @@ namespace Siger.ApiACC.Controllers
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
{
fixtureguid=fixtureToolsObj.FixtureGuid,
fixturename=fixtureToolsObj.FixtureName,
projectId=ProjectId,
section=loading.section,
sn=sn,
......
......@@ -78,22 +78,31 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(RequestEnum.ParameterMiss);
}
if(!string.IsNullOrEmpty(req.parentid) && !string.IsNullOrEmpty(req.fixturetoolid) &&
req.parentid == req.fixturetoolid)
{
throw new BadRequestException(RequestEnum.ParentSonSame);
}
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.son == son.guid && q.parent == parentGuid);
if (exsit != null)
{
throw new BadRequestException(RequestEnum.DataExist);
}
if (!string.IsNullOrEmpty(parentGuid))
{
var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid);
if(parentExsit != null)
{
throw new BadRequestException(RequestEnum.LevelCountError);
}
}
var entity = new siger_automation_fixture_tools_assembly
{
......@@ -127,6 +136,11 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(RequestEnum.ParameterMiss);
}
if (!string.IsNullOrEmpty(req.parentid) && !string.IsNullOrEmpty(req.fixturetoolid) &&
req.parentid == req.fixturetoolid)
{
throw new BadRequestException(RequestEnum.ParentSonSame);
}
var entity = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.id == req.id);
if(entity == null)
{
......@@ -145,6 +159,14 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(RequestEnum.DataExist);
}
if (!string.IsNullOrEmpty(parentGuid))
{
var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid);
if (parentExsit != null)
{
throw new BadRequestException(RequestEnum.LevelCountError);
}
}
entity.parent = parent?.guid ?? "";
entity.son = son.guid;
......
......@@ -14,6 +14,11 @@ using Siger.Middlelayer.Repository;
using Siger.Middlelayer.Repository.Extensions;
using System.Linq;
using Siger.Middlelayer.Repository.Entities;
using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Utility.Helpers;
using Siger.Middlelayer.Utility.ImportEntities;
using System.IO;
using Siger.Middlelayer.Log;
namespace Siger.ApiACC.Controllers
{
......@@ -31,9 +36,9 @@ namespace Siger.ApiACC.Controllers
_toolsRepository = toolsRepository;
}
public IActionResult GetPageList(string category, string code, string name, string state, int page, int pagesize)
public IActionResult GetPageList(string category, string code, string name, string state, int page, int pagesize, string toexcel)
{
var data = _toolsRepository.GetPagedList(category.ToInt(), code, name, string.IsNullOrEmpty(state) ? -1 : state.ToInt(), ProjectId, page, pagesize);
var data = _toolsRepository.GetPagedList(category.ToInt(), code, name, string.IsNullOrEmpty(state) ? -1 : state.ToInt(), ProjectId, page, pagesize, toexcel);
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)
......@@ -44,9 +49,62 @@ namespace Siger.ApiACC.Controllers
item.categoryids = cateIds;
list.Add(item);
}
if (toexcel.ToInt() == 1)
{
return ExportExcel(data.Data);
}
return new PagedObjectResult(list, data.Total, page, pagesize);
}
private IActionResult ExportExcel(IEnumerable<ResponseFixtureTools> data)
{
var rootDir = FileSystemHelper.GetPhysicalFolders(FileSystemHelper.CommonFileSetting.PhysicalFolder, FileSystemHelper.ExportFileName);
if (!data.Any())
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var dataList = new List<FixtureToolsTemplate>();
foreach (var item in data)
{
dataList.Add(new FixtureToolsTemplate
{
Catgeory = item.category,
Name = item.name,
Manage = item.managetype == 1 ? "单件" : "批次",
PartNumber = item.partnumber,
Code = item.code,
Specfication = item.specification,
Number = item.number.ToString(),
Status = item.status == 1 ? "可用" : "停用",
Remark = item.remark
});
}
if (dataList.Any())
{
EpPlusExcelHelper<FixtureToolsTemplate> helper = null;
try
{
helper = new EpPlusExcelHelper<FixtureToolsTemplate>();
var temporaryFileName = $"工装台账_FixtureToolsData_{DateTime.Now:yyyyMMddHHmmss}.xlsx";
helper.GenerateExcel(dataList, Path.Combine(rootDir, temporaryFileName));
return new ObjectResult($"{FileSystemHelper.CommonFileSetting.RequestPath}/{FileSystemHelper.ExportFileName}/{temporaryFileName}");
}
catch (Exception e)
{
Logger.WriteLineError("Export Fixture Tools Data failed, error:" + e);
throw new BadRequestException(RequestEnum.ExportFailed);
}
finally
{
helper?.Dispose();
}
}
throw new BadRequestException(CommonEnum.Fail);
}
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;
......@@ -194,12 +252,58 @@ namespace Siger.ApiACC.Controllers
[HttpGet]
public IActionResult GetCategoryPageList(string id, int page, int pagesize)
public IActionResult GetCategoryPageList(string id, int page, int pagesize, string toexcel = "")
{
var data = _toolsCategoryRepository.GetPagedList(id.ToInt(), ProjectId, page, pagesize);
var data = _toolsCategoryRepository.GetPagedList(id.ToInt(), ProjectId, page, pagesize, toexcel);
if(toexcel.ToInt() == 1)
{
return ExportCategoryExcel(data.Data);
}
return new PagedObjectResult(data.Data, data.Total, page, pagesize);
}
private IActionResult ExportCategoryExcel(IEnumerable<ResponseFixtureToolsCategory> data)
{
var rootDir = FileSystemHelper.GetPhysicalFolders(FileSystemHelper.CommonFileSetting.PhysicalFolder, FileSystemHelper.ExportFileName);
if (!data.Any())
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var dataList = new List<FixtureToolsCategoryTemplate>();
foreach (var item in data)
{
dataList.Add(new FixtureToolsCategoryTemplate
{
Fixture = item.name,
Parent = item.parentname
});
}
if (dataList.Any())
{
EpPlusExcelHelper<FixtureToolsCategoryTemplate> helper = null;
try
{
helper = new EpPlusExcelHelper<FixtureToolsCategoryTemplate>();
var temporaryFileName = $"工装类型_FixtureToolsCategoryData_{DateTime.Now:yyyyMMddHHmmss}.xlsx";
helper.GenerateExcel(dataList, Path.Combine(rootDir, temporaryFileName));
return new ObjectResult($"{FileSystemHelper.CommonFileSetting.RequestPath}/{FileSystemHelper.ExportFileName}/{temporaryFileName}");
}
catch (Exception e)
{
Logger.WriteLineError("Export Fixture Tools Category Data failed, error:" + e);
throw new BadRequestException(RequestEnum.ExportFailed);
}
finally
{
helper?.Dispose();
}
}
throw new BadRequestException(CommonEnum.Fail);
}
[HttpPost]
public IActionResult AddCategory([FromBody]RequestAddFixtureToolsCategory req)
{
......@@ -356,9 +460,9 @@ namespace Siger.ApiACC.Controllers
[HttpGet]
public IActionResult GetFixtureToolList()
public IActionResult GetFixtureToolList(string categoryid)
{
var list = _toolsRepository.GetDataList(ProjectId);
var list = _toolsRepository.GetDataList(categoryid.ToInt(), ProjectId);
return new ObjectResult(list);
}
}
......
using FluentScheduler;
using NPOI.SS.Formula.Functions;
using Siger.Middlelayer.Log;
using Module = Siger.Middlelayer.Common.Module;
......@@ -11,7 +12,8 @@ namespace Siger.ApiACC.Tasks
//Logger.RegisterLogEngine(Module.Acc);
//Schedule<AccCalculateTraceJob>().ToRunNow().AndEvery(30).Minutes();
Logger.RegisterTxtLogEngine(Module.Acc);
Schedule<AutoMES>().ToRunNow().AndEvery(10).Seconds();
}
}
}
using FluentScheduler;
using Newtonsoft.Json;
using Siger.Middlelayer.AccRepository.Request;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.Configuration;
using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Common.Log;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -12,19 +18,103 @@ namespace Siger.ApiACC.Tasks
public void Execute()
{
throw new NotImplementedException();
Logger.WriteLineInfo($"execute mes job");
var projectId = GetProjectId();
var hostDic = GetHost();
if (projectId==0 || !hostDic.Any())
{
Logger.WriteLineInfo($"配置未完整");
return;
}
using (DBhelper dbhelper = new DBhelper())
{
var tasklist = dbhelper.GetTaskList(projectId);
if (!tasklist.Any())
{
Logger.WriteLineInfo($"无任务下发");
return;
}
var tasks = tasklist.OrderBy(s => s.actiontype);
var task = tasks.FirstOrDefault();
var sendToPLC = new RequestPLC
{
RStation = task.sectionid,
Fixture = task.fixtureguid,
RequestForm = task.no,
RobotStep = (int)task.action,
StorageNo = task.locationid,
SN = task.sn,
Program = task.programnumber
};
var result = PushTask(hostDic,sendToPLC, out string message);
if (!result)
{
Logger.WriteLineError($"TASK 下发失败 : {message}");
return;
}
task.send = 1;
if (!dbhelper.UpdateTask(task))
{
Logger.WriteLineError($"更新TASK 下发状态失败");
}
}
}
public void Dispose()
{
throw new NotImplementedException();
}
/// <summary>
/// 下发任务
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
/// <param name="request"></param>
/// <param name="msg"></param>
private bool PushTask(string ip,RequestPLC request,out string msg)
{
msg = string.Empty;
try
{
var param = JsonHelper.SerializerToJsonString(request);
var retstring = HttpHelper.HttpPost($"{ip}{CommonConst.SenTaskToMES}", "application/json", param);
var result = JsonConvert.DeserializeObject<ResponsePlC>(retstring);
if (result.return_code != 0)
{
msg = $"PushTask failed,URL{ip} input:{param } result :{result.return_desc}";
return false;
}
return true;
}catch(Exception ex)
{
msg = ex.ToString();
}
return false;
}
//获取TaskList
private List<int>GetTaskList()
private int GetProjectId()
{
var _pid = ConfigManager.GetValue("ProjectSetting", "ProjectId", string.Empty);
if (string.IsNullOrEmpty(_pid))
Logger.WriteLineError("DbSetting about [ProjectSetting] ProjectId not found.");
return int.Parse(_pid);
}
private string GetHost()
{
var host = ConfigManager.GetValue("ProjectSetting", "Host", string.Empty);
if (string.IsNullOrEmpty(host))
{
Logger.WriteLineError("DbSetting about [ProjectSetting] Host not found.");
return null;
}
return host;
return new List<int>();
}
}
}
using Siger.Middlelayer.AccRepository;
using Siger.Middlelayer.AccRepository.Entities;
using Siger.Middlelayer.CncRepository;
using Siger.Middlelayer.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static Siger.Middlelayer.Share.Enum.ModuleEnum.Automation;
namespace Siger.ApiACC.Tasks
{
public class DBhelper
public class DBhelper : IDisposable
{
private static DBhelper _helper;
public static DBhelper Instance = _helper ?? (_helper = new DBhelper());
public ApiCncDbContext CncDbContext;
public ApiAccDbContext AccDbContext;
public ApiConfigDbContext ConfigDbContext;
private readonly ApiCncDbContext CncDbContext;
private readonly ApiAccDbContext AccDbContext;
private readonly ApiConfigDbContext ConfigDbContext;
static DBhelper()
{
}
public void LoadDbContext()
public DBhelper()
{
CncDbContext = new ApiCncDbContext();
AccDbContext = new ApiAccDbContext();
ConfigDbContext = new ApiConfigDbContext();
}
public List<int> GetTaskList()
internal bool CanTask(int projectId, int section)
{
return new List<int>();
var taskObj = AccDbContext.siger_automation_task_list.FirstOrDefault(f => f.projectId == projectId && f.status >= (int)TaskResultStatus.Cancel && f.status < (int)TaskResultStatus.Complated);
if (taskObj == null)
return true;
else
return false;
}
/// <summary>
/// 获取未推送tasklist
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public IEnumerable<siger_automation_task_list> GetTaskList(int projectId)
{
var taskObjs = AccDbContext.siger_automation_task_list.Where(f => f.projectId == projectId && f.send==0 && f.status >= (int)TaskResultStatus.Cancel && f.status < (int)TaskResultStatus.Complated);
return taskObjs;
}
public siger_automation_fixture_tools_monitor GetMonitor(int section)
{
return AccDbContext.siger_automation_fixture_tools_moniter.FirstOrDefault(f => f.section == section);
}
public bool UpdateTask(siger_automation_task_list taskNo)
{
AccDbContext.siger_automation_task_list.Update(taskNo);
return AccDbContext.SaveChanges() > 0;
}
public void Dispose()
{
......@@ -37,5 +62,6 @@ namespace Siger.ApiACC.Tasks
AccDbContext?.Dispose();
ConfigDbContext?.Dispose();
}
}
}
......@@ -9,7 +9,7 @@ namespace Siger.ApiCNC.Tasks
{
public CncRegistry()
{
Schedule<ProduceEfficiencyJob>().ToRunNow().AndEvery(1).Days().At(3,0);
//Schedule<ProduceEfficiencyJob>().ToRunNow().AndEvery(1).Days().At(3,0);
}
}
}
......@@ -105,5 +105,7 @@
/// 罗美特追溯附件 存放路径
/// </summary>
public const string MetekAttachmentFilePath = "attachment";
public const string SenTaskToMES = "/distributiontask";
}
}
......@@ -1473,5 +1473,8 @@ namespace Siger.Middlelayer.Common
[Description("ID重复")]
IDExist,
[Description("父级和子级不能相同")]
ParentSonSame,
}
}
using Siger.Middlelayer.Utility.ExcelImport;
namespace Siger.Middlelayer.Utility.ImportEntities
{
public class FixtureToolsCategoryTemplate : ImportBase
{
[ExcelColumn("工装类型*")]
public string Fixture { get; set; }
[ExcelColumn("上级类型")]
public string Parent { get; set; }
}
public class FixtureToolsTemplate : ImportBase
{
[ExcelColumn("工装类型*")]
public string Catgeory { get; set; }
[ExcelColumn("管理类型*")]
public string Manage { get; set; }
[ExcelColumn("工装名称*")]
public string Name { get; set; }
[ExcelColumn("工装料号*")]
public string PartNumber { get; set; }
[ExcelColumn("工装编号*")]
public string Code { get; set; }
[ExcelColumn("规格型号*")]
public string Specfication { get; set; }
[ExcelColumn("数量*")]
public string Number { get; set; }
[ExcelColumn("状态*")]
public string Status { get; set; }
[ExcelColumn("备注")]
public string Remark { get; set; }
}
public class FixtureToolsProductTemplate : ImportBase
{
[ExcelColumn("工装编号*")]
public string FixtureTool { get; set; }
[ExcelColumn("产品名称*")]
public string Product { get; set; }
[ExcelColumn("备注")]
public string Remark { get; set; }
}
public class FixtureToolsAssmeblyTemplate : ImportBase
{
[ExcelColumn("父工装编号*")]
public string ParentFixtureTool { get; set; }
[ExcelColumn("子工装编号*")]
public string FixtureTool { get; set; }
[ExcelColumn("备注")]
public string Remark { get; set; }
}
}
......@@ -11,6 +11,10 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary>
public string fixtureguid { get; set; }
/// <summary>
/// 工装名称
/// </summary>
public string fixturename { get; set; }
/// <summary>
/// 当前工站ID
/// </summary>
public int section { get; set; }
......
......@@ -7,6 +7,7 @@ using Siger.Middlelayer.AccRepository.Entities;
using Siger.Middlelayer.AccRepository.Repositories.Interface;
using Siger.Middlelayer.AccRepository.Response;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Repository.Data.Acc;
using Siger.Middlelayer.Repository.Paged;
......@@ -20,7 +21,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
_context = context;
}
public IPagedCollectionResult<ResponseFixtureToolsCategory> GetPagedList(int id, int projectid, int page, int pagesize)
public IPagedCollectionResult<ResponseFixtureToolsCategory> GetPagedList(int id, int projectid, int page, int pagesize, string toexcel = "")
{
Expression<Func<ResponseFixtureToolsCategory, bool>> FunNum = f => true;
var query = from q in _context.siger_automation_fixture_tools_category
......@@ -42,9 +43,17 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{
FunNum = q => q.id == id;
}
var entities = query.Where(FunNum).OrderBy(q => q.parentid).OrderBy(q => q.createtime).Skip((page - 1) * pagesize).Take(pagesize).AsNoTracking().ToList();
var totalCount = query.Where(FunNum).Count();
return new PagedCollectionResult<ResponseFixtureToolsCategory>(entities, totalCount);
if(toexcel.ToInt() == 1)
{
var entities = query.Where(FunNum).OrderBy(q => q.parentid).OrderBy(q => q.createtime).AsNoTracking().ToList();
return new PagedCollectionResult<ResponseFixtureToolsCategory>(entities, entities.Count);
}
else
{
var entities = query.Where(FunNum).OrderBy(q => q.parentid).OrderBy(q => q.createtime).Skip((page - 1) * pagesize).Take(pagesize).AsNoTracking().ToList();
var totalCount = query.Where(FunNum).Count();
return new PagedCollectionResult<ResponseFixtureToolsCategory>(entities, totalCount);
}
}
}
}
......@@ -28,7 +28,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
where q.projectId == projectId && q.productcode==productCode && q.status == (int)RowState.Valid && t.status == (int)RowState.Valid
select new ResponseProductFixtureInfo
{
FixtureId=t.id,
FixtureName=t.name,
FixtureGuid=t.guid,
ProductCode=q.productcode,
Location=l.locationid,
......
......@@ -7,6 +7,7 @@ using Siger.Middlelayer.AccRepository.Entities;
using Siger.Middlelayer.AccRepository.Repositories.Interface;
using Siger.Middlelayer.AccRepository.Response;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Repository.Data.Acc;
using Siger.Middlelayer.Repository.Extensions;
using Siger.Middlelayer.Repository.Paged;
......@@ -22,7 +23,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
}
public IPagedCollectionResult<ResponseFixtureTools> GetPagedList(int category, string code, string name, int state,
int projectid, int page, int pagesize)
int projectid, int page, int pagesize, string toexcel = "")
{
var query = from q in _context.siger_automation_fixture_tools
join p in _context.siger_automation_fixture_tools_category on q.category equals p.guid
......@@ -70,13 +71,21 @@ namespace Siger.Middlelayer.AccRepository.Repositories
stateExpression = q => q.status == state;
}
var expression = categoryExpression.And(codeExpression).And(nameExpression).And(stateExpression);
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<ResponseFixtureTools>(entities, totalCount);
if(toexcel.ToInt() == 1)
{
var entities = query.Where(expression).OrderByDescending(q => q.id).AsNoTracking().ToList();
return new PagedCollectionResult<ResponseFixtureTools>(entities, entities.Count);
}
else
{
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<ResponseFixtureTools>(entities, totalCount);
}
}
public IEnumerable<ResponseFixtureTools> GetDataList(int projectid)
public IEnumerable<ResponseFixtureTools> GetDataList(int categoryid, int projectid)
{
var query = from q in _context.siger_automation_fixture_tools
join p in _context.siger_automation_fixture_tools_category on q.category equals p.guid
......@@ -98,6 +107,10 @@ namespace Siger.Middlelayer.AccRepository.Repositories
status = q.status,
updatetime = q.updatetime.HasValue && q.updatetime > DateTime.MinValue ? q.updatetime.Value.ToString(ParameterConstant.DateTimeFormat) : ""
};
if (categoryid > 0)
{
query = query.Where(q => q.categoryid == categoryid);
}
var entities = query.OrderByDescending(q => q.id).AsNoTracking().ToList();
return entities;
}
......@@ -109,7 +122,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
select new ResponseProductFixtureInfo
{
FixtureGuid=q.guid,
FixtureId=q.id,
FixtureName=q.name,
Location=l.locationid
};
return query.FirstOrDefault();
......
......@@ -30,6 +30,10 @@ namespace Siger.Middlelayer.AccRepository.Repositories
join w in _context.siger_wms_storage on l.storageid equals w.id
join u in _context.siger_project_user on q.updator equals u.mid into uu
from u in uu.DefaultIfEmpty()
join m in _context.siger_automation_fixture_tools_moniter on q.fixturetools equals m.fixtureguid into mm
from m in mm.DefaultIfEmpty()
join r in _context.siger_project_product_route on m.route equals r.id into rr
from r in rr.DefaultIfEmpty()
where q.projectId == projectid && q.status == (int)RowState.Valid
select new ResponseAutomationLocation
{
......@@ -49,7 +53,10 @@ namespace Siger.Middlelayer.AccRepository.Repositories
remark = q.remark,
updator = u.name ?? "",
status = q.status,
updatetime = q.updatetime.HasValue && q.updatetime > DateTime.MinValue ? q.updatetime.Value.ToString(ParameterConstant.DateTimeFormat) : ""
updatetime = q.updatetime.HasValue && q.updatetime > DateTime.MinValue ? q.updatetime.Value.ToString(ParameterConstant.DateTimeFormat) : "",
sn = m.sn ?? "",
route = r.name ?? "",
routenumber = r == null ? "" : r.serialNumber.ToString()
};
Expression<Func<ResponseAutomationLocation, bool>> wavehouseidExpression = f => true;
if (wavehouseid > 0)
......@@ -84,6 +91,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
join c in _context.siger_automation_fixture_tools_category on t.category equals c.guid
join l in _context.siger_wms_storage_location on q.locationid equals l.locationid
join w in _context.siger_wms_storage on l.storageid equals w.id
join m in _context.siger_automation_fixture_tools_moniter on q.fixturetools equals m.fixtureguid into mm
from m in mm.DefaultIfEmpty()
where q.projectId == projectid && q.status == (int)RowState.Valid
select new ResponseAutomationLocationList
{
......@@ -97,9 +106,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories
fixturetoolid = t.id,
code = t.code,
name = t.name,
materialsn = "TestData"
materialsn = m.sn ?? ""
};
var entities = query.OrderByDescending(q => q.id).AsNoTracking().ToList();
var entities = query.AsNoTracking().ToList();
return entities;
}
}
......
......@@ -7,6 +7,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
{
public interface IAutomationFixtureToolsCategoryRepository : IAccRepositoryBase<siger_automation_fixture_tools_category>
{
IPagedCollectionResult<ResponseFixtureToolsCategory> GetPagedList(int id, int projectid, int page, int pagesize);
IPagedCollectionResult<ResponseFixtureToolsCategory> GetPagedList(int id, int projectid, int page, int pagesize, string toexcel = "");
}
}
......@@ -9,9 +9,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
public interface IAutomationFixtureToolsRepository : IAccRepositoryBase<siger_automation_fixture_tools>
{
IPagedCollectionResult<ResponseFixtureTools> GetPagedList(int category, string code, string name, int state,
int projectid, int page, int pagesize);
int projectid, int page, int pagesize, string toexcel = "");
IEnumerable<ResponseFixtureTools> GetDataList(int projectid);
IEnumerable<ResponseFixtureTools> GetDataList(int categoryid, int projectid);
ResponseProductFixtureInfo GetProductFixtureLocation(int projectId, string guid);
}
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Siger.Middlelayer.AccRepository.Request
{
public class RequestPLC
{
/// <summary>
/// 工件唯一识别SN
/// </summary>
public String SN { get; set; }
/// <summary>
/// 工装唯一编号GUID
/// </summary>
public string Fixture { get; set; }
/// <summary>
/// 任务唯一编号
/// </summary>
public string RequestForm { get; set; }
/// <summary>
/// 机器人动作指令
/// </summary>
public int RobotStep { get; set; }
/// <summary>
/// 发起地
/// </summary>
public int RStation { get; set; }
/// <summary>
/// 储位位置编号
/// </summary>
public int StorageNo { get; set; }
/// <summary>
/// 加工程序号 ,上料完成后自动加工需要
/// </summary>
public string Program { get; set; }
}
public class ResponsePlC
{
public int return_code { get; set; }
public string return_desc { get; set; }
}
}
......@@ -7,9 +7,10 @@ namespace Siger.Middlelayer.AccRepository.Response
public class ResponseProductFixtureInfo
{
/// <summary>
/// 工装ID
/// 工装名称
/// </summary>
public int FixtureId { get; set; }
public string FixtureName { get; set; }
/// <summary>
/// GUID
/// </summary>
......
......@@ -351,19 +351,22 @@ CREATE TABLE IF NOT EXISTS `siger_automation_task_list` (
-- ----------------------------
-- 设备可用状态
-- Table structure for siger_automation_task_list
-- Table structure for siger_automation_machine_status
-- ----------------------------
DROP TABLE IF EXISTS `siger_automation_machine_status`;
CREATE TABLE `siger_automation_machine_status` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`section` int(11) NOT NULL DEFAULT 0 COMMENT '工位ID',
`machineid` int(11) NOT NULL DEFAULT 0 COMMENT '工位对应设备ID',
`projectid` int(11) NOT NULL DEFAULT 0,
`enable` int(1) NOT NULL DEFAULT 1 COMMENT '设备可用状态 0:不可用 1:可用',
`status` int(1) NOT NULL DEFAULT 1 COMMENT '完工状态 0:取消 1:待生产 2:生产中 3:生产完成 ',
`updatetime` datetime(0) NULL DEFAULT NULL COMMENT '操作时间',
CREATE TABLE `siger_automation_machine_status` (
`id` int NOT NULL AUTO_INCREMENT,
`section` int NOT NULL DEFAULT '0' COMMENT '工位ID',
`machineid` int NOT NULL DEFAULT '0' COMMENT '工位对应设备ID',
`projectid` int NOT NULL DEFAULT '0',
`enable` int NOT NULL DEFAULT '1' COMMENT '设备可用状态 0:不可用 1:可用',
`status` int NOT NULL DEFAULT '1' COMMENT '完工状态 0:取消 1:待生产 2:生产中 3:生产完成 ',
`updatetime` datetime DEFAULT NULL COMMENT '操作时间',
`program` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '程序号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
SET FOREIGN_KEY_CHECKS=1;
-- ----------------------------
......@@ -414,6 +417,7 @@ CREATE TABLE `siger_automation_fixture_tools_moniter` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`projectid` int(11) NOT NULL DEFAULT 0,
`fixtureguid` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工装ID',
`fixturename` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工装名称',
`section` int(11) NOT NULL DEFAULT 0 COMMENT '当前工站ID',
`sn` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '当前绑定工件',
`route` int(1) NOT NULL DEFAULT 1 COMMENT '工序ID',
......@@ -428,18 +432,6 @@ CREATE TABLE `siger_automation_fixture_tools_moniter` (
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `siger_automation_machine_status`;
CREATE TABLE `siger_automation_machine_status` (
`id` int NOT NULL AUTO_INCREMENT,
`section` int NOT NULL DEFAULT '0' COMMENT '工位ID',
`machineid` int NOT NULL DEFAULT '0' COMMENT '工位对应设备ID',
`projectid` int NOT NULL DEFAULT '0',
`enable` int NOT NULL DEFAULT '1' COMMENT '设备可用状态 0:不可用 1:可用',
`status` int NOT NULL DEFAULT '1' COMMENT '完工状态 0:取消 1:待生产 2:生产中 3:生产完成 ',
`updatetime` datetime DEFAULT NULL COMMENT '操作时间',
`program` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '程序号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
SET FOREIGN_KEY_CHECKS=1;
SET FOREIGN_KEY_CHECKS = 1;
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