Commit a478442c by yiyu.li
parents 9c5a7d93 2da17f65
...@@ -742,6 +742,7 @@ export default { ...@@ -742,6 +742,7 @@ export default {
'9000517': '请填写子工装编号', '9000517': '请填写子工装编号',
'9000518': '请填写储位ID', '9000518': '请填写储位ID',
'9000519': '请填写仓库名称', '9000519': '请填写仓库名称',
'9000520': '请输入工件编号',
'9100000': 'Departments cannot be empty', '9100000': 'Departments cannot be empty',
'9100001': 'Position cannot be empty', '9100001': 'Position cannot be empty',
......
...@@ -769,6 +769,7 @@ export default { ...@@ -769,6 +769,7 @@ export default {
'9000517': '请填写子工装编号', '9000517': '请填写子工装编号',
'9000518': '请填写储位ID', '9000518': '请填写储位ID',
'9000519': '请填写仓库名称', '9000519': '请填写仓库名称',
'9000520': '请输入工件编号',
'9100000': '部门不能为空', '9100000': '部门不能为空',
......
...@@ -295,7 +295,7 @@ export default { ...@@ -295,7 +295,7 @@ export default {
}, },
{ {
title: "储位编号", title: "储位编号",
key: "locationcode", key: "locationid",
}, },
{ {
title: "工装编号", title: "工装编号",
...@@ -318,7 +318,7 @@ export default { ...@@ -318,7 +318,7 @@ export default {
}, },
{ {
title: "储位编号", title: "储位编号",
key: "locationcode", key: "locationid",
}, },
{ {
title: "工装编号", title: "工装编号",
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
> >
<Option <Option
v-for="(item, index) in productList" v-for="(item, index) in productList"
:value="item.id" :value="item.code"
:key="index" :key="index"
:label=" :label="
item.name + item.name +
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
clearable clearable
filterable filterable
class="searchSelect" class="searchSelect"
v-model="state" v-model="status"
> >
<Option :value="1">待执行</Option> <Option :value="1">待执行</Option>
<Option :value="2">执行中</Option> <Option :value="2">执行中</Option>
...@@ -296,7 +296,7 @@ export default { ...@@ -296,7 +296,7 @@ export default {
productList: [], productList: [],
taskNumber: "", taskNumber: "",
sn: "", sn: "",
state: 0, status: 0,
performType: 0, performType: 0,
startTime: [], startTime: [],
endTime: [], endTime: [],
...@@ -326,6 +326,7 @@ export default { ...@@ -326,6 +326,7 @@ export default {
complatend: this.endTime.length > 0 ? this.endTime[1] : "", complatend: this.endTime.length > 0 ? this.endTime[1] : "",
page: page, page: page,
pageSize: pagesize, pageSize: pagesize,
TaskNo: this.taskNumber,
}; };
this.axios this.axios
.request({ .request({
...@@ -399,20 +400,6 @@ export default { ...@@ -399,20 +400,6 @@ export default {
} }
); );
}, },
exportExcel() {
// this.axios.request({
// url: "/config/Download/GetTemplate?name=StorageLocation",
// method: "get",
// })
// .then((res) => {
// if (res.data.ret === 1) {
// window.location.href =
// this.axios.publicPath + "" + res.data.data;
// } else {
// this.$Message.error(this.$t(res.data.msg));
// }
// });
},
initlevel() { initlevel() {
// 初始化产线层级 // 初始化产线层级
this.axios this.axios
...@@ -454,17 +441,33 @@ export default { ...@@ -454,17 +441,33 @@ export default {
this.endTime = val; this.endTime = val;
}, },
exportExcel() { exportExcel() {
let data = {}; let params = {
section: this.sectionid,
tasktype: this.taskType,
productCode: this.productCode,
sn: this.sn,
status: this.status,
actionType: this.performType,
triggerbegin:
this.startTime.length > 0 ? this.startTime[0] : "",
triggerend: this.startTime.length > 0 ? this.startTime[1] : "",
complatebegin: this.endTime.length > 0 ? this.endTime[0] : "",
complatend: this.endTime.length > 0 ? this.endTime[1] : "",
page: this.page,
pageSize: this.pagesize,
TaskNo: this.taskNumber,
toexcel: '1'
};
this.axios this.axios
.request({ .request({
url: "", url: "/acc/AutomationState/GetTasklist",
data, params,
method: "", method: "get",
}) })
.then((res) => { .then((res) => {
if (res.data.ret === 1) { if (res.data.ret === 1) {
window.location.href = window.location.href =
axios.publicPath + "" + res.data.data; this.axios.publicPath + "" + res.data.data;
} else { } else {
this.$Message.error(this.$t(res.data.msg)); this.$Message.error(this.$t(res.data.msg));
} }
......
...@@ -690,14 +690,21 @@ export default { ...@@ -690,14 +690,21 @@ export default {
axios axios
.request({ .request({
url: url:
"/qms/InspectStandard/GetProductsBySectionId?sectionid=" + "/acc/SectionProperty/GetMonitorSnProduct?sectionid=" +
stationid, stationid,
method: "get", method: "get",
}) })
.then((res) => { .then((res) => {
if (res.data.ret == 1 && res.data.data.length > 0) { if (res.data.ret == 1 && res.data.data.id > 0) {
this.productList = res.data.data; this.productList = [
{
id:res.data.data.id,
name:res.data.data.name,
code:res.data.data.code,
}
];
this.product = this.productList[0]; this.product = this.productList[0];
this.qrcode = res.data.data.sn;
this.initmaterial(this.product.id, stationid); this.initmaterial(this.product.id, stationid);
this.inititems(); this.inititems();
} else { } else {
...@@ -715,21 +722,6 @@ export default { ...@@ -715,21 +722,6 @@ export default {
this.initproduct(this.station.id); this.initproduct(this.station.id);
this.initSn(this.station.id) this.initSn(this.station.id)
}, },
initSn(sectionid){
if (sectionid > 0) {
axios
.request({
url:
"/acc/SectionProperty/GetSn?sectionId=" + sectionid,
method: "get",
})
.then((res) => {
if (res.data.ret === 1) {
this.qrcode = res.data.data;
}
});
}
},
productchange(i) { productchange(i) {
this.c = i; this.c = i;
this.product = this.productList[i]; this.product = this.productList[i];
......
...@@ -41,10 +41,11 @@ namespace Siger.ApiACC.Controllers ...@@ -41,10 +41,11 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationFixtureToolsProductRepository _automationFixtureToolsProduct; private readonly IAutomationFixtureToolsProductRepository _automationFixtureToolsProduct;
private readonly IAutomationFixtureToolsRepository _automationFixtureTools; private readonly IAutomationFixtureToolsRepository _automationFixtureTools;
private readonly IProductRouteRepository _productRoute; private readonly IProductRouteRepository _productRoute;
private readonly IAutomationSectionPropertyRepository _automationSectionProperty;
public AutomationController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection,IAutomationLineMode automationLineMode,IAutomationMachineStatus automationMachineStatus,ISigerDict sigerDict,IAutomationTaskListRepository automationTaskList, public AutomationController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection,IAutomationLineMode automationLineMode,IAutomationMachineStatus automationMachineStatus,ISigerDict sigerDict,IAutomationTaskListRepository automationTaskList,
ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution, IAutomationFixtureMonitor automationFixtureMonitor, IAutomationLocationRepository automationLocation, IProductionBeatSetRepository productionBeatSet, IAutomationFixtureToolsProductRepository automationFixtureToolsProduct, ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution, IAutomationFixtureMonitor automationFixtureMonitor, IAutomationLocationRepository automationLocation, IProductionBeatSetRepository productionBeatSet, IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,
IAutomationFixtureToolsRepository automationFixtureTools, IProductRouteRepository productRoute) IAutomationFixtureToolsRepository automationFixtureTools, IProductRouteRepository productRoute, IAutomationSectionPropertyRepository automationSectionProperty)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection; _sigerProjectLevelSection = sigerProjectLevelSection;
...@@ -59,6 +60,7 @@ namespace Siger.ApiACC.Controllers ...@@ -59,6 +60,7 @@ namespace Siger.ApiACC.Controllers
_automationFixtureToolsProduct = automationFixtureToolsProduct; _automationFixtureToolsProduct = automationFixtureToolsProduct;
_automationFixtureTools = automationFixtureTools; _automationFixtureTools = automationFixtureTools;
_productRoute = productRoute; _productRoute = productRoute;
_automationSectionProperty = automationSectionProperty;
} }
/// <summary> /// <summary>
...@@ -69,12 +71,12 @@ namespace Siger.ApiACC.Controllers ...@@ -69,12 +71,12 @@ namespace Siger.ApiACC.Controllers
[HttpPost] [HttpPost]
public IActionResult MachineStatus([FromBody]RequestAutomationMachine request) public IActionResult MachineStatus([FromBody]RequestAutomationMachine request)
{ {
var machineAttr = _sigerProjectMachineAttribution.Get(f => f.projectid == PID && f.machine == request.machineid); var machineAttr = _sigerProjectMachineAttribution.Get(f => f.projectid == PID && f.machine == request.machineid && f.status==(int)RowState.Valid);
if (machineAttr==null) if (machineAttr==null)
{ {
throw new BadRequestException(ConfigEnum.MachineAttributionNotFound); throw new BadRequestException(ConfigEnum.MachineAttributionNotFound);
} }
var exitsObj = _automationMachineStatus.Get(f => f.machineid == request.machineid); var exitsObj = _automationMachineStatus.Get(f => f.machineid == request.machineid );
if (exitsObj==null) if (exitsObj==null)
{ {
_automationMachineStatus.Insert(new siger_automation_machine_status{ _automationMachineStatus.Insert(new siger_automation_machine_status{
...@@ -87,6 +89,7 @@ namespace Siger.ApiACC.Controllers ...@@ -87,6 +89,7 @@ namespace Siger.ApiACC.Controllers
}); });
}else }else
{ {
exitsObj.section = machineAttr.station;
exitsObj.enable = request.enable; exitsObj.enable = request.enable;
exitsObj.status = request.status; exitsObj.status = request.status;
exitsObj.updatetime = DateTime.Now; exitsObj.updatetime = DateTime.Now;
...@@ -101,31 +104,13 @@ namespace Siger.ApiACC.Controllers ...@@ -101,31 +104,13 @@ namespace Siger.ApiACC.Controllers
{ {
if (request.status == (int)Automation.MachineStatus.Waiting || request.status == (int)Automation.MachineStatus.Complated) if (request.status == (int)Automation.MachineStatus.Waiting || request.status == (int)Automation.MachineStatus.Complated)
{ {
var stationDicts = _sigerDict.GetDataByCat(AccDictCost.Automation, PID);
if (!stationDicts.Any())
{
Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典");
throw new BadRequestException(AccEnum.AutomationDictNotfound);
}
//Logger.WriteLineInfo($"设备状态更变{request.status}触发");
if (_automationTaskList.CanTask(PID, machineAttr.station)) if (_automationTaskList.CanTask(PID, machineAttr.station))
{ {
var uploadStation = stationDicts.Where(f => f.dkey == DictKeyValConst.UploadloadStation); var section = _sigerProjectLevelSection.Get(f => f.id == machineAttr.station);
var uploadStations = uploadStation.Select(f => f.dval.ToInt()).ToList(); if (section != null)
if (!uploadStations.Contains(machineAttr.station))
{ {
var tasklist = _automationTaskList.GetList(f => f.projectId == PID && f.status < (int)TaskResultStatus.Complated); Logger.WriteLineInfo($"MachineStatus 设备 {section.title}状态 触发自动任务检查");
AutoProcess(section.parentid);
if (!tasklist.Any())
{
var section = _sigerProjectLevelSection.Get(f => f.id == machineAttr.station);
if (section != null)
{
Logger.WriteLineInfo($"MachineStatus 设备 {section.title}状态 触发自动任务检查");
AutoProcess(section.parentid, stationDicts);
}
}
} }
} }
} }
...@@ -172,20 +157,11 @@ namespace Siger.ApiACC.Controllers ...@@ -172,20 +157,11 @@ namespace Siger.ApiACC.Controllers
{ {
//TODO //TODO
//手动-》自动 时 //手动-》自动 时
//task 无任务时候 ,根据设备状态创建任务
var stationDicts = _sigerDict.GetDataByCat(AccDictCost.Automation, PID);
if (!stationDicts.Any())
{
Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典");
throw new BadRequestException(AccEnum.AutomationDictNotfound);
}
var tasklist = _automationTaskList.GetList(f => f.projectId == PID && f.status < (int)TaskResultStatus.Complated); var tasklist = _automationTaskList.GetList(f => f.projectId == PID && f.status < (int)TaskResultStatus.Complated);
if (!tasklist.Any()) if (!tasklist.Any())
{ {
Logger.WriteLineInfo($"LineMode Mode=1 触发自动任务检查"); Logger.WriteLineInfo($"LineMode Mode=1 触发自动任务检查");
AutoProcess(line, stationDicts); AutoProcess(line);
} }
} }
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
...@@ -236,15 +212,9 @@ namespace Siger.ApiACC.Controllers ...@@ -236,15 +212,9 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(AccEnum.AutoTaskDone); throw new BadRequestException(AccEnum.AutoTaskDone);
} }
var stationDicts = _sigerDict.GetDataByCat(AccDictCost.Automation, PID);
if (!stationDicts.Any())
{
Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典");
throw new BadRequestException(AccEnum.AutomationDictNotfound);
}
//更新Tasklist //更新Tasklist
PlCfeeback(taskObj, request.status, stationDicts); PlCfeeback(taskObj, request.status);
if (_unitOfWork.Commit() <= 0) if (_unitOfWork.Commit() <= 0)
{ {
...@@ -261,13 +231,13 @@ namespace Siger.ApiACC.Controllers ...@@ -261,13 +231,13 @@ namespace Siger.ApiACC.Controllers
if (section != null) if (section != null)
{ {
Logger.WriteLineInfo($" 设备{section.title} 任务编号:{taskObj.no} 状态:{request.status} "); Logger.WriteLineInfo($" 设备{section.title} 任务编号:{taskObj.no} 状态:{request.status} ");
AutoProcess(section.parentid, stationDicts, taskObj); AutoProcess(section.parentid, taskObj);
} }
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
void PlCfeeback(siger_automation_task_list taskObj,int status, IEnumerable<SigerTrDict> stationDicts) void PlCfeeback(siger_automation_task_list taskObj,int status )
{ {
//2.更新状态 //2.更新状态
taskObj.status = status; taskObj.status = status;
...@@ -275,23 +245,29 @@ namespace Siger.ApiACC.Controllers ...@@ -275,23 +245,29 @@ namespace Siger.ApiACC.Controllers
_automationTaskList.Update(taskObj); _automationTaskList.Update(taskObj);
var monitor = _automationFixtureMonitor.Get(f => f.section == taskObj.sectionid); var monitor = _automationFixtureMonitor.Get(f => f.section == taskObj.sectionid);
var sectionProperty = _automationSectionProperty.Get(f => f.sectionid == taskObj.sectionid);
if(sectionProperty==null)
{
Logger.WriteLineInfo($"PlCfeeback 设备属性为维护");
throw new BadRequestException(AccEnum.SectionPropertyNull);
}
//PLC 反馈结束. //PLC 反馈结束.
if (status == (int)TaskResultStatus.Complated) if (status == (int)TaskResultStatus.Complated)
{ {
var uploadStation = stationDicts.Where(f => f.dkey == DictKeyValConst.UploadloadStation); var location = _automationLocation.Get(f => f.fixturetools == taskObj.fixtureguid && f.locationid == taskObj.locationid);
var uploadStations = uploadStation.Select(f => f.dval).ToList(); if (location == null)
{
Logger.WriteLineInfo($"PlCfeeback 未找到该工装储位信息");
throw new BadRequestException(AccEnum.MachineDisable);
}
if (taskObj.action == TaskAction.Step_SXLW_LK) // 业务入口: 上料位-》 入库 如果是上料工装 安装完成 ,绑定 储位与装配
if (sectionProperty.propertytype == 1)
{ {
// 业务入口: 上料位-》 入库 如果是上料工装 安装完成 ,绑定 储位与装配
if (uploadStations.Exists(f => f.Contains(taskObj.sectionid.ToString()))) //绑定SN 工件到立库储位
if (taskObj.action == TaskAction.Step_SXLW_LK)
{ {
var location = _automationLocation.Get(f => f.fixturetools == taskObj.fixtureguid);
if (location == null)
{
Logger.WriteLineInfo($"PlCfeeback 未找到该工装储位信息");
throw new BadRequestException(AccEnum.MachineDisable);
}
location.fixturetools = taskObj.fixtureguid; location.fixturetools = taskObj.fixtureguid;
location.fixturename = taskObj.fixturename; location.fixturename = taskObj.fixturename;
location.ordernumber = taskObj.ordercode; location.ordernumber = taskObj.ordercode;
...@@ -302,20 +278,60 @@ namespace Siger.ApiACC.Controllers ...@@ -302,20 +278,60 @@ namespace Siger.ApiACC.Controllers
location.status = (int)LocationStatus.In; location.status = (int)LocationStatus.In;
_automationLocation.Update(location); _automationLocation.Update(location);
} }
//从立库储位拿SN 工件到上料位
if (taskObj.action==TaskAction.Step_LK_SXLW)
{
//location.sn = "";
location.status = (int)LocationStatus.Out;
_automationLocation.Update(location);
}
} }
if (monitor != null && taskObj.action == TaskAction.Step_SXLW_LK) // CNC 设备
if (sectionProperty.propertytype == 2)
{ {
monitor.section = 0; if (taskObj.action== TaskAction.Step_LK_JGZX )
{
location.status = (int)LocationStatus.Out;
_automationLocation.Update(location);
}
} }
//抽检台
if (sectionProperty.propertytype == 3)
{
if (taskObj.action == TaskAction.Step_LK_CJT)
{
location.status = (int)LocationStatus.Out;
_automationLocation.Update(location);
//上料上下料设备状态为后台控制,CNC是PLC控制 }
var machineStatus = _automationMachineStatus.Get(f => f.section == taskObj.sectionid && f.auto==0);
if (machineStatus != null) }
//清洗机
if (sectionProperty.propertytype==4)
{ {
machineStatus.status = (int)Automation.MachineStatus.Waiting; if(taskObj.action==TaskAction.Step_QXJ_LK)
_automationMachineStatus.Update(machineStatus); {
//上料 指定的第一道工序
var route = _productRoute.GetList(f => f.productId == taskObj.productid && f.status == (int)RowState.Valid, "serialNumber", true).FirstOrDefault();
if (route == null)
{
throw new BadRequestException(AccEnum.ProductRouteMissing);
}
if (route.id == location.routeid)
{
Logger.WriteLineInfo($"PlCfeeback 工装储位{taskObj.locationid} 工序{location.routeid}-{location.routenum}完成");
//最后一道工序
location.routeid = 0;
location.status = (int)LocationStatus.In;
_automationLocation.Update(location);
}
else
{
Logger.WriteLineInfo($"PlCfeeback 工装储位{taskObj.locationid} 工序{location.routeid}-{location.routenum}为完成");
}
}
} }
} }
if (monitor != null) if (monitor != null)
...@@ -335,7 +351,7 @@ namespace Siger.ApiACC.Controllers ...@@ -335,7 +351,7 @@ namespace Siger.ApiACC.Controllers
/// <param name="fixture"></param> /// <param name="fixture"></param>
/// <param name="stationDicts"></param> /// <param name="stationDicts"></param>
/// <param name="tasklist"></param> /// <param name="tasklist"></param>
void AutoProcess(int line,IEnumerable<SigerTrDict> stationDicts,siger_automation_task_list tasklist=null) void AutoProcess(int line ,siger_automation_task_list tasklist=null)
{ {
var lineMode = _automationLineMode.Get(f => f.projectId == PID && f.section == line); var lineMode = _automationLineMode.Get(f => f.projectId == PID && f.section == line);
if (lineMode==null) if (lineMode==null)
...@@ -355,24 +371,33 @@ namespace Siger.ApiACC.Controllers ...@@ -355,24 +371,33 @@ namespace Siger.ApiACC.Controllers
//2.其他设备上料 //2.其他设备上料
//3.其他设备下料 //3.其他设备下料
*/ */
var updownDic= stationDicts.Where(s => s.dkey == DictKeyValConst.UploadloadStation);
var uploadStations = updownDic.Select(f => f.dval.ToInt()).ToList();
/* 自动任务创建只有CNC 设备;排除上料设备(手动任务) */ ///* 自动任务创建只有CNC 设备;排除上料设备(手动任务) */
var dictClean = stationDicts.FirstOrDefault(s=>s.dkey==DictKeyValConst.CleanStation);
if (dictClean==null) var sectionPropertys = _automationSectionProperty.GetList(f => f.projectId == PID).ToList();
if (!sectionPropertys.Any())
{ {
Logger.WriteLineInfo($"AutoProcess 未配置清洗机字典"); Logger.WriteLineInfo($"AutoProcess 设备属性未配置");
return; return;
} }
var cncStations = sectionPropertys.Where(s=>s.propertytype==2).Select(s => s.sectionid).ToList();
// 获取可用 设备状态列表 排除上料工位 // 获取可用 设备状态列表 排除上料工位
var machineStatusList = _automationMachineStatus.GetList(f => f.projectId == PID && f.auto==1 && !uploadStations.Contains(f.section) && f.enable == 1); var machineStatusList = _automationMachineStatus.GetList(f => f.projectId == PID && cncStations.Contains(f.section) && f.enable == 1);
if (!machineStatusList.Any()) if (!machineStatusList.Any())
{ {
Logger.WriteLineInfo($"AutoProcess 无可用状态的设备"); Logger.WriteLineInfo($"AutoProcess 无可用状态的设备");
return; return;
} }
//优先级1 :清洗机完成 。待下料 //优先级1 :清洗机完成 。待下料
var cleanMachine = machineStatusList.FirstOrDefault(f => f.section == dictClean.dval.ToInt());
var cleanProperty = sectionPropertys.FirstOrDefault(f=>f.propertytype == 4);
if (cleanProperty==null)
{
Logger.WriteLineInfo($"AutoProcess 设备属性清洗机未配置");
return;
}
var cleanMachine = _automationMachineStatus.Get(f => f.section == cleanProperty.sectionid);
if (cleanMachine!=null) if (cleanMachine!=null)
{ {
if (cleanMachine.status == (int)Automation.MachineStatus.Complated) if (cleanMachine.status == (int)Automation.MachineStatus.Complated)
...@@ -381,22 +406,41 @@ namespace Siger.ApiACC.Controllers ...@@ -381,22 +406,41 @@ namespace Siger.ApiACC.Controllers
if (tasklist == null) if (tasklist == null)
{ {
Logger.WriteLineError($"AutoProcess Tasklist 为空"); Logger.WriteLineError($"AutoProcess Tasklist 为空");
return;
Logger.WriteLineError($"AutoProcess Tasklist 为空,查找设备Monitor{cleanMachine.section }状态");
var machineMonitor = _automationFixtureMonitor.Get(f => f.section == cleanMachine.section);
if (machineMonitor == null)
{
Logger.WriteLineError($"AutoProcess 清洗机{cleanMachine.section}machineMonitor 为空");
return;
}
CreateTask(cleanMachine.section, TaskActionType.Unload, TaskAction.Step_QXJ_LK, machineMonitor.fixtureguid, machineMonitor.ordernumber, machineMonitor.sn, "", machineMonitor.productId, machineMonitor.productCode, machineMonitor.locationId, machineMonitor.route);
} }
var locationObj = _automationLocation.Get(f =>f.projectId==PID&& f.locationid == tasklist.locationid); else
if (locationObj==null)
{ {
Logger.WriteLineError($"AutoProcess 立库 为空"); var locationObj = _automationLocation.Get(f => f.projectId == PID && f.locationid == tasklist.locationid);
return; if (locationObj == null)
} {
//工件回到立库 Logger.WriteLineError($"AutoProcess 立库 为空");
locationObj.status = (int)LocationStatus.In; return;
_automationLocation.Update(locationObj); }
//工件回到立库
locationObj.status = (int)LocationStatus.In;
_automationLocation.Update(locationObj);
CreateTask(cleanMachine.section, TaskActionType.Unload, TaskAction.Step_QXJ_LK, tasklist.fixtureguid, tasklist.ordercode, tasklist.sn, "无程序", tasklist.productid, tasklist.productcode, tasklist.locationid, tasklist.route); CreateTask(cleanMachine.section, TaskActionType.Unload, TaskAction.Step_QXJ_LK, tasklist.fixtureguid, tasklist.ordercode, tasklist.sn, "无程序", tasklist.productid, tasklist.productcode, tasklist.locationid, tasklist.route);
return; //完成当前任务 退出 return; //完成当前任务 退出
}
}
else
{
Logger.WriteLineInfo($"AutoProcess 清洗机未完成");
} }
} }
else
{
Logger.WriteLineInfo($"AutoProcess 清洗机没找到");
}
//优先级2 :其他设备待上料 (立库->加工中心) //优先级2 :其他设备待上料 (立库->加工中心)
var freeMachine = machineStatusList.Where(f=>f.status==(int)Automation.MachineStatus.Waiting); var freeMachine = machineStatusList.Where(f=>f.status==(int)Automation.MachineStatus.Waiting);
if (freeMachine != null) if (freeMachine != null)
...@@ -438,15 +482,51 @@ namespace Siger.ApiACC.Controllers ...@@ -438,15 +482,51 @@ namespace Siger.ApiACC.Controllers
if (cleanMachine != null) if (cleanMachine != null)
{ {
var fullMachine = machineStatusList.FirstOrDefault(f => f.status == (int)Automation.MachineStatus.Complated); var fullMachine = machineStatusList.FirstOrDefault(f => f.status == (int)Automation.MachineStatus.Complated);
if (fullMachine != null && cleanMachine.status==(int)Automation.MachineStatus.Waiting) if (fullMachine != null && cleanMachine.status == (int)Automation.MachineStatus.Waiting)
{ {
Logger.WriteLineError($"AutoProcess 清洗机空闲,创建普通设备下料到清洗机Task "); Logger.WriteLineError($"AutoProcess 清洗机空闲,创建普通设备下料到清洗机Task ");
if (tasklist==null) //更新清洗机监控
var monitor = _automationFixtureMonitor.Get(cleanMachine.section);
if (monitor == null)
{ {
Logger.WriteLineError($"AutoProcess Tasklist 为空"); _automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
return; {
section = cleanMachine.section,
fixtureguid = tasklist.fixtureguid,
fixturename = tasklist.fixturename,
productCode = tasklist.productcode,
productId = tasklist.productid,
locationId = tasklist.locationid,
ordernumber = tasklist.ordercode,
productName = tasklist.productname,
projectId = tasklist.projectId,
taskno = tasklist.no,
route = tasklist.route,
sn = tasklist.sn,
updatetime = DateTime.Now,
status = 1,
createtime = DateTime.Now,
});
}
else
{
monitor.fixtureguid = tasklist.fixtureguid;
monitor.fixturename = tasklist.fixturename;
monitor.productCode = tasklist.productcode;
monitor.productId = tasklist.productid;
monitor.locationId = tasklist.locationid;
monitor.ordernumber = tasklist.ordercode;
monitor.productName = tasklist.productname;
monitor.projectId = tasklist.projectId;
monitor.taskno = tasklist.no;
monitor.route = tasklist.route;
monitor.sn = tasklist.sn;
monitor.updatetime = DateTime.Now;
monitor.status = tasklist.status;
} }
CreateTask(fullMachine.section,TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, tasklist.fixtureguid,tasklist.ordercode, tasklist.sn,tasklist.programnumber,tasklist.productid,tasklist.productcode,tasklist.locationid,tasklist.route); //创建CNC 下料到清洗机
CreateTask(fullMachine.section, TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, tasklist.fixtureguid, tasklist.ordercode, tasklist.sn, tasklist.programnumber, tasklist.productid, tasklist.productcode, tasklist.locationid, tasklist.route);
return; //完成当前任务 退出 return; //完成当前任务 退出
} }
...@@ -491,8 +571,7 @@ namespace Siger.ApiACC.Controllers ...@@ -491,8 +571,7 @@ namespace Siger.ApiACC.Controllers
ordercode= orderno, ordercode= orderno,
sn= sn, sn= sn,
remark= EnumHelper.GetEnumDesc(taskAction), remark= EnumHelper.GetEnumDesc(taskAction),
route=route route=route,
}); });
var monitor = _automationFixtureMonitor.Get(f => f.section == section); var monitor = _automationFixtureMonitor.Get(f => f.section == section);
if (monitor == null) if (monitor == null)
...@@ -510,7 +589,7 @@ namespace Siger.ApiACC.Controllers ...@@ -510,7 +589,7 @@ namespace Siger.ApiACC.Controllers
route=route, route=route,
status=1, status=1,
sn=sn, sn=sn,
taskno=taskNo, taskno=taskNo,
}); });
} }
else else
...@@ -541,36 +620,62 @@ namespace Siger.ApiACC.Controllers ...@@ -541,36 +620,62 @@ namespace Siger.ApiACC.Controllers
var TempList = new List<ResponseAutoRouteInfo>(); var TempList = new List<ResponseAutoRouteInfo>();
foreach (var b in beats) foreach (var b in beats)
{ {
var autoLocation = _automationLocation.Get(f => f.projectId == b.projectID && !string.IsNullOrEmpty(f.sn) && f.routeid == b.route_number.ToInt() && f.productid == b.product_name.ToInt()); Logger.WriteLineError($"SelectLocation 设备{b.machineID}标准节拍{b.route_number}{b.route_name}");
if (autoLocation == null) var autoLocationIds = _automationLocation.GetList(f => f.projectId == b.projectID && f.routeid == b.route_number.ToInt() && f.productid == b.product_name.ToInt());
continue; if (!autoLocationIds.Any())
if(autoLocation.status==2)
{ {
//SN不在立库内 Logger.WriteLineError($"SelectLocation 设备{b.machineID} routeid:{b.route_number}-{b.route_name}productId:{b.product_name} 没有匹配到当前储位");
Logger.WriteLineError($"SelectLocation 当前储位工件不在储位上");
continue; continue;
} }
TempList.Add(new ResponseAutoRouteInfo foreach (var autoLocation in autoLocationIds)
{ {
FixtureGuid=autoLocation.fixturetools, if (string.IsNullOrEmpty(autoLocation.sn))
FixtureName=autoLocation.fixturename, {
Section=b.section_id, Logger.WriteLineError($"SelectLocation 设备{b.machineID} routeid:{b.route_number}-{b.route_name}productId:{b.product_name} 储位{autoLocation.locationid}没有SN工件");
Machine=b.machineID, continue;
Pn=b.process_number, }
ProductId=b.product_name.ToInt(), if (autoLocation.status == 2)
ProductName=b.product_name_text, {
Location=autoLocation.locationid, //SN不在立库内
Route=b.route_number.ToInt(), Logger.WriteLineError($"SelectLocation 设备{b.machineID} routeid:{b.route_number}-{b.route_name}productId:{b.product_name} 储位{autoLocation.locationid}工件Sn:{autoLocation.sn}不在储位上");
RouteName=b.route_name, continue;
OrderNo=autoLocation.ordernumber, }
Sn=autoLocation.sn, if(autoLocation.routeid==0)
LId=autoLocation.id {
}); Logger.WriteLineError($"SelectLocation 有效订单号{autoLocation.ordernumber} 工序{b.route_number}-{b.route_name}完成");
continue;
}
Logger.WriteLineError($"SelectLocation 有效订单号{autoLocation.ordernumber} beasetId:{b.id}工序{b.route_number}-{b.route_name}");
TempList.Add(new ResponseAutoRouteInfo
{
FixtureGuid = autoLocation.fixturetools,
FixtureName = autoLocation.fixturename,
Section = b.section_id,
Machine = b.machineID,
Pn = b.process_number,
ProductId = b.product_name.ToInt(),
ProductCode=autoLocation.productcode,
ProductName = b.product_name_text,
Location = autoLocation.locationid,
Route = b.route_number.ToInt(),
RouteName = b.route_name,
OrderNo = autoLocation.ordernumber,
Sn = autoLocation.sn,
LId = autoLocation.id
});
Logger.WriteLineError($"SelectLocation 有效订单号{autoLocation.ordernumber}");
}
}
if (!TempList.Any())
{
Logger.WriteLineError($"SelectLocation 没有匹配到有效订单号");
return null;
} }
var ordernos = TempList.Select(f => f.OrderNo).ToList(); var ordernos = TempList.Select(f => f.OrderNo).ToList();
// 取产品交期最近的订单 // 取产品交期最近的订单
var planOrder = _automationFixtureToolsProduct.GetDeliveryOrder(ordernos, PID); var planOrder = _automationFixtureToolsProduct.GetDeliveryOrder(ordernos, PID);
...@@ -591,7 +696,7 @@ namespace Siger.ApiACC.Controllers ...@@ -591,7 +696,7 @@ namespace Siger.ApiACC.Controllers
ordernumber =result.OrderNo, ordernumber =result.OrderNo,
location=result.Location, location=result.Location,
productId=result.ProductId, productId=result.ProductId,
//productCode=result.productcode, productCode = result.ProductCode,
productName = result.ProductName, productName = result.ProductName,
sn =result.Sn, sn =result.Sn,
pn= result.Pn, pn= result.Pn,
......
...@@ -23,6 +23,7 @@ using Siger.Middlelayer.Common.Helpers; ...@@ -23,6 +23,7 @@ using Siger.Middlelayer.Common.Helpers;
using Newtonsoft.Json; using Newtonsoft.Json;
using NPOI.SS.Formula; using NPOI.SS.Formula;
using static Siger.Middlelayer.Share.Enum.ModuleEnum.Automation; using static Siger.Middlelayer.Share.Enum.ModuleEnum.Automation;
using Siger.ApiCommon.Result;
namespace Siger.ApiACC.Controllers namespace Siger.ApiACC.Controllers
{ {
...@@ -43,10 +44,11 @@ namespace Siger.ApiACC.Controllers ...@@ -43,10 +44,11 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationLocationRepository _automationLocation; private readonly IAutomationLocationRepository _automationLocation;
private readonly IAutomationLineMode _automationLine; private readonly IAutomationLineMode _automationLine;
private readonly IProductRouteRepository _productRoute; private readonly IProductRouteRepository _productRoute;
private readonly IAutomationSectionPropertyRepository _sectionPropertyRepository;
public AutomationOperateController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection , ISigerDict sigerDict,IAutomationMachineStatus automationMachineStatus,ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution,IAutomationTaskListRepository automationTaskList, public AutomationOperateController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection , ISigerDict sigerDict,IAutomationMachineStatus automationMachineStatus,ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution,IAutomationTaskListRepository automationTaskList,
IProductPlanDetails planDetails,IProductPlanRepository productPlan,IAutomationFixtureMonitor automationFixtureMonitor ,IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,IAutomationFixtureToolsRepository automationFixtureTools, IAutomationLocationRepository automationLocation, IProductPlanDetails planDetails,IProductPlanRepository productPlan,IAutomationFixtureMonitor automationFixtureMonitor ,IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,IAutomationFixtureToolsRepository automationFixtureTools, IAutomationLocationRepository automationLocation,
IAutomationLineMode automationLine, IProductRouteRepository productRoute) IAutomationLineMode automationLine, IProductRouteRepository productRoute, IAutomationSectionPropertyRepository sectionPropertyRepository)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection; _sigerProjectLevelSection = sigerProjectLevelSection;
...@@ -62,6 +64,7 @@ namespace Siger.ApiACC.Controllers ...@@ -62,6 +64,7 @@ namespace Siger.ApiACC.Controllers
_automationLocation = automationLocation; _automationLocation = automationLocation;
_automationLine = automationLine; _automationLine = automationLine;
_productRoute = productRoute; _productRoute = productRoute;
_sectionPropertyRepository = sectionPropertyRepository;
} }
/// <summary> /// <summary>
...@@ -79,70 +82,53 @@ namespace Siger.ApiACC.Controllers ...@@ -79,70 +82,53 @@ namespace Siger.ApiACC.Controllers
Logger.WriteLineInfo($"GetloadStation 未配置设备类型字典"); Logger.WriteLineInfo($"GetloadStation 未配置设备类型字典");
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
} }
var loadStation=new List<string>(); var loadStation=new List<string>();
//上下料
if (type==0) if (type==0)
{ {
var dictLoad = stationDicts.Where(s => s.dkey == DictKeyValConst.UploadloadStation); var sectionProperty = _sectionPropertyRepository.GetList(f => f.propertytype == 1);
if (!dictLoad.Any()) var sections = sectionProperty.Select(s => s.sectionid).ToList();
var levelSection = _sigerProjectLevelSection.GetList(f => f.parentid == line && sections.Contains(f.id));
if (!levelSection.Any())
{ {
Logger.WriteLineInfo($"GetloadStation 未配置上下料工站字典");
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
} }
loadStation = dictLoad.Select(s => s.dval).ToList(); var result = new List<ResponseLoadStation>();
}else foreach (var lv in levelSection)
{
var dictLoad = stationDicts.Where(s => s.dkey == DictKeyValConst.CleanStation);
if (!dictLoad.Any())
{ {
Logger.WriteLineInfo($"GetloadStation 未配置清洗工站字典"); result.Add(new ResponseLoadStation
throw new BadRequestException(CommonEnum.RecordNotFound); {
section=lv.id,
status=1,
title=lv.title,
});
} }
loadStation = dictLoad.Select(s => s.dval).ToList(); return new ObjectResult(result);
//检验
} }
else
var data = new List<ResponseLoadStation>();
foreach (var station in loadStation)
{ {
var section = _sigerProjectLevelSection.Get(f => f.id == station.ToInt() && f.parentid==line && f.status == (int)RowState.Valid); var sectionProperty = _sectionPropertyRepository.GetList(f => f.propertytype == 3);
if (section == null) var sections = sectionProperty.Select(s => s.sectionid).ToList();
continue; var levelSection = _sigerProjectLevelSection.GetList(f => f.parentid == line && sections.Contains(f.id));
var machintAttr = _sigerProjectMachineAttribution.Get(f => f.station == section.id); if (!levelSection.Any())
if(machintAttr==null)
{ {
Logger.WriteLineInfo($"GetloadStation 未配置工站字典"); throw new BadRequestException(CommonEnum.RecordNotFound);
continue;
} }
var loadStatus = (int)Automation.MachineStatus.Waiting; var result = new List<ResponseLoadStation>();
var machineStatus = _automationMachineStatus.Get(f => f.section == section.id); foreach (var lv in levelSection)
if (machineStatus==null)
{ {
_automationMachineStatus.Insert(new siger_automation_machine_status result.Add(new ResponseLoadStation
{ {
projectId=ProjectId, section = lv.id,
enable=1, status = 1,
machineid=machintAttr.machine, title = lv.title,
section=section.id,
updatetime=DateTime.Now
});
}else
{
loadStatus = machineStatus.status; });
} }
data.Add(new ResponseLoadStation { return new ObjectResult(result);
section=section.id,
title=section.title,
status=loadStatus
});
} }
_unitOfWork.Commit();
return new ObjectResult(data);
} }
...@@ -201,7 +187,14 @@ namespace Siger.ApiACC.Controllers ...@@ -201,7 +187,14 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(AccEnum.LineIsAutoMode); throw new BadRequestException(AccEnum.LineIsAutoMode);
} }
var attr = _sigerProjectMachineAttribution.Get(f => f.station == taskobj.sectionid && f.status == 1); var section = taskobj.sectionid;
//抽检台-》上料位特殊逻辑
if (taskobj.action == Automation.TaskAction.Step_CJT_SXLW)
{
section = taskobj.extend1.ToInt();
}
var attr = _sigerProjectMachineAttribution.Get(f => f.station == section && f.status == 1);
if (attr==null) if (attr==null)
{ {
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
...@@ -226,14 +219,14 @@ namespace Siger.ApiACC.Controllers ...@@ -226,14 +219,14 @@ namespace Siger.ApiACC.Controllers
RobotStep = (int)taskobj.action, RobotStep = (int)taskobj.action,
StorageNo = taskobj.locationid, StorageNo = taskobj.locationid,
SN = taskobj.sn, SN = taskobj.sn,
Program = taskobj.programnumber Program = taskobj.programnumber,
TaskType=(int)taskobj.tasktype
}; };
var result = PushTask(host, sendToPLC, out string message); var result = PushTask(host, sendToPLC, out string message);
if (!result) if (!result)
{ {
Logger.WriteLineError($"TASK 下发失败 : {message}"); return new ImportObjectResult((int)CommonEnum.Fail, message);
throw new BadRequestException(CommonEnum.Fail);
} }
taskobj.send = 1; taskobj.send = 1;
_automationTaskList.Update(taskobj); _automationTaskList.Update(taskobj);
...@@ -340,10 +333,6 @@ namespace Siger.ApiACC.Controllers ...@@ -340,10 +333,6 @@ namespace Siger.ApiACC.Controllers
updatetime = DateTime.Now updatetime = DateTime.Now
}); });
} }
if (machineStatus.auto==1)
{
throw new BadRequestException(AccEnum.MachineDisable);
}
var plandts = _planDetails.Get(f => f.projectId == ProjectId && f.OrderNumber == loading.code); var plandts = _planDetails.Get(f => f.projectId == ProjectId && f.OrderNumber == loading.code);
if (plandts==null) if (plandts==null)
...@@ -362,10 +351,15 @@ namespace Siger.ApiACC.Controllers ...@@ -362,10 +351,15 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(AccEnum.FixtureToolsIsNone); throw new BadRequestException(AccEnum.FixtureToolsIsNone);
} }
var exitsUpload = _automationTaskList.Get(f => f.send == 0 && f.locationid == loading.locationid); var monitor = _automationFixtureMonitor.Get(f => f.section == loading.section);
if (exitsUpload!=null) if (monitor != null)
{ {
throw new BadRequestException(AccEnum.FixtureOrderNulll); var exitsUpload = _automationTaskList.Get(f =>f.no==monitor.taskno);
if (exitsUpload != null)
{
if (exitsUpload.status != (int)Automation.TaskResultStatus.Complated)
throw new BadRequestException(AccEnum.TaskProcessing);
}
} }
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual); var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
var sn = _automationTaskList.CreateRandonSn(plan.product_code); var sn = _automationTaskList.CreateRandonSn(plan.product_code);
...@@ -408,7 +402,6 @@ namespace Siger.ApiACC.Controllers ...@@ -408,7 +402,6 @@ namespace Siger.ApiACC.Controllers
}); });
var monitor = _automationFixtureMonitor.Get(f => f.fixtureguid == fixtureToolsObj.FixtureGuid);
if (monitor==null) if (monitor==null)
{ {
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor _automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
...@@ -482,16 +475,23 @@ namespace Siger.ApiACC.Controllers ...@@ -482,16 +475,23 @@ namespace Siger.ApiACC.Controllers
{ {
machineStatus.status = (int)Automation.MachineStatus.Waiting; machineStatus.status = (int)Automation.MachineStatus.Waiting;
} }
//创建 安装完成动作
var monitor = _automationFixtureMonitor.Get(f => f.projectId == ProjectId && f.section == assemble.section); var monitor = _automationFixtureMonitor.Get(f => f.projectId == ProjectId && f.section == assemble.section);
if (monitor==null) if (monitor==null)
{ {
throw new BadRequestException(AccEnum.MonitorNotfound); throw new BadRequestException(AccEnum.MonitorNotfound);
} }
var tasklist = _automationTaskList.Get(f => f.projectId == ProjectId && f.no == monitor.taskno);
if(tasklist==null)
{
throw new BadRequestException(AccEnum.MachineDisable);
}
if (tasklist.status!=(int)Automation.TaskResultStatus.Complated)
{
throw new BadRequestException(AccEnum.TaskProcessing);
}
//检测工序是否配置正确 //检测工序是否配置正确
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual); var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
{ {
...@@ -552,9 +552,12 @@ namespace Siger.ApiACC.Controllers ...@@ -552,9 +552,12 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(AccEnum.LocationNoSn); throw new BadRequestException(AccEnum.LocationNoSn);
} }
if (location.status==(int)Automation.LocationStatus.Out)
{
throw new BadRequestException(AccEnum.LocationNoSn);
}
var levelSection = _sigerProjectLevelSection.Get(f => f.id == unloading.section); var levelSection = _sigerProjectLevelSection.Get(f => f.id == unloading.section);
var lineMode = _automationLine.Get(f => f.section ==levelSection.parentid); var lineMode = _automationLine.Get(f => f.section ==levelSection.parentid);
if (lineMode==null) if (lineMode==null)
{ {
throw new BadRequestException(AccEnum.LineModeNotfound); throw new BadRequestException(AccEnum.LineModeNotfound);
...@@ -569,8 +572,17 @@ namespace Siger.ApiACC.Controllers ...@@ -569,8 +572,17 @@ namespace Siger.ApiACC.Controllers
//1. 有检验状态 (立库-》检验工位) //1. 有检验状态 (立库-》检验工位)
//2. 无检验状态 (立库-》上下料工位) //2. 无检验状态 (立库-》上下料工位)
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual); var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
var action = lineMode.inspect == 1 ? Automation.TaskAction.Step_LK_CJT : Automation.TaskAction.Step_LK_SXLW; var action = lineMode.inspect == 1 ? Automation.TaskAction.Step_LK_CJT : Automation.TaskAction.Step_LK_SXLW;
var section = unloading.section;
if (lineMode.inspect==1)
{
var sectionProperty = _sectionPropertyRepository.Get(f => f.propertytype == 3);
if(sectionProperty==null)
{
throw new BadRequestException(AccEnum.SectionPropertyNull);
}
section = sectionProperty.sectionid;
}
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
{ {
no = taskNo, no = taskNo,
...@@ -594,11 +606,11 @@ namespace Siger.ApiACC.Controllers ...@@ -594,11 +606,11 @@ namespace Siger.ApiACC.Controllers
productcode = location.productcode, productcode = location.productcode,
processid = 0, processid = 0,
programnumber = "", programnumber = "",
remark = "手动任务-准备下料", remark =lineMode.inspect==1? "准备下料-》抽检台":"准备下料",
extend1= unixtime.ToStr() extend1= unixtime.ToStr()
}); });
var monitor = _automationFixtureMonitor.Get(f => f.section == unloading.section); var monitor = _automationFixtureMonitor.Get(f => f.section == section);
if (monitor == null) if (monitor == null)
{ {
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor _automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
...@@ -606,7 +618,7 @@ namespace Siger.ApiACC.Controllers ...@@ -606,7 +618,7 @@ namespace Siger.ApiACC.Controllers
fixtureguid = location.fixturetools, fixtureguid = location.fixturetools,
fixturename = location.fixturename, fixturename = location.fixturename,
projectId = ProjectId, projectId = ProjectId,
section = unloading.section, section = section,
sn = location.sn, sn = location.sn,
createtime = DateTime.Now, createtime = DateTime.Now,
updatetime = DateTime.Now, updatetime = DateTime.Now,
...@@ -654,20 +666,6 @@ namespace Siger.ApiACC.Controllers ...@@ -654,20 +666,6 @@ namespace Siger.ApiACC.Controllers
[HttpPost] [HttpPost]
public IActionResult Disassemble([FromBody]Requestdisassemble disassemble) public IActionResult Disassemble([FromBody]Requestdisassemble disassemble)
{ {
var machineStatus = _automationMachineStatus.Get(f => f.section == disassemble.section);
if (machineStatus == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
if (machineStatus.enable == 0)
{
throw new BadRequestException(AccEnum.MachineDisable);
}
if (machineStatus.auto==0)
{
machineStatus.status = 1;
}
if (!_automationTaskList.CanTask(ProjectId, disassemble.section)) if (!_automationTaskList.CanTask(ProjectId, disassemble.section))
{ {
throw new BadRequestException(AccEnum.TaskProcessing); throw new BadRequestException(AccEnum.TaskProcessing);
...@@ -678,7 +676,25 @@ namespace Siger.ApiACC.Controllers ...@@ -678,7 +676,25 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(AccEnum.MonitorNotfound); throw new BadRequestException(AccEnum.MonitorNotfound);
} }
var tasklist = _automationTaskList.Get(f => f.no == monitor.taskno);
if (tasklist==null)
{
throw new BadRequestException(AccEnum.MachineDisable);
}
var location = _automationLocation.Get(f => f.id == monitor.locationId); var location = _automationLocation.Get(f => f.id == monitor.locationId);
if (location==null)
{
throw new BadRequestException(AccEnum.LocationNoSn);
}
if (string.IsNullOrEmpty(location.sn))
{
throw new BadRequestException(AccEnum.LocationNoSn);
}
if(location.status== (int)LocationStatus.Out)
{
throw new BadRequestException(AccEnum.LocationNoSn);
}
if (location!=null) if (location!=null)
{ {
location.sn = ""; location.sn = "";
...@@ -713,7 +729,7 @@ namespace Siger.ApiACC.Controllers ...@@ -713,7 +729,7 @@ namespace Siger.ApiACC.Controllers
}); });
//移出 上料位 //移出 上料位
monitor.section = 0;
monitor.taskno = taskNo; monitor.taskno = taskNo;
_automationFixtureMonitor.Update(monitor); _automationFixtureMonitor.Update(monitor);
......
...@@ -12,6 +12,11 @@ using Siger.Middlelayer.Common; ...@@ -12,6 +12,11 @@ using Siger.Middlelayer.Common;
using Siger.Middlelayer.Share.Enum.ModuleEnum; using Siger.Middlelayer.Share.Enum.ModuleEnum;
using Siger.Middlelayer.Repository; using Siger.Middlelayer.Repository;
using Siger.Middlelayer.Log; using Siger.Middlelayer.Log;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Utility.Helpers;
using Siger.Middlelayer.Utility.ImportEntities;
using System.IO;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace Siger.ApiACC.Controllers namespace Siger.ApiACC.Controllers
...@@ -95,17 +100,79 @@ namespace Siger.ApiACC.Controllers ...@@ -95,17 +100,79 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(output); return new ObjectResult(output);
} }
[HttpGet] [HttpGet]
public IActionResult GetTasklist(int section, int tasktype, string productCode, string taskno, string sn, int status, int actionType, string triggerbegin,string triggerend, string complatebegin,string complatend,int page,int pageSize) public IActionResult GetTasklist(int section, int tasktype, string productCode, string taskno, string sn, int status, int actionType, string triggerbegin,string triggerend, string complatebegin,string complatend,int page,int pageSize, string toexcel)
{ {
var ids = new List<int>(); var ids = new List<int>();
if (section != 0) if (section != 0)
{ {
ids = _sigerProjectLevelSection.GetLevelSectionIds(section, ProjectId).ToList(); ids = _sigerProjectLevelSection.GetLevelSectionIds(section, ProjectId).ToList();
} }
var resulst = _automationTaskList.GetTasklistPagedList(ids, tasktype, productCode, taskno, sn, status, actionType, triggerbegin, triggerend, complatebegin, complatend, ProjectId,page,pageSize); var resulst = _automationTaskList.GetTasklistPagedList(ids, tasktype, productCode, taskno, sn, status, actionType, triggerbegin, triggerend, complatebegin, complatend, ProjectId,page,pageSize,toexcel);
if(toexcel.ToInt() == 1)
{
return ExportExcel(resulst.Data);
}
return new PagedObjectResult(resulst, resulst.Total, page, pageSize); return new PagedObjectResult(resulst, resulst.Total, page, pageSize);
} }
public IActionResult ExportExcel(IEnumerable<ResponseAutomationTasklist> data)
{
var rootDir = FileSystemHelper.GetPhysicalFolders(FileSystemHelper.CommonFileSetting.PhysicalFolder, FileSystemHelper.ExportFileName);
if (!data.Any())
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var dataList = new List<AutomationStateList>();
foreach (var item in data)
{
var model = Mapper<ResponseAutomationTasklist, AutomationStateList>.Map(item);
switch (item.status)
{
case 1:
model.status_value = "待执行";
break;
case 2:
model.status_value = "执行中";
break;
case 3:
model.status_value = "执行完成";
break;
case 4:
model.status_value = "取消";
break;
default:
model.status_value = "";
break;
}
dataList.Add(model);
}
if (dataList.Any())
{
EpPlusExcelHelper<AutomationStateList> helper = null;
try
{
helper = new EpPlusExcelHelper<AutomationStateList>();
var temporaryFileName = $"任务清单管理_AutomationTaskData_{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 Automation Task Data failed, error:" + e);
throw new BadRequestException(RequestEnum.ExportFailed);
}
finally
{
helper?.Dispose();
}
}
throw new BadRequestException(CommonEnum.Fail);
}
public IActionResult DeleteTask(int id) public IActionResult DeleteTask(int id)
{ {
var record = _automationTaskList.Get(f => f.id == id); var record = _automationTaskList.Get(f => f.id == id);
......
...@@ -135,12 +135,12 @@ namespace Siger.ApiACC.Controllers ...@@ -135,12 +135,12 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ProductNotFound); throw new BadRequestException(RequestEnum.ProductNotFound);
} }
//var data = _toolsProductRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && (q.fixturetools == fixtureTool.guid || var data = _toolsProductRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.fixturetools == fixtureTool.guid &&
// q.productid == req.productid.ToInt())); q.productid == req.productid.ToInt());
//if (data != null) if (data != null)
//{ {
// throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.DataExist);
//} }
var entity = new siger_automation_fixture_tools_product var entity = new siger_automation_fixture_tools_product
{ {
...@@ -190,8 +190,8 @@ namespace Siger.ApiACC.Controllers ...@@ -190,8 +190,8 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ProductNotFound); throw new BadRequestException(RequestEnum.ProductNotFound);
} }
var data = _toolsProductRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && (q.fixturetools == fixtureTool.guid || var data = _toolsProductRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.fixturetools == fixtureTool.guid &&
q.productid == req.productid.ToInt()) && q.id != req.id); q.productid == req.productid.ToInt() && q.id != req.id);
if (data != null) if (data != null)
{ {
throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.DataExist);
......
...@@ -68,6 +68,10 @@ namespace Siger.ApiACC.Controllers ...@@ -68,6 +68,10 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ProductNotFound); throw new BadRequestException(RequestEnum.ProductNotFound);
} }
if (string.IsNullOrEmpty(req.sn))
{
throw new BadRequestException(RequestEnum.PleaseInputPartSerialNumber);
}
var maxLevel = _levelRepository.GetList(t => t.status == (int)RowState.Valid && t.projectid == ProjectId).Max(q => q.id); var maxLevel = _levelRepository.GetList(t => t.status == (int)RowState.Valid && t.projectid == ProjectId).Max(q => q.id);
var section = _levelSectionRepository.Get(t => t.status == (int)RowState.Valid && t.projectid == ProjectId && t.id == req.sectionid); var section = _levelSectionRepository.Get(t => t.status == (int)RowState.Valid && t.projectid == ProjectId && t.id == req.sectionid);
if (section == null || section.levelid != maxLevel) if (section == null || section.levelid != maxLevel)
...@@ -262,6 +266,7 @@ namespace Siger.ApiACC.Controllers ...@@ -262,6 +266,7 @@ namespace Siger.ApiACC.Controllers
{ {
try try
{ {
CreateTaskList(req.sectionid, req.productid, product.code, req.sn, req.routeid.ToInt()); CreateTaskList(req.sectionid, req.productid, product.code, req.sn, req.routeid.ToInt());
AddSnList(req.materialid.ToInt(), inspection, product.code, section.parentid);//把二维码插入到 sn_list表 AddSnList(req.materialid.ToInt(), inspection, product.code, section.parentid);//把二维码插入到 sn_list表
} }
...@@ -324,9 +329,16 @@ namespace Siger.ApiACC.Controllers ...@@ -324,9 +329,16 @@ namespace Siger.ApiACC.Controllers
if (monitor==null) if (monitor==null)
{ {
Logger.WriteLineInfo($"检验工站{section} monitor 为空"); Logger.WriteLineInfo($"检验工站{section} monitor 为空");
throw new BadRequestException(CommonEnum.RecordNotFound);
}
//找到上下料位
var tasklst = _automationTaskList.Get(f => f.no == monitor.taskno);
if (tasklst==null)
{
Logger.WriteLineInfo($"检验工站{section} tasklst 为空");
throw new BadRequestException(CommonEnum.RecordNotFound);
} }
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual); var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
{ {
no = taskNo, no = taskNo,
...@@ -350,7 +362,8 @@ namespace Siger.ApiACC.Controllers ...@@ -350,7 +362,8 @@ namespace Siger.ApiACC.Controllers
productcode = productcode, productcode = productcode,
processid = routeid, processid = routeid,
programnumber = "", programnumber = "",
remark = "质量检验", remark = "质量检验->上下料位置",
extend1=tasklst.sectionid.ToString(),//上下料位发起到检验的工站
}); });
monitor.taskno = taskNo; monitor.taskno = taskNo;
......
...@@ -14,6 +14,7 @@ using Siger.Middlelayer.Repository; ...@@ -14,6 +14,7 @@ using Siger.Middlelayer.Repository;
using Siger.Middlelayer.Repository.Extensions; using Siger.Middlelayer.Repository.Extensions;
using System.Linq; using System.Linq;
using Siger.Middlelayer.Repository.Entities; using Siger.Middlelayer.Repository.Entities;
using Siger.Middlelayer.Share.Enum.ModuleEnum;
namespace Siger.ApiACC.Controllers namespace Siger.ApiACC.Controllers
{ {
...@@ -22,50 +23,61 @@ namespace Siger.ApiACC.Controllers ...@@ -22,50 +23,61 @@ namespace Siger.ApiACC.Controllers
private readonly IUnitOfWork _unitOfWork; private readonly IUnitOfWork _unitOfWork;
private readonly IAutomationSectionPropertyRepository _sectionPropertyRepository; private readonly IAutomationSectionPropertyRepository _sectionPropertyRepository;
private readonly ISigerProjectLevelSectionRepository _levelSectionRepository; private readonly ISigerProjectLevelSectionRepository _levelSectionRepository;
private readonly IProductionBeatSetRepository _beatSetRepository;
private readonly IAutomationFixtureMonitor _fixtureMonitor; private readonly IAutomationFixtureMonitor _fixtureMonitor;
private readonly IProductRouteRepository _routeRepository;
private readonly IAutomationTaskListRepository _taskListRepository;
private readonly ISigerProjectProductRepository _productRepository;
public SectionPropertyController(IUnitOfWork unitOfWork, IAutomationSectionPropertyRepository sectionPropertyRepository, public SectionPropertyController(IUnitOfWork unitOfWork, IAutomationSectionPropertyRepository sectionPropertyRepository,
ISigerProjectLevelSectionRepository levelSectionRepository, IProductionBeatSetRepository beatSetRepository, ISigerProjectLevelSectionRepository levelSectionRepository, IAutomationFixtureMonitor fixtureMonitor, IProductRouteRepository routeRepository,
IAutomationFixtureMonitor fixtureMonitor) IAutomationTaskListRepository taskListRepository, ISigerProjectProductRepository productRepository)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_sectionPropertyRepository = sectionPropertyRepository; _sectionPropertyRepository = sectionPropertyRepository;
_levelSectionRepository = levelSectionRepository; _levelSectionRepository = levelSectionRepository;
_beatSetRepository = beatSetRepository;
_fixtureMonitor = fixtureMonitor; _fixtureMonitor = fixtureMonitor;
_routeRepository = routeRepository;
_productRepository = productRepository;
} }
[HttpGet] [HttpGet]
public IActionResult GetSections(string line) public IActionResult GetSections(string line)
{ {
var sectionIds = _levelSectionRepository.GetLevelSectionIds(line.ToInt(), ProjectId); var sectionIds = _levelSectionRepository.GetLevelSectionIds(line.ToInt(), ProjectId);
var sectionids = _sectionPropertyRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && sectionIds.Contains(q.sectionid)). var sectionids = _sectionPropertyRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && sectionIds.Contains(q.sectionid) &&
Select(q => q.sectionid).ToList(); q.propertytype == (int)Automation.SectionPropertyEnum.Check).Select(q => q.sectionid).ToList();
var sections = _levelSectionRepository.GetList(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && sectionids.Contains(q.id)). var sections = _levelSectionRepository.GetList(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && sectionids.Contains(q.id)).
Select(q => new { q.id, q.title }).ToList(); Select(q => new { q.id, q.title }).ToList();
return new ObjectResult(sections); return new ObjectResult(sections);
} }
[HttpGet] [HttpGet]
public IActionResult GetRouteByProduct(string productId, int sectionId) public IActionResult GetRouteByProduct(string productId)
{ {
var list = _beatSetRepository.GetList(q => q.projectID == ProjectId && q.status == (int)RowState.Valid && q.product_name.ToInt() == productId.ToInt() && var list = _routeRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.productId == productId.ToInt()).Select(q => new
q.section_id == sectionId).Select(q => new {
{ q.id,
q.id, q.name,
name = q.route_name, route_number = q.serialNumber
q.route_number }).ToList();
}).ToList();
return new ObjectResult(list); return new ObjectResult(list);
} }
[HttpGet] [HttpGet]
public IActionResult GetSn(int sectionid) public IActionResult GetMonitorSnProduct(int sectionid)
{ {
var monitor = _fixtureMonitor.Get(sectionid); var res = new ResponseMonitorSnProduct();
return new ObjectResult(monitor?.sn ?? ""); var monitor = _fixtureMonitor.Get(q => q.section == sectionid);
if(monitor != null)
{
var product = _productRepository.Get(monitor.productId);
res.id = monitor.productId;
res.name = product?.name ?? "";
res.code = monitor.productCode;
res.sn = monitor.sn;
}
return new ObjectResult(res);
} }
} }
} }
...@@ -3,8 +3,10 @@ using Newtonsoft.Json; ...@@ -3,8 +3,10 @@ using Newtonsoft.Json;
using Siger.Middlelayer.AccRepository.Request; using Siger.Middlelayer.AccRepository.Request;
using Siger.Middlelayer.Common; using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.Configuration; using Siger.Middlelayer.Common.Configuration;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.Helpers; using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Common.Log; using Siger.Middlelayer.Common.Log;
using Siger.Middlelayer.Share.Enum.ModuleEnum;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -43,10 +45,17 @@ namespace Siger.ApiACC.Tasks ...@@ -43,10 +45,17 @@ namespace Siger.ApiACC.Tasks
var task = tasks.FirstOrDefault(); var task = tasks.FirstOrDefault();
if (task.send == 1) if (task.send == 1)
return; return;
var levelsction = dbhelper.GetLevelsection(task.sectionid);
var section = task.sectionid;
//抽检台-》上料位特殊逻辑
if (task.action== Automation.TaskAction.Step_CJT_SXLW)
{
section = task.extend1.ToInt();
}
var levelsction = dbhelper.GetLevelsection(section);
if (levelsction == null) if (levelsction == null)
return; return;
var attr = dbhelper.GetAttribution(task.sectionid); var attr = dbhelper.GetAttribution(section);
if (attr == null) if (attr == null)
return; return;
...@@ -66,7 +75,8 @@ namespace Siger.ApiACC.Tasks ...@@ -66,7 +75,8 @@ namespace Siger.ApiACC.Tasks
RobotStep = (int)task.action, RobotStep = (int)task.action,
StorageNo = task.locationid, StorageNo = task.locationid,
SN = task.sn, SN = task.sn,
Program = task.programnumber Program = task.programnumber,
TaskType = (int)task.tasktype
}; };
Logger.WriteLineError($"TASK 开始下发 : {EnumHelper.GetEnumDesc(task.action)}"); Logger.WriteLineError($"TASK 开始下发 : {EnumHelper.GetEnumDesc(task.action)}");
......
...@@ -344,6 +344,8 @@ namespace Siger.Middlelayer.Common.ModuleEnum ...@@ -344,6 +344,8 @@ namespace Siger.Middlelayer.Common.ModuleEnum
TaskIsSend, TaskIsSend,
[Description("该储位无工件")] [Description("该储位无工件")]
LocationNoSn, LocationNoSn,
[Description("工站属性为空")]
SectionPropertyNull
} }
public enum SeriNumCfg public enum SeriNumCfg
......
...@@ -15,11 +15,13 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum ...@@ -15,11 +15,13 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
/// <summary> /// <summary>
/// 手动任务 /// 手动任务
/// </summary> /// </summary>
Manual=1, [Description("手动任务")]
Manual =1,
/// <summary> /// <summary>
/// 自动任务 /// 自动任务
/// </summary> /// </summary>
Auto=2 [Description("自动任务")]
Auto =2
} }
/// <summary> /// <summary>
/// 执行任务 任务发方式 0,未执行 1 手动执行 2 自动执行 /// 执行任务 任务发方式 0,未执行 1 手动执行 2 自动执行
...@@ -29,14 +31,17 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum ...@@ -29,14 +31,17 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
/// <summary> /// <summary>
/// 未执行 /// 未执行
/// </summary> /// </summary>
[Description("未执行")]
None=0, None=0,
/// <summary> /// <summary>
/// 手动执行 /// 手动执行
/// </summary> /// </summary>
[Description("手动执行")]
Manual = 1, Manual = 1,
/// <summary> /// <summary>
/// 自动执行 /// 自动执行
/// </summary> /// </summary>
[Description("自动执行")]
Auto = 2 Auto = 2
} }
/// <summary> /// <summary>
...@@ -71,14 +76,17 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum ...@@ -71,14 +76,17 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
/// <summary> /// <summary>
/// 待生产 /// 待生产
/// </summary> /// </summary>
[Description("待生产")]
Waiting = 1, Waiting = 1,
/// <summary> /// <summary>
/// 生产中 /// 生产中
/// </summary> /// </summary>
[Description("生产中")]
Produce = 2, Produce = 2,
/// <summary> /// <summary>
/// 生产完成 /// 生产完成
/// </summary> /// </summary>
[Description("生产完成")]
Complated = 3 Complated = 3
} }
...@@ -156,5 +164,22 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum ...@@ -156,5 +164,22 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
[Description("不在库内")] [Description("不在库内")]
Out =2 Out =2
} }
/// <summary>
/// 1:上下料工位2:加工工位3:检验工位4:清洗5:存储工位
/// </summary>
public enum SectionPropertyEnum
{
[Description("上下料工位")]
UpDownLoad = 1,
[Description("加工工位")]
Machining = 2,
[Description("检验工位")]
Check = 3,
[Description("清洗")]
Clean = 3,
[Description("存储工位")]
Storage = 3,
}
} }
} }
...@@ -1544,5 +1544,8 @@ namespace Siger.Middlelayer.Common ...@@ -1544,5 +1544,8 @@ namespace Siger.Middlelayer.Common
[Description("请填写仓库名称")] [Description("请填写仓库名称")]
PleaseInputWarehouseName, PleaseInputWarehouseName,
[Description("请输入工件编号")]
PleaseInputPartSerialNumber,
} }
} }
...@@ -249,4 +249,45 @@ namespace Siger.Middlelayer.Utility.ImportEntities ...@@ -249,4 +249,45 @@ namespace Siger.Middlelayer.Utility.ImportEntities
[ExcelColumn("维护时间")] [ExcelColumn("维护时间")]
public string UpdateTime { get; set; } public string UpdateTime { get; set; }
} }
public class AutomationStateList : ImportBase
{
[ExcelColumn("任务编号")]
public string taskno { get; set; }
[ExcelColumn("产线层级")]
public string section { get; set; }
[ExcelColumn("触发方")]
public string trigger { get; set; }
[ExcelColumn("任务类型")]
public string tasktype { get; set; }
[ExcelColumn("工件编号")]
public string sn { get; set; }
[ExcelColumn("工单编号")]
public string ordernumber { get; set; }
[ExcelColumn("产品编号")]
public string productCode { get; set; }
[ExcelColumn("工序编号")]
public string routeNo { get; set; }
[ExcelColumn("工序名称")]
public string route { get; set; }
[ExcelColumn("程序号")]
public string program { get; set; }
[ExcelColumn("储位位置")]
public string location { get; set; }
[ExcelColumn("工装编号")]
public string fixtureCode { get; set; }
[ExcelColumn("动作")]
public string action { get; set; }
[ExcelColumn("执行类型")]
public string actionType { get; set; }
[ExcelColumn("状态")]
public string status_value { get; set; }
[ExcelColumn("触发时间")]
public string triggerTime { get; set; }
[ExcelColumn("完成时间")]
public string complatetime { get; set; }
}
} }
...@@ -169,5 +169,7 @@ namespace Siger.Middlelayer.AccRepository ...@@ -169,5 +169,7 @@ namespace Siger.Middlelayer.AccRepository
public DbSet<siger_automation_fixture_tools_monitor> siger_automation_fixture_tools_moniter { get; set; } public DbSet<siger_automation_fixture_tools_monitor> siger_automation_fixture_tools_moniter { get; set; }
public DbSet<siger_check_sn_trace_inspection> siger_check_sn_trace_inspection { get; set; } public DbSet<siger_check_sn_trace_inspection> siger_check_sn_trace_inspection { get; set; }
public DbSet<siger_check_sn_trace_detail> siger_check_sn_trace_detail { get; set; }
} }
} }
...@@ -15,17 +15,17 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -15,17 +15,17 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary> /// </summary>
public int sectionid { get; set; } public int sectionid { get; set; }
/// <summary> /// <summary>
/// 1:上下料工位2:加工工位3:检验工位4:装配工位5:存储工位 /// 1:上下料工位2:加工工位3:检验工位4:清洗5:存储工位
/// </summary> /// </summary>
public int propertytype { get; set; } public int propertytype { get; set; }
/// <summary> /// <summary>
/// 0:不是上料1:是上料 /// 0:不是上料1:是上料
/// </summary> /// </summary>
public string upload { get; set; } public int upload { get; set; }
/// <summary> /// <summary>
/// 0:不是下料1:是下料 /// 0:不是下料1:是下料
/// </summary> /// </summary>
public string down { get; set; } public int down { get; set; }
public DateTime createtime { get; set; } public DateTime createtime { get; set; }
......
...@@ -102,6 +102,9 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -102,6 +102,9 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary> /// </summary>
public string remark { get; set; } public string remark { get; set; }
/// <summary>
/// 准备前往下一个工站ID
/// </summary>
public string extend1 { get; set; } public string extend1 { get; set; }
public int route { get; set; } public int route { get; set; }
......
...@@ -171,15 +171,15 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -171,15 +171,15 @@ namespace Siger.Middlelayer.AccRepository.Repositories
} }
if(fixtureTool != null && product != null) if(fixtureTool != null && product != null)
{ {
var data = _context.siger_automation_fixture_tools_product.FirstOrDefault(q => q.projectId == projectid && q.status == (int)RowState.Valid && (q.fixturetools == fixtureTool.guid || var data = _context.siger_automation_fixture_tools_product.FirstOrDefault(q => q.projectId == projectid && q.status == (int)RowState.Valid && q.fixturetools == fixtureTool.guid &&
q.productid == product.id)); q.productid == product.id);
if (data != null) if (data != null)
{ {
errors.Add($"{rowIndex},{(int)RequestEnum.DataExist}"); errors.Add($"{rowIndex},{(int)RequestEnum.DataExist}");
} }
} }
if(list.Count(q => q.FixtureTool == item.FixtureTool || q.Product == item.Product) > 1) if(list.Count(q => q.FixtureTool == item.FixtureTool && q.Product == item.Product) > 1)
{ {
errors.Add($"{rowIndex},{(int)RequestEnum.DataExist}"); errors.Add($"{rowIndex},{(int)RequestEnum.DataExist}");
} }
......
...@@ -89,7 +89,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -89,7 +89,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
} }
public IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tirbeigin, string triend, string compbegin, string compend, int projectid, int page, int pagesize) public IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tirbeigin, string triend, string compbegin, string compend, int projectid, int page, int pagesize, string toexcel)
{ {
var query = from q in _context.siger_automation_task_list var query = from q in _context.siger_automation_task_list
join t in _context.siger_automation_fixture_tools on q.fixtureguid equals t.guid join t in _context.siger_automation_fixture_tools on q.fixtureguid equals t.guid
...@@ -121,8 +121,10 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -121,8 +121,10 @@ namespace Siger.Middlelayer.AccRepository.Repositories
route=r!=null?$"{r.serialNumber}-{r.name}":"", route=r!=null?$"{r.serialNumber}-{r.name}":"",
send=q.send, send=q.send,
tasktype=EnumHelper.GetEnumDesc(q.tasktype), tasktype=EnumHelper.GetEnumDesc(q.tasktype),
tasktypeid = Convert.ToInt32(q.tasktype),
status=q.status, status=q.status,
actionTypeid = Convert.ToInt32(q.actiontype)
}; };
Expression<Func<ResponseAutomationTasklist, bool>> sectonsExpression = f => true; Expression<Func<ResponseAutomationTasklist, bool>> sectonsExpression = f => true;
if (sections.Any()) if (sections.Any())
...@@ -165,14 +167,26 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -165,14 +167,26 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{ {
comptimeExpression = q => q.complatevalue >= compbegin.ToDateTime() && q.complatevalue <= compend.ToDateTime(); comptimeExpression = q => q.complatevalue >= compbegin.ToDateTime() && q.complatevalue <= compend.ToDateTime();
} }
Expression<Func<ResponseAutomationTasklist, bool>> statusExpression = f => true;
if (status != 0)
{
statusExpression = q => q.status == status;
}
var expression = sectonsExpression.And(taskTypeExpression).And(productCodeExpression).And(tasknoExpression).And(snExpression) var expression = sectonsExpression.And(taskTypeExpression).And(productCodeExpression).And(tasknoExpression).And(snExpression)
.And(actionTypeExpression).And(triggerTimeTypeExpression).And(comptimeExpression); .And(actionTypeExpression).And(triggerTimeTypeExpression).And(comptimeExpression).And(statusExpression);
if (toexcel.ToInt() == 1)
var entities = query.Where(expression).Skip((page - 1) * pagesize).Take(pagesize).AsNoTracking().ToList(); {
var totalCount = query.Where(expression).Count(); var entities = query.Where(expression).AsNoTracking().ToList();
return new PagedCollectionResult<ResponseAutomationTasklist>(entities, totalCount); return new PagedCollectionResult<ResponseAutomationTasklist>(entities, entities.Count);
}
else
{
var entities = query.Where(expression).Skip((page - 1) * pagesize).Take(pagesize).AsNoTracking().ToList();
var totalCount = query.Where(expression).Count();
return new PagedCollectionResult<ResponseAutomationTasklist>(entities, totalCount);
}
} }
} }
} }
...@@ -26,6 +26,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface ...@@ -26,6 +26,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
string CreateRandonSn(string productCode); string CreateRandonSn(string productCode);
IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tirbeigin,string triend,string compbegin, string compend, int projectid, int page, int pagesize); IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tirbeigin,string triend,string compbegin, string compend, int projectid, int page, int pagesize, string toexcel);
} }
} }
...@@ -37,6 +37,8 @@ namespace Siger.Middlelayer.AccRepository.Request ...@@ -37,6 +37,8 @@ namespace Siger.Middlelayer.AccRepository.Request
public string Program { get; set; } public string Program { get; set; }
public int LineID { get; set; } public int LineID { get; set; }
public int TaskType { get; set; }
} }
public class ResponsePlC public class ResponsePlC
......
...@@ -162,4 +162,16 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -162,4 +162,16 @@ namespace Siger.Middlelayer.AccRepository.Response
public int son_categoryid { get; set; } public int son_categoryid { get; set; }
public int son_status { get; set; } public int son_status { get; set; }
} }
public class ResponseMonitorSnProduct
{
public string sn { get; set; } = string.Empty;
public int id { get; set; } = 0;
public string name { get; set; } = string.Empty;
public string code { get; set; } = string.Empty;
}
} }
...@@ -56,6 +56,7 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -56,6 +56,7 @@ namespace Siger.Middlelayer.AccRepository.Response
public int Machine { get; set; } public int Machine { get; set; }
public string Pn { get; set; } public string Pn { get; set; }
public int ProductId { get; set; } public int ProductId { get; set; }
public string ProductCode { get; set; }
public string ProductName { get; set; } public string ProductName { get; set; }
public int Route { get; set; } public int Route { get; set; }
public string RouteName { get; set; } public string RouteName { get; set; }
......
...@@ -38,7 +38,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories ...@@ -38,7 +38,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
from m in mm.DefaultIfEmpty() from m in mm.DefaultIfEmpty()
join s in _context.siger_project_level_section on q.sectionid equals s.id into ss join s in _context.siger_project_level_section on q.sectionid equals s.id into ss
from s in ss.DefaultIfEmpty() from s in ss.DefaultIfEmpty()
join r in _context.siger_project_beat_set on q.routeid equals r.id into rr join r in _context.siger_project_product_route on q.routeid equals r.id into rr
from r in rr.DefaultIfEmpty() from r in rr.DefaultIfEmpty()
join u1 in _context.siger_project_user on q.send_mid equals u1.mid into uu1 join u1 in _context.siger_project_user on q.send_mid equals u1.mid into uu1
from u1 in uu1.DefaultIfEmpty() from u1 in uu1.DefaultIfEmpty()
...@@ -60,7 +60,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories ...@@ -60,7 +60,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
check_time = (q.check_time.HasValue && q.check_time != DateTime.Now) ? check_time = (q.check_time.HasValue && q.check_time != DateTime.Now) ?
q.check_time.Value.ToString(ParameterConstant.DateTimeFormat) : "", q.check_time.Value.ToString(ParameterConstant.DateTimeFormat) : "",
routeid = q.routeid, routeid = q.routeid,
routename = r.route_name ?? "", routename = r.name ?? "",
materialid = q.materialid, materialid = q.materialid,
materialname = m.name ?? "", materialname = m.name ?? "",
materialpn = m.pn ?? "", materialpn = m.pn ?? "",
......
...@@ -34,7 +34,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories ...@@ -34,7 +34,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
join s in _context.siger_project_level_section on q.sectionid equals s.id join s in _context.siger_project_level_section on q.sectionid equals s.id
join m in _context.siger_tr_materials on q.materialid equals m.id into mm join m in _context.siger_tr_materials on q.materialid equals m.id into mm
from m in mm.DefaultIfEmpty() from m in mm.DefaultIfEmpty()
join r in _context.siger_project_beat_set on q.routeid equals r.id into rr join r in _context.siger_project_product_route on q.routeid equals r.id into rr
from r in rr.DefaultIfEmpty() from r in rr.DefaultIfEmpty()
join u1 in _context.siger_user on q.send_mid equals u1.id into uu1 join u1 in _context.siger_user on q.send_mid equals u1.id into uu1
from u1 in uu1.DefaultIfEmpty() from u1 in uu1.DefaultIfEmpty()
...@@ -58,7 +58,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories ...@@ -58,7 +58,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
sectionid = q.sectionid, sectionid = q.sectionid,
sectionname = s.title ?? "", sectionname = s.title ?? "",
routeid = q.routeid, routeid = q.routeid,
routename = r.route_name ?? "", routename = r.name ?? "",
testroom = q.testroom, testroom = q.testroom,
sn = q.sn, sn = q.sn,
checktype = q.check_type, checktype = q.check_type,
......
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