Commit 9f261137 by yucheng.jiang
parents 281394cc 64e411d3
......@@ -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': '部门不能为空',
......
......@@ -654,7 +654,6 @@ export default {
});
},
linechange(i) {
console.log(1111111111);
this.a = i;
this.line = this.lineList[i];
this.initstations(this.line.id);
......@@ -672,7 +671,7 @@ export default {
axios
.request({
url:
"http://localhost:8105/acc/SectionProperty/GetSections"
"/acc/SectionProperty/GetSections"
,
params,
method: "get",
......@@ -715,6 +714,22 @@ export default {
this.b = i;
this.station = this.stationList[i];
this.initproduct(this.station.id);
this.initSn(this.station.id)
},
initSn(sectionid){
if (sectionid > 0) {
axios
.request({
url:
"/acc/SectionProperty/GetSn?productId=" + productid + "&sectionId=" + sectionid,
method: "get",
})
.then((res) => {
if (res.data.ret === 1) {
this.qrcode = res.data.data;
}
});
}
},
productchange(i) {
this.c = i;
......@@ -730,7 +745,7 @@ export default {
axios
.request({
url:
"/acc/SectionProperty/GetRouteByProduct?productId=" + productid,
"/acc/SectionProperty/GetRouteByProduct?productId=" + productid + "&sectionId=" + sectionid,
method: "get",
})
.then((res) => {
......
......@@ -28,9 +28,10 @@ namespace Siger.ApiACC.Controllers
private readonly ISigerDict _sigerDict;
private readonly IAutomationTaskListRepository _automationTaskList;
private readonly ISigerProjectMachineAttributionRepository _sigerProjectMachineAttribution;
private readonly IAutomationFixtureMonitor _automationFixtureMonitor;
public AutomationController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection,IAutomationLineMode automationLineMode,IAutomationMachineStatus automationMachineStatus,ISigerDict sigerDict,IAutomationTaskListRepository automationTaskList,
ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution)
ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution, IAutomationFixtureMonitor automationFixtureMonitor)
{
_unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection;
......@@ -39,6 +40,7 @@ namespace Siger.ApiACC.Controllers
_sigerDict = sigerDict;
_automationTaskList = automationTaskList;
_sigerProjectMachineAttribution = sigerProjectMachineAttribution;
_automationFixtureMonitor = automationFixtureMonitor;
}
/// <summary>
......@@ -181,7 +183,7 @@ namespace Siger.ApiACC.Controllers
public IActionResult TaskResult([FromBody]RequestAutomationTaskResult request)
{
//1.检查Tasklist
var taskObj = _automationTaskList.Get(f => f.guid == request.guid);
var taskObj = _automationTaskList.Get(f => f.no== request.guid);
if (taskObj == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
......@@ -311,8 +313,28 @@ namespace Siger.ApiACC.Controllers
}
}
/// <summary>
/// 创建自动任务
/// </summary>
/// <param name="machineStatus"></param>
/// <param name="actionType"></param>
/// <param name="taskAction"></param>
void CreateTask(siger_automation_machine_status machineStatus,TaskActionType actionType, TaskAction taskAction)
{
//j检查工装监控状态
var monitor = _automationFixtureMonitor.Get(f => f.section == machineStatus.section);
if (monitor==null)
{
Logger.WriteLineInfo($"CreateTask 工装监控状态无数据,请确认业务链正确 ");
return;
}
if (monitor.section==0)
{
Logger.WriteLineInfo($"CreateTask 工装监控状态无当前工站信息,请确认业务链正确 ");
return;
}
_automationTaskList.Insert(new siger_automation_task_list
{
......@@ -328,9 +350,16 @@ namespace Siger.ApiACC.Controllers
send = 0,
operater = 0,
status = 1,
fixtureguid=monitor.fixtureguid,
productcode=monitor.productCode,
locationid=monitor.locationId,
ordercode=monitor.ordernumber,
sn=monitor.sn,
remark="自动任务"
});
if (_unitOfWork.Commit() > 0)
Logger.WriteLineInfo($"CreateTask 工站 完成");
else
......
......@@ -23,20 +23,79 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationFixtureToolsCategoryRepository _toolsCategoryRepository;
private readonly IAutomationFixtureToolsRepository _toolsRepository;
private readonly IAutomationLocationRepository _autoLocationRepository;
private readonly IAutomationFixtureMonitor _fixtureMonitor;
private readonly IProductRouteRepository _routeRepository;
public AutomationLocationController(IUnitOfWork unitOfWork, IAutomationFixtureToolsCategoryRepository toolsCategoryRepository,
IAutomationFixtureToolsRepository toolsRepository, IAutomationLocationRepository autoLocationRepository)
IAutomationFixtureToolsRepository toolsRepository, IAutomationLocationRepository autoLocationRepository,
IAutomationFixtureMonitor fixtureMonitor, IProductRouteRepository routeRepository)
{
_unitOfWork = unitOfWork;
_toolsCategoryRepository = toolsCategoryRepository;
_toolsRepository = toolsRepository;
_autoLocationRepository = autoLocationRepository;
_fixtureMonitor = fixtureMonitor;
_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);
return new PagedObjectResult(data.Data, data.Total, page, pagesize);
var list = new List<ResponseAutomationLocation>();
var locations = _autoLocationRepository.GetLocationList(ProjectId);
var categorys = _toolsCategoryRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).ToList();
foreach (var item in data.Data)
{
if(item.fixturetoolid > 0 && string.IsNullOrEmpty(item.sn))
{
item.materialstate = 1;//有工装无工件
}
else if(item.fixturetoolid > 0 && !string.IsNullOrEmpty(item.sn))
{
item.materialstate = 2;//有工装有工件
}
else if (item.fixturetoolid <= 0 && string.IsNullOrEmpty(item.sn))
{
item.materialstate = 3;//无工装无工件
}
else if (item.fixturetoolid <= 0 && string.IsNullOrEmpty(item.sn))
{
item.materialstate = 4;//无工装有工件
}
var loca = locations.FirstOrDefault(q => q.locationid == item.locaid);
if(loca != null)
{
var locas = GetParentLocations(loca.id, locations);
var locationIds = locas.Select(q => q.id).ToList();
locationIds = locationIds.Distinct().ToList();
locationIds.Reverse();
item.locationIds = locationIds;
}
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)));
}
private IEnumerable<siger_wms_storage_location> GetParentLocations(int pid, IEnumerable<siger_wms_storage_location> types)
{
var query = from c in types where c.id == pid select c;
return query.ToList().Concat(query.ToList().SelectMany(t => GetParentLocations(t.parentid, types)));
}
[HttpPost]
......@@ -66,7 +125,7 @@ namespace Siger.ApiACC.Controllers
var entity = new siger_automation_location
{
guid = Guid.NewGuid().ToString(),
locationid = req.locationid.ToInt(),
locationid = location.locationid,
fixturetools = fixturetool.guid,
attachment = req.fileurl,
filename = req.filename,
......@@ -115,7 +174,7 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(RequestEnum.DataExist);
}
entity.locationid = req.locationid.ToInt();
entity.locationid = location.locationid;
entity.fixturetools = fixturetool.guid;
entity.attachment = req.fileurl;
entity.filename = req.filename;
......
......@@ -33,9 +33,10 @@ namespace Siger.ApiACC.Controllers
private readonly IProductPlanRepository _productPlan;
private readonly IAutomationFixtureMonitor _automationFixtureMonitor;
private readonly IAutomationFixtureToolsProductRepository _automationFixtureToolsProduct;
private readonly IAutomationFixtureToolsRepository _automationFixtureTools;
public AutomationOperateController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection , ISigerDict sigerDict,IAutomationMachineStatus automationMachineStatus,ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution,IAutomationTaskListRepository automationTaskList,
IProductPlanDetails planDetails,IProductPlanRepository productPlan,IAutomationFixtureMonitor automationFixtureMonitor ,IAutomationFixtureToolsProductRepository automationFixtureToolsProduct)
IProductPlanDetails planDetails,IProductPlanRepository productPlan,IAutomationFixtureMonitor automationFixtureMonitor ,IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,IAutomationFixtureToolsRepository automationFixtureTools)
{
_unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection;
......@@ -47,6 +48,7 @@ namespace Siger.ApiACC.Controllers
_productPlan = productPlan;
_automationFixtureMonitor = automationFixtureMonitor;
_automationFixtureToolsProduct = automationFixtureToolsProduct;
_automationFixtureTools = automationFixtureTools;
}
/// <summary>
......@@ -139,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,
......@@ -159,7 +163,7 @@ namespace Siger.ApiACC.Controllers
var result = _automationFixtureToolsProduct.GetPlanFixtureInfo(ProjectId, code);
if (result==null)
{
throw new BadRequestException(CncEnum.PlanHasExist);
throw new BadRequestException(AccEnum.FixtureOrderNulll);
}
var sn = _automationTaskList.CreateRandonSn(result.ProductCode);
result.Sn = sn;
......@@ -179,19 +183,33 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var machineStatus = _automationMachineStatus.Get(f => f.machineid==machineAttr.machine);
if (machineStatus==null)
var machineStatus = _automationMachineStatus.Get(f => f.machineid == machineAttr.machine);
if (machineStatus == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
// throw new BadRequestException(CommonEnum.RecordNotFound);
//上料设备状态与PLC 无关,
//需要手动插入
_automationMachineStatus.Insert(new siger_automation_machine_status
{
enable = 1,
section = loading.section,
machineid = machineAttr.machine,
projectId = ProjectId,
status = (int)Automation.MachineStatus.Produce,
updatetime = DateTime.Now
});
}
if (machineStatus.enable==0)
else
{
if (machineStatus.enable == 0)
{
throw new BadRequestException(AccEnum.MachineDisable);
}
if(machineStatus.status!=(int)Automation.MachineStatus.Waiting)
if (machineStatus.status != (int)Automation.MachineStatus.Waiting)
{
throw new BadRequestException(AccEnum.MachineBusy);
}
}
if (!_automationTaskList.CanTask(ProjectId,loading.section))
{
throw new BadRequestException(AccEnum.TaskProcessing);
......@@ -208,7 +226,8 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(CncEnum.PlanHasExist);
}
//检查工装
var fixtureToolsObj = _automationFixtureToolsProduct.GetFixtureInfoByProductCode(ProjectId, plan.product_code);
var fixtureToolsObj = _automationFixtureTools.GetProductFixtureLocation(ProjectId,loading.guid);
//var fixtureToolsObj = _automationFixtureToolsProduct.GetFixtureInfoByProductCode(ProjectId, plan.product_code);
if (fixtureToolsObj == null)
{
throw new BadRequestException(AccEnum.FixtureToolsIsNone);
......@@ -248,6 +267,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,
......
......@@ -37,7 +37,30 @@ namespace Siger.ApiACC.Controllers
public IActionResult GetPageList(string category, string code, string name, int page, int pagesize)
{
var data = _toolsAssemblyRepository.GetPagedList(category.ToInt(), code, name, ProjectId, page, pagesize);
return new PagedObjectResult(data.Data, data.Total, page, pagesize);
var categorys = _toolsCategoryRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).ToList();
var list = new List<ResponseAumationFixtureToolsAssembly>();
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;
var parentcates = GetParentCategoryList(item.parentcate_guid, categorys);
var parentcateIds = parentcates.Select(q => q.id).ToList();
parentcateIds.Reverse();
item.parentcategoryids = parentcateIds;
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)));
}
[HttpGet]
......@@ -55,22 +78,50 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(RequestEnum.ParameterMiss);
}
if(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)
if (parent == null)
{
throw new BadRequestException(RequestEnum.FixtureToolNotFound);
}
if (parent == null)
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 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);
}
var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid);
if(parentExsit != null)
{
throw new BadRequestException(RequestEnum.LevelCountError);
}
if (_toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid) == null)
{
var parentEntity = new siger_automation_fixture_tools_assembly
{
guid = Guid.NewGuid().ToString(),
parent = "",
son = parent.guid,
creator = UserId,
createtime = DateTime.Now,
attachment = req.fileurl,
filename = req.filename,
projectId = ProjectId,
updatetime = DateTime.Now,
updator = UserId,
status = req.status.ToInt() == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
};
_toolsAssemblyRepository.Insert(parentEntity);
}
var entity = new siger_automation_fixture_tools_assembly
{
......@@ -104,24 +155,57 @@ 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)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId);
if (parent == null)
{
throw new BadRequestException(RequestEnum.FixtureToolNotFound);
}
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 parentGuid = parent.guid;
var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == son.guid && q.parent == parentGuid &&
q.id != req.id);
if (exsit != null)
{
throw new BadRequestException(RequestEnum.DataExist);
}
var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid);
if (parentExsit != null)
{
throw new BadRequestException(RequestEnum.LevelCountError);
}
if (_toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid) == null)
{
var parentEntity = new siger_automation_fixture_tools_assembly
{
guid = Guid.NewGuid().ToString(),
parent = "",
son = parent.guid,
creator = UserId,
createtime = DateTime.Now,
attachment = req.fileurl,
filename = req.filename,
projectId = ProjectId,
updatetime = DateTime.Now,
updator = UserId,
status = req.status.ToInt() == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
};
_toolsAssemblyRepository.Insert(parentEntity);
}
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;
......@@ -191,30 +249,59 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(CommonEnum.Fail);
}
[HttpGet]
public IActionResult GetFxitureTooolList()
public IActionResult GetCategoryPageList(string id, int page, int pagesize, string toexcel = "")
{
var list = _toolsRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).Select(
q => new
var data = _toolsCategoryRepository.GetPagedList(id.ToInt(), ProjectId, page, pagesize, toexcel);
if(toexcel.ToInt() == 1)
{
q.id,
q.code,
q.partnumber,
q.name,
q.specification,
q.number
}).ToList();
return new ObjectResult(list);
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>();
[HttpGet]
public IActionResult GetCategoryPageList(string id, int page, int pagesize)
foreach (var item in data)
{
var data = _toolsCategoryRepository.GetPagedList(id.ToInt(), ProjectId, page, pagesize);
return new PagedObjectResult(data.Data, data.Total, page, pagesize);
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]
......@@ -370,5 +457,13 @@ namespace Siger.ApiACC.Controllers
}
return resp;
}
[HttpGet]
public IActionResult GetFixtureToolList(string categoryid)
{
var list = _toolsRepository.GetDataList(categoryid.ToInt(), ProjectId);
return new ObjectResult(list);
}
}
}
......@@ -36,10 +36,28 @@ namespace Siger.ApiACC.Controllers
_productRepository = productRepository;
}
[HttpGet]
public IActionResult GetPageList(string category, string tool, string product, int page, int pagesize)
{
var data = _toolsProductRepository.GetPagedList(category.ToInt(), tool.ToInt(), product.ToInt(), ProjectId, page, pagesize);
return new PagedObjectResult(data.Data, data.Total, page, pagesize);
var categorys = _toolsCategoryRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).ToList();
var list = new List<ResponseAumationFixtureToolsProduct>();
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]
......@@ -72,6 +90,7 @@ namespace Siger.ApiACC.Controllers
fixturetools = fixtureTool.guid,
remark = req.remark,
productid = req.productid.ToInt(),
productcode = product.code,
projectId = ProjectId,
createtime = DateTime.Now,
updatetime = DateTime.Now,
......@@ -123,6 +142,7 @@ namespace Siger.ApiACC.Controllers
entity.fixturetools = fixtureTool.guid;
entity.remark = req.remark;
entity.productid = req.productid.ToInt();
entity.productcode = product.code;
entity.updatetime = DateTime.Now;
entity.updator = UserId;
entity.filename = req.filename;
......
......@@ -23,14 +23,17 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationSectionPropertyRepository _sectionPropertyRepository;
private readonly ISigerProjectLevelSectionRepository _levelSectionRepository;
private readonly IProductionBeatSetRepository _beatSetRepository;
private readonly IAutomationFixtureMonitor _fixtureMonitor;
public SectionPropertyController(IUnitOfWork unitOfWork, IAutomationSectionPropertyRepository sectionPropertyRepository,
ISigerProjectLevelSectionRepository levelSectionRepository, IProductionBeatSetRepository beatSetRepository)
ISigerProjectLevelSectionRepository levelSectionRepository, IProductionBeatSetRepository beatSetRepository,
IAutomationFixtureMonitor fixtureMonitor)
{
_unitOfWork = unitOfWork;
_sectionPropertyRepository = sectionPropertyRepository;
_levelSectionRepository = levelSectionRepository;
_beatSetRepository = beatSetRepository;
_fixtureMonitor = fixtureMonitor;
}
[HttpGet]
......@@ -44,10 +47,11 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(sections);
}
public IActionResult GetRouteByProduct(string productId)
[HttpGet]
public IActionResult GetRouteByProduct(string productId, int sectionId)
{
var list = _beatSetRepository.GetList(q => q.projectID == ProjectId && q.status == (int)RowState.Valid && q.product_name.ToInt() == productId.ToInt()).
Select(q => new
var list = _beatSetRepository.GetList(q => q.projectID == ProjectId && q.status == (int)RowState.Valid && q.product_name.ToInt() == productId.ToInt() &&
q.section_id == sectionId).Select(q => new
{
q.id,
name = q.route_name,
......@@ -56,5 +60,13 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(list);
}
[HttpGet]
public IActionResult GetSn(int sectionid)
{
var monitor = _fixtureMonitor.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.section == sectionid).OrderByDescending(q => q.updatetime).
FirstOrDefault();
return new ObjectResult(monitor?.sn ?? "");
}
}
}
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;
}
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()
{
//获取TaskList
private List<int>GetTaskList()
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;
static DBhelper()
{
}
public void LoadDbContext()
private readonly ApiCncDbContext CncDbContext;
private readonly ApiAccDbContext AccDbContext;
private readonly ApiConfigDbContext ConfigDbContext;
public DBhelper()
{
CncDbContext = new ApiCncDbContext();
AccDbContext = new ApiAccDbContext();
ConfigDbContext = new ApiConfigDbContext();
}
public List<int> GetTaskList()
internal bool CanTask(int projectId, int section)
{
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 new List<int>();
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);
}
}
}
......@@ -1127,5 +1127,67 @@ namespace Siger.ApiWMS.Controllers
return query.ToList().Concat(query.ToList().SelectMany(t => GetSonTypes(t.id, types)));
}
[HttpGet]
public IActionResult GetLocationTree(int warehouseid)
{
var locationTypes = locationtype.GetList(q => q.projectid == ProjectId && q.status == (int)RowState.Valid).ToList();
var sonLocationTypes = GetSonTypes(0, locationTypes).ToList();
var lastLocationId = sonLocationTypes.LastOrDefault()?.id ?? 0;
var allLocas = location.GetList(q => q.projectid == ProjectId && q.status == (int)RowState.Valid).ToList();
var locations = allLocas.Where(q => q.typeid == lastLocationId);
if(warehouseid > 0)
{
locations = locations.Where(q => q.storageid == warehouseid);
}
var locationTreeList = new List<LevelSectionTree>();
foreach(var loca in locations)
{
var locas = GetParentLocations(loca.id, allLocas.Select(q => new LevelSectionTree
{
id = q.id,
pid = q.parentid,
title = q.realname,
name = q.realname
}));
locationTreeList.AddRange(locas);
}
var locationTree = locationTreeList.GroupBy(q => q.id).Select(q => q.FirstOrDefault()).ToList();
return new ObjectResult(ConvertToTree(locationTree));
}
private IEnumerable<LevelSectionTree> GetParentLocations(int pid, IEnumerable<LevelSectionTree> types)
{
var query = from c in types where c.id == pid select c;
return query.ToList().Concat(query.ToList().SelectMany(t => GetParentLocations(t.pid, types)));
}
private IList<LevelSectionTree> ConvertToTree(IEnumerable<LevelSectionTree> models)
{
var section = new Dictionary<int, LevelSectionTree>();
foreach (var item in models)
{
section.Add(item.id, item);
}
var result = new List<LevelSectionTree>();
foreach (var item in section.Values)
{
if (item.pid == 0)
{
result.Add(item);
}
else
{
if (section.ContainsKey(item.pid))
{
section[item.pid].AddChilrden(item);
}
}
}
return result;
}
}
}
\ No newline at end of file
......@@ -105,5 +105,7 @@
/// 罗美特追溯附件 存放路径
/// </summary>
public const string MetekAttachmentFilePath = "attachment";
public const string SenTaskToMES = "/distributiontask";
}
}
......@@ -327,6 +327,8 @@ namespace Siger.Middlelayer.Common.ModuleEnum
TaskProcessing,
[Description("产品工装未找到")]
FixtureToolsIsNone,
[Description("未找到工装信息")]
FixtureOrderNulll
}
public enum SeriNumCfg
......
......@@ -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; }
}
}
......@@ -22,7 +22,6 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 附件
/// </summary>
public string attachment { get; set; }
public string fileurl { get; set; }
/// <summary>
/// 附件名称
/// </summary>
......
......@@ -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; }
......
......@@ -25,6 +25,10 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 更新时间
/// </summary>
public DateTime updatetime { get; set; }
/// <summary>
/// 程序号
/// </summary>
public string program { get; set; }
}
}
......@@ -16,6 +16,10 @@ namespace Siger.Middlelayer.AccRepository.Entities
public string no { get; set; }
/// <summary>
/// 工装GUID
/// </summary>
public string fixtureguid { get; set; }
/// <summary>
/// 工位ID
/// </summary>
public int sectionid { get; set; }
......@@ -40,6 +44,10 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary>
public int productid { get; set; }
/// <summary>
/// 产品code
/// </summary>
public string productcode { get; set; }
/// <summary>
/// 工序ID
/// </summary>
public int processid { get; set; }
......@@ -51,10 +59,7 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 储位位置
/// </summary>
public int locationid { get; set; }
/// <summary>
/// 工装GUID
/// </summary>
public string fixtureguid { get; set; }
/// <summary>
/// Task 执行动作类型 1 手动 2 自动
......
......@@ -26,7 +26,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
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 c1 in _context.siger_automation_fixture_tools_category on t1.category equals c1.guid into cc1
from c1 in cc1.DefaultIfEmpty()
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
......@@ -48,7 +49,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories
filename = q.filename,
categoryid = c2.id,
category = c2.name,
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) : "",
cate_guid = t2.guid,
parentcate_guid = t1.guid
};
Expression<Func<ResponseAumationFixtureToolsAssembly, bool>> categoryExpression = f => true;
if (category > 0)
......
......@@ -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;
}
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,
......@@ -61,7 +61,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
filename = q.filename,
partnumber = t.partnumber,
specfication = t.specification,
productcode = p.code
productcode = p.code,
cate_guid = c.guid ?? ""
};
Expression<Func<ResponseAumationFixtureToolsProduct, bool>> categoryExpression = f => true;
if (category > 0)
......@@ -97,9 +98,10 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{
OrderNumber = ordernumber,
ProductName = p.product_name,
ProductCode = q.productcode,
Location = l.locationid,
FixtureName=t.name,
FixtureGuid=t.guid,
ProductCode =q!=null? q.productcode:"",
Location =l!=null? l.locationid:0,
};
return query.FirstOrDefault();
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
......@@ -6,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;
......@@ -21,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
......@@ -69,9 +71,62 @@ namespace Siger.Middlelayer.AccRepository.Repositories
stateExpression = q => q.status == state;
}
var expression = categoryExpression.And(codeExpression).And(nameExpression).And(stateExpression);
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 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
where q.projectId == projectid && q.status == (int)RowState.Valid
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,
partnumber = q.partnumber,
specification = q.specification,
number = q.number,
remark = q.remark,
code = q.code,
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;
}
public ResponseProductFixtureInfo GetProductFixtureLocation(int projectId, string guid)
{
var query = from q in _context.siger_automation_fixture_tools
join l in _context.siger_automation_location on q.guid equals l.guid
select new ResponseProductFixtureInfo
{
FixtureGuid=q.guid,
FixtureName=q.name,
Location=l.locationid
};
return query.FirstOrDefault();
}
}
}
......@@ -30,11 +30,16 @@ 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
{
id = q.id,
locationid = l.id,
locaid = q.locationid,
location = l.name,
wavehouseid = w.id,
wavehouse = w.name,
......@@ -48,7 +53,11 @@ 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(),
cate_guid = c.guid ?? ""
};
Expression<Func<ResponseAutomationLocation, bool>> wavehouseidExpression = f => true;
if (wavehouseid > 0)
......@@ -68,7 +77,12 @@ namespace Siger.Middlelayer.AccRepository.Repositories
public siger_wms_storage_location GetLocation(int id, int projectid)
{
return _context.siger_wms_storage_location.FirstOrDefault(q => q.locationid == id && q.projectId == projectid && q.status == (int)RowState.Valid);
return _context.siger_wms_storage_location.FirstOrDefault(q => q.id == id && q.projectId == projectid && q.status == (int)RowState.Valid);
}
public IEnumerable<siger_wms_storage_location> GetLocationList(int projectid)
{
return _context.siger_wms_storage_location.Where(q => q.projectId == projectid && q.status == (int)RowState.Valid);
}
public IEnumerable<ResponseAutomationLocationList> GetDataList(int projectid)
......@@ -78,10 +92,13 @@ 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
{
id = q.id,
fixtureguid = t.guid,
locationid = l.locationid,
location = l.realname,
locationcode = l.serial_number,
......@@ -91,9 +108,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 = "");
}
}
......@@ -2,12 +2,17 @@
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 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 categoryid, int projectid);
ResponseProductFixtureInfo GetProductFixtureLocation(int projectId, string guid);
}
}
......@@ -14,5 +14,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
siger_wms_storage_location GetLocation(int id, int projectid);
IEnumerable<ResponseAutomationLocationList> GetDataList(int projectid);
IEnumerable<siger_wms_storage_location> GetLocationList(int projectid);
}
}
......@@ -19,5 +19,6 @@ namespace Siger.Middlelayer.AccRepository.Request
/// 完成状态
/// </summary>
public int status { get; set; }
}
}
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; }
}
}
......@@ -11,6 +11,11 @@ namespace Siger.Middlelayer.AccRepository.Request
{
public int section { get; set; }
public string code { get; set; }
/// <summary>
/// 工装GUID
/// </summary>
public string guid { get; set; }
}
/// <summary>
/// 安装完成
......
......@@ -111,6 +111,10 @@ namespace Siger.Middlelayer.AccRepository.Response
public string updatetime { get; set; }
public string fileurl { get; set; }
public string filename { get; set; }
public string cate_guid { get; set; }
public List<int> categoryids { get; set; } = new List<int>();
}
public class ResponseAumationFixtureToolsAssembly
......@@ -130,5 +134,10 @@ namespace Siger.Middlelayer.AccRepository.Response
public int status { get; set; }
public string fileurl { get; set; }
public string filename { get; set; }
public string parentcate_guid { get; set; }
public List<int> parentcategoryids { get; set; } = new List<int>();
public string cate_guid { get; set; }
public List<int> categoryids { get; set; } = new List<int>();
}
}
......@@ -11,6 +11,7 @@ namespace Siger.Middlelayer.AccRepository.Response
/// 储位位置
/// </summary>
public int locationid { get; set; }
public int locaid { get; set; }
public string location { get; set; }
public int wavehouseid { get; set; }
public string wavehouse { get; set; }
......@@ -47,6 +48,10 @@ namespace Siger.Middlelayer.AccRepository.Response
public string updatetime { get; set; }
public int status { get; set; }
public List<int> locationIds { get; set; } = new List<int>();
public List<int> categoryIds { get; set; } = new List<int>();
public string cate_guid { get; set; }
}
public class ResponseAutomationLocationList
......@@ -71,6 +76,7 @@ namespace Siger.Middlelayer.AccRepository.Response
/// 工装ID
/// </summary>
public int fixturetoolid { get; set; }
public string fixtureguid { get; set; }
public string code { get; set; }
public string name { get; set; }
public string materialsn { 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>
......@@ -34,6 +35,8 @@ namespace Siger.Middlelayer.AccRepository.Response
public string ProductCode { get; set; }
public string ProductName { get; set; }
public int status { get; set; }
public string FixtureName { get; set; }
public string FixtureGuid { get; set; }
public int Location { get; set; }
public string Sn { get; set; }
}
......
......@@ -269,9 +269,6 @@ CREATE TABLE IF NOT EXISTS `siger_automation_location` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`locationid` int(11) NOT NULL DEFAULT 0 COMMENT '储位位置',
`fixturetools` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工装GUID',
`materialid` int(11) NOT NULL DEFAULT 0 COMMENT '物料ID',
`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 '备注',
......@@ -327,17 +324,17 @@ CREATE TABLE IF NOT EXISTS `siger_automation_section_route` (
CREATE TABLE IF NOT EXISTS `siger_automation_task_list` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`no` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`fixtureguid` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`fixtureguid` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工装GUID',
`sectionid` int(11) NOT NULL DEFAULT 0 COMMENT '工位ID',
`trigger` int(1) NOT NULL DEFAULT 0 COMMENT '触发方',
`tasktype` int(1) NOT NULL DEFAULT 0 COMMENT '任务类型',
`materialid` int(11) NOT NULL DEFAULT 0 COMMENT '工件ID',
`sn` int(11) NOT NULL DEFAULT 0 COMMENT '工件ID',
`ordercode` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工单号',
`productid` int(11) NOT NULL DEFAULT 0 COMMENT '产品ID',
`productcode` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '产品CODE',
`processid` int(11) NOT NULL DEFAULT 0 COMMENT '工序ID',
`programnumber` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '程序号',
`locationid` int(11) NOT NULL COMMENT '储位位置',
`fixturetools` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工装GUID',
`action` int(1) NOT NULL DEFAULT 0 COMMENT '动作',
`actiontype` int(11) NOT NULL DEFAULT 0 COMMENT '动作类型',
`projectid` int(11) NOT NULL DEFAULT 0,
......@@ -354,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 '操作时间',
`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;
-- ----------------------------
......@@ -417,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',
......@@ -430,4 +431,7 @@ CREATE TABLE `siger_automation_fixture_tools_moniter` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
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