Commit a478442c by yiyu.li
parents 9c5a7d93 2da17f65
......@@ -742,6 +742,7 @@ export default {
'9000517': '请填写子工装编号',
'9000518': '请填写储位ID',
'9000519': '请填写仓库名称',
'9000520': '请输入工件编号',
'9100000': 'Departments cannot be empty',
'9100001': 'Position cannot be empty',
......
......@@ -769,6 +769,7 @@ export default {
'9000517': '请填写子工装编号',
'9000518': '请填写储位ID',
'9000519': '请填写仓库名称',
'9000520': '请输入工件编号',
'9100000': '部门不能为空',
......
......@@ -295,7 +295,7 @@ export default {
},
{
title: "储位编号",
key: "locationcode",
key: "locationid",
},
{
title: "工装编号",
......@@ -318,7 +318,7 @@ export default {
},
{
title: "储位编号",
key: "locationcode",
key: "locationid",
},
{
title: "工装编号",
......
......@@ -37,7 +37,7 @@
>
<Option
v-for="(item, index) in productList"
:value="item.id"
:value="item.code"
:key="index"
:label="
item.name +
......@@ -75,7 +75,7 @@
clearable
filterable
class="searchSelect"
v-model="state"
v-model="status"
>
<Option :value="1">待执行</Option>
<Option :value="2">执行中</Option>
......@@ -296,7 +296,7 @@ export default {
productList: [],
taskNumber: "",
sn: "",
state: 0,
status: 0,
performType: 0,
startTime: [],
endTime: [],
......@@ -326,6 +326,7 @@ export default {
complatend: this.endTime.length > 0 ? this.endTime[1] : "",
page: page,
pageSize: pagesize,
TaskNo: this.taskNumber,
};
this.axios
.request({
......@@ -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() {
// 初始化产线层级
this.axios
......@@ -454,17 +441,33 @@ export default {
this.endTime = val;
},
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
.request({
url: "",
data,
method: "",
url: "/acc/AutomationState/GetTasklist",
params,
method: "get",
})
.then((res) => {
if (res.data.ret === 1) {
window.location.href =
axios.publicPath + "" + res.data.data;
this.axios.publicPath + "" + res.data.data;
} else {
this.$Message.error(this.$t(res.data.msg));
}
......
......@@ -690,14 +690,21 @@ export default {
axios
.request({
url:
"/qms/InspectStandard/GetProductsBySectionId?sectionid=" +
"/acc/SectionProperty/GetMonitorSnProduct?sectionid=" +
stationid,
method: "get",
})
.then((res) => {
if (res.data.ret == 1 && res.data.data.length > 0) {
this.productList = res.data.data;
if (res.data.ret == 1 && res.data.data.id > 0) {
this.productList = [
{
id:res.data.data.id,
name:res.data.data.name,
code:res.data.data.code,
}
];
this.product = this.productList[0];
this.qrcode = res.data.data.sn;
this.initmaterial(this.product.id, stationid);
this.inititems();
} else {
......@@ -715,21 +722,6 @@ export default {
this.initproduct(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) {
this.c = i;
this.product = this.productList[i];
......
......@@ -41,10 +41,11 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationFixtureToolsProductRepository _automationFixtureToolsProduct;
private readonly IAutomationFixtureToolsRepository _automationFixtureTools;
private readonly IProductRouteRepository _productRoute;
private readonly IAutomationSectionPropertyRepository _automationSectionProperty;
public AutomationController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection,IAutomationLineMode automationLineMode,IAutomationMachineStatus automationMachineStatus,ISigerDict sigerDict,IAutomationTaskListRepository automationTaskList,
ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution, IAutomationFixtureMonitor automationFixtureMonitor, IAutomationLocationRepository automationLocation, IProductionBeatSetRepository productionBeatSet, IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,
IAutomationFixtureToolsRepository automationFixtureTools, IProductRouteRepository productRoute)
IAutomationFixtureToolsRepository automationFixtureTools, IProductRouteRepository productRoute, IAutomationSectionPropertyRepository automationSectionProperty)
{
_unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection;
......@@ -59,6 +60,7 @@ namespace Siger.ApiACC.Controllers
_automationFixtureToolsProduct = automationFixtureToolsProduct;
_automationFixtureTools = automationFixtureTools;
_productRoute = productRoute;
_automationSectionProperty = automationSectionProperty;
}
/// <summary>
......@@ -69,12 +71,12 @@ namespace Siger.ApiACC.Controllers
[HttpPost]
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)
{
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)
{
_automationMachineStatus.Insert(new siger_automation_machine_status{
......@@ -87,6 +89,7 @@ namespace Siger.ApiACC.Controllers
});
}else
{
exitsObj.section = machineAttr.station;
exitsObj.enable = request.enable;
exitsObj.status = request.status;
exitsObj.updatetime = DateTime.Now;
......@@ -101,31 +104,13 @@ namespace Siger.ApiACC.Controllers
{
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))
{
var uploadStation = stationDicts.Where(f => f.dkey == DictKeyValConst.UploadloadStation);
var uploadStations = uploadStation.Select(f => f.dval.ToInt()).ToList();
if (!uploadStations.Contains(machineAttr.station))
var section = _sigerProjectLevelSection.Get(f => f.id == machineAttr.station);
if (section != null)
{
var tasklist = _automationTaskList.GetList(f => f.projectId == PID && f.status < (int)TaskResultStatus.Complated);
if (!tasklist.Any())
{
var section = _sigerProjectLevelSection.Get(f => f.id == machineAttr.station);
if (section != null)
{
Logger.WriteLineInfo($"MachineStatus 设备 {section.title}状态 触发自动任务检查");
AutoProcess(section.parentid, stationDicts);
}
}
Logger.WriteLineInfo($"MachineStatus 设备 {section.title}状态 触发自动任务检查");
AutoProcess(section.parentid);
}
}
}
......@@ -172,20 +157,11 @@ namespace Siger.ApiACC.Controllers
{
//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);
if (!tasklist.Any())
{
Logger.WriteLineInfo($"LineMode Mode=1 触发自动任务检查");
AutoProcess(line, stationDicts);
AutoProcess(line);
}
}
return new ObjectResult(CommonEnum.Succefull);
......@@ -236,15 +212,9 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(AccEnum.AutoTaskDone);
}
var stationDicts = _sigerDict.GetDataByCat(AccDictCost.Automation, PID);
if (!stationDicts.Any())
{
Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典");
throw new BadRequestException(AccEnum.AutomationDictNotfound);
}
//更新Tasklist
PlCfeeback(taskObj, request.status, stationDicts);
PlCfeeback(taskObj, request.status);
if (_unitOfWork.Commit() <= 0)
{
......@@ -261,13 +231,13 @@ namespace Siger.ApiACC.Controllers
if (section != null)
{
Logger.WriteLineInfo($" 设备{section.title} 任务编号:{taskObj.no} 状态:{request.status} ");
AutoProcess(section.parentid, stationDicts, taskObj);
AutoProcess(section.parentid, taskObj);
}
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.更新状态
taskObj.status = status;
......@@ -275,23 +245,29 @@ namespace Siger.ApiACC.Controllers
_automationTaskList.Update(taskObj);
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 反馈结束.
if (status == (int)TaskResultStatus.Complated)
{
var uploadStation = stationDicts.Where(f => f.dkey == DictKeyValConst.UploadloadStation);
var uploadStations = uploadStation.Select(f => f.dval).ToList();
var location = _automationLocation.Get(f => f.fixturetools == taskObj.fixtureguid && f.locationid == taskObj.locationid);
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.fixturename = taskObj.fixturename;
location.ordernumber = taskObj.ordercode;
......@@ -302,20 +278,60 @@ namespace Siger.ApiACC.Controllers
location.status = (int)LocationStatus.In;
_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;
_automationMachineStatus.Update(machineStatus);
if(taskObj.action==TaskAction.Step_QXJ_LK)
{
//上料 指定的第一道工序
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)
......@@ -335,7 +351,7 @@ namespace Siger.ApiACC.Controllers
/// <param name="fixture"></param>
/// <param name="stationDicts"></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);
if (lineMode==null)
......@@ -355,24 +371,33 @@ namespace Siger.ApiACC.Controllers
//2.其他设备上料
//3.其他设备下料
*/
var updownDic= stationDicts.Where(s => s.dkey == DictKeyValConst.UploadloadStation);
var uploadStations = updownDic.Select(f => f.dval.ToInt()).ToList();
/* 自动任务创建只有CNC 设备;排除上料设备(手动任务) */
var dictClean = stationDicts.FirstOrDefault(s=>s.dkey==DictKeyValConst.CleanStation);
if (dictClean==null)
///* 自动任务创建只有CNC 设备;排除上料设备(手动任务) */
var sectionPropertys = _automationSectionProperty.GetList(f => f.projectId == PID).ToList();
if (!sectionPropertys.Any())
{
Logger.WriteLineInfo($"AutoProcess 未配置清洗机字典");
Logger.WriteLineInfo($"AutoProcess 设备属性未配置");
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())
{
Logger.WriteLineInfo($"AutoProcess 无可用状态的设备");
return;
}
//优先级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.status == (int)Automation.MachineStatus.Complated)
......@@ -381,22 +406,41 @@ namespace Siger.ApiACC.Controllers
if (tasklist == null)
{
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);
if (locationObj==null)
else
{
Logger.WriteLineError($"AutoProcess 立库 为空");
return;
}
//工件回到立库
locationObj.status = (int)LocationStatus.In;
_automationLocation.Update(locationObj);
var locationObj = _automationLocation.Get(f => f.projectId == PID && f.locationid == tasklist.locationid);
if (locationObj == null)
{
Logger.WriteLineError($"AutoProcess 立库 为空");
return;
}
//工件回到立库
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);
return; //完成当前任务 退出
CreateTask(cleanMachine.section, TaskActionType.Unload, TaskAction.Step_QXJ_LK, tasklist.fixtureguid, tasklist.ordercode, tasklist.sn, "无程序", tasklist.productid, tasklist.productcode, tasklist.locationid, tasklist.route);
return; //完成当前任务 退出
}
}
else
{
Logger.WriteLineInfo($"AutoProcess 清洗机未完成");
}
}
else
{
Logger.WriteLineInfo($"AutoProcess 清洗机没找到");
}
//优先级2 :其他设备待上料 (立库->加工中心)
var freeMachine = machineStatusList.Where(f=>f.status==(int)Automation.MachineStatus.Waiting);
if (freeMachine != null)
......@@ -438,15 +482,51 @@ namespace Siger.ApiACC.Controllers
if (cleanMachine != null)
{
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 ");
if (tasklist==null)
//更新清洗机监控
var monitor = _automationFixtureMonitor.Get(cleanMachine.section);
if (monitor == null)
{
Logger.WriteLineError($"AutoProcess Tasklist 为空");
return;
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
{
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; //完成当前任务 退出
}
......@@ -491,8 +571,7 @@ namespace Siger.ApiACC.Controllers
ordercode= orderno,
sn= sn,
remark= EnumHelper.GetEnumDesc(taskAction),
route=route
route=route,
});
var monitor = _automationFixtureMonitor.Get(f => f.section == section);
if (monitor == null)
......@@ -510,7 +589,7 @@ namespace Siger.ApiACC.Controllers
route=route,
status=1,
sn=sn,
taskno=taskNo,
taskno=taskNo,
});
}
else
......@@ -541,36 +620,62 @@ namespace Siger.ApiACC.Controllers
var TempList = new List<ResponseAutoRouteInfo>();
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());
if (autoLocation == null)
continue;
if(autoLocation.status==2)
Logger.WriteLineError($"SelectLocation 设备{b.machineID}标准节拍{b.route_number}{b.route_name}");
var autoLocationIds = _automationLocation.GetList(f => f.projectId == b.projectID && f.routeid == b.route_number.ToInt() && f.productid == b.product_name.ToInt());
if (!autoLocationIds.Any())
{
//SN不在立库内
Logger.WriteLineError($"SelectLocation 当前储位工件不在储位上");
Logger.WriteLineError($"SelectLocation 设备{b.machineID} routeid:{b.route_number}-{b.route_name}productId:{b.product_name} 没有匹配到当前储位");
continue;
}
TempList.Add(new ResponseAutoRouteInfo
foreach (var autoLocation in autoLocationIds)
{
FixtureGuid=autoLocation.fixturetools,
FixtureName=autoLocation.fixturename,
Section=b.section_id,
Machine=b.machineID,
Pn=b.process_number,
ProductId=b.product_name.ToInt(),
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
});
if (string.IsNullOrEmpty(autoLocation.sn))
{
Logger.WriteLineError($"SelectLocation 设备{b.machineID} routeid:{b.route_number}-{b.route_name}productId:{b.product_name} 储位{autoLocation.locationid}没有SN工件");
continue;
}
if (autoLocation.status == 2)
{
//SN不在立库内
Logger.WriteLineError($"SelectLocation 设备{b.machineID} routeid:{b.route_number}-{b.route_name}productId:{b.product_name} 储位{autoLocation.locationid}工件Sn:{autoLocation.sn}不在储位上");
continue;
}
if(autoLocation.routeid==0)
{
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 planOrder = _automationFixtureToolsProduct.GetDeliveryOrder(ordernos, PID);
......@@ -591,7 +696,7 @@ namespace Siger.ApiACC.Controllers
ordernumber =result.OrderNo,
location=result.Location,
productId=result.ProductId,
//productCode=result.productcode,
productCode = result.ProductCode,
productName = result.ProductName,
sn =result.Sn,
pn= result.Pn,
......
......@@ -23,6 +23,7 @@ using Siger.Middlelayer.Common.Helpers;
using Newtonsoft.Json;
using NPOI.SS.Formula;
using static Siger.Middlelayer.Share.Enum.ModuleEnum.Automation;
using Siger.ApiCommon.Result;
namespace Siger.ApiACC.Controllers
{
......@@ -43,10 +44,11 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationLocationRepository _automationLocation;
private readonly IAutomationLineMode _automationLine;
private readonly IProductRouteRepository _productRoute;
private readonly IAutomationSectionPropertyRepository _sectionPropertyRepository;
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,
IAutomationLineMode automationLine, IProductRouteRepository productRoute)
IAutomationLineMode automationLine, IProductRouteRepository productRoute, IAutomationSectionPropertyRepository sectionPropertyRepository)
{
_unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection;
......@@ -62,6 +64,7 @@ namespace Siger.ApiACC.Controllers
_automationLocation = automationLocation;
_automationLine = automationLine;
_productRoute = productRoute;
_sectionPropertyRepository = sectionPropertyRepository;
}
/// <summary>
......@@ -79,70 +82,53 @@ namespace Siger.ApiACC.Controllers
Logger.WriteLineInfo($"GetloadStation 未配置设备类型字典");
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var loadStation=new List<string>();
//上下料
if (type==0)
{
var dictLoad = stationDicts.Where(s => s.dkey == DictKeyValConst.UploadloadStation);
if (!dictLoad.Any())
var sectionProperty = _sectionPropertyRepository.GetList(f => f.propertytype == 1);
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);
}
loadStation = dictLoad.Select(s => s.dval).ToList();
}else
{
var dictLoad = stationDicts.Where(s => s.dkey == DictKeyValConst.CleanStation);
if (!dictLoad.Any())
var result = new List<ResponseLoadStation>();
foreach (var lv in levelSection)
{
Logger.WriteLineInfo($"GetloadStation 未配置清洗工站字典");
throw new BadRequestException(CommonEnum.RecordNotFound);
result.Add(new ResponseLoadStation
{
section=lv.id,
status=1,
title=lv.title,
});
}
loadStation = dictLoad.Select(s => s.dval).ToList();
return new ObjectResult(result);
//检验
}
var data = new List<ResponseLoadStation>();
foreach (var station in loadStation)
else
{
var section = _sigerProjectLevelSection.Get(f => f.id == station.ToInt() && f.parentid==line && f.status == (int)RowState.Valid);
if (section == null)
continue;
var machintAttr = _sigerProjectMachineAttribution.Get(f => f.station == section.id);
if(machintAttr==null)
var sectionProperty = _sectionPropertyRepository.GetList(f => f.propertytype == 3);
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 未配置工站字典");
continue;
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var loadStatus = (int)Automation.MachineStatus.Waiting;
var machineStatus = _automationMachineStatus.Get(f => f.section == section.id);
if (machineStatus==null)
var result = new List<ResponseLoadStation>();
foreach (var lv in levelSection)
{
_automationMachineStatus.Insert(new siger_automation_machine_status
result.Add(new ResponseLoadStation
{
projectId=ProjectId,
enable=1,
machineid=machintAttr.machine,
section=section.id,
updatetime=DateTime.Now
});
}else
{
section = lv.id,
status = 1,
title = lv.title,
loadStatus = machineStatus.status;
});
}
data.Add(new ResponseLoadStation {
section=section.id,
title=section.title,
status=loadStatus
});
return new ObjectResult(result);
}
_unitOfWork.Commit();
return new ObjectResult(data);
}
......@@ -201,7 +187,14 @@ namespace Siger.ApiACC.Controllers
{
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)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
......@@ -226,14 +219,14 @@ namespace Siger.ApiACC.Controllers
RobotStep = (int)taskobj.action,
StorageNo = taskobj.locationid,
SN = taskobj.sn,
Program = taskobj.programnumber
Program = taskobj.programnumber,
TaskType=(int)taskobj.tasktype
};
var result = PushTask(host, sendToPLC, out string message);
if (!result)
{
Logger.WriteLineError($"TASK 下发失败 : {message}");
throw new BadRequestException(CommonEnum.Fail);
return new ImportObjectResult((int)CommonEnum.Fail, message);
}
taskobj.send = 1;
_automationTaskList.Update(taskobj);
......@@ -340,10 +333,6 @@ namespace Siger.ApiACC.Controllers
updatetime = DateTime.Now
});
}
if (machineStatus.auto==1)
{
throw new BadRequestException(AccEnum.MachineDisable);
}
var plandts = _planDetails.Get(f => f.projectId == ProjectId && f.OrderNumber == loading.code);
if (plandts==null)
......@@ -362,10 +351,15 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(AccEnum.FixtureToolsIsNone);
}
var exitsUpload = _automationTaskList.Get(f => f.send == 0 && f.locationid == loading.locationid);
if (exitsUpload!=null)
var monitor = _automationFixtureMonitor.Get(f => f.section == loading.section);
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 sn = _automationTaskList.CreateRandonSn(plan.product_code);
......@@ -408,7 +402,6 @@ namespace Siger.ApiACC.Controllers
});
var monitor = _automationFixtureMonitor.Get(f => f.fixtureguid == fixtureToolsObj.FixtureGuid);
if (monitor==null)
{
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
......@@ -482,16 +475,23 @@ namespace Siger.ApiACC.Controllers
{
machineStatus.status = (int)Automation.MachineStatus.Waiting;
}
//创建 安装完成动作
var monitor = _automationFixtureMonitor.Get(f => f.projectId == ProjectId && f.section == assemble.section);
if (monitor==null)
{
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);
_automationTaskList.Insert(new siger_automation_task_list
{
......@@ -552,9 +552,12 @@ namespace Siger.ApiACC.Controllers
{
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 lineMode = _automationLine.Get(f => f.section ==levelSection.parentid);
if (lineMode==null)
{
throw new BadRequestException(AccEnum.LineModeNotfound);
......@@ -569,8 +572,17 @@ namespace Siger.ApiACC.Controllers
//1. 有检验状态 (立库-》检验工位)
//2. 无检验状态 (立库-》上下料工位)
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
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
{
no = taskNo,
......@@ -594,11 +606,11 @@ namespace Siger.ApiACC.Controllers
productcode = location.productcode,
processid = 0,
programnumber = "",
remark = "手动任务-准备下料",
remark =lineMode.inspect==1? "准备下料-》抽检台":"准备下料",
extend1= unixtime.ToStr()
});
var monitor = _automationFixtureMonitor.Get(f => f.section == unloading.section);
var monitor = _automationFixtureMonitor.Get(f => f.section == section);
if (monitor == null)
{
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
......@@ -606,7 +618,7 @@ namespace Siger.ApiACC.Controllers
fixtureguid = location.fixturetools,
fixturename = location.fixturename,
projectId = ProjectId,
section = unloading.section,
section = section,
sn = location.sn,
createtime = DateTime.Now,
updatetime = DateTime.Now,
......@@ -654,20 +666,6 @@ namespace Siger.ApiACC.Controllers
[HttpPost]
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))
{
throw new BadRequestException(AccEnum.TaskProcessing);
......@@ -678,7 +676,25 @@ namespace Siger.ApiACC.Controllers
{
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);
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)
{
location.sn = "";
......@@ -713,7 +729,7 @@ namespace Siger.ApiACC.Controllers
});
//移出 上料位
monitor.section = 0;
monitor.taskno = taskNo;
_automationFixtureMonitor.Update(monitor);
......
......@@ -12,6 +12,11 @@ using Siger.Middlelayer.Common;
using Siger.Middlelayer.Share.Enum.ModuleEnum;
using Siger.Middlelayer.Repository;
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
namespace Siger.ApiACC.Controllers
......@@ -95,17 +100,79 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(output);
}
[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>();
if (section != 0)
{
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);
}
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)
{
var record = _automationTaskList.Get(f => f.id == id);
......
......@@ -135,12 +135,12 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(RequestEnum.ProductNotFound);
}
//var data = _toolsProductRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && (q.fixturetools == fixtureTool.guid ||
// q.productid == req.productid.ToInt()));
//if (data != null)
//{
// throw new BadRequestException(RequestEnum.DataExist);
//}
var data = _toolsProductRepository.Get(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.fixturetools == fixtureTool.guid &&
q.productid == req.productid.ToInt());
if (data != null)
{
throw new BadRequestException(RequestEnum.DataExist);
}
var entity = new siger_automation_fixture_tools_product
{
......@@ -190,8 +190,8 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(RequestEnum.ProductNotFound);
}
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);
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);
if (data != null)
{
throw new BadRequestException(RequestEnum.DataExist);
......
......@@ -68,6 +68,10 @@ namespace Siger.ApiACC.Controllers
{
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 section = _levelSectionRepository.Get(t => t.status == (int)RowState.Valid && t.projectid == ProjectId && t.id == req.sectionid);
if (section == null || section.levelid != maxLevel)
......@@ -262,6 +266,7 @@ namespace Siger.ApiACC.Controllers
{
try
{
CreateTaskList(req.sectionid, req.productid, product.code, req.sn, req.routeid.ToInt());
AddSnList(req.materialid.ToInt(), inspection, product.code, section.parentid);//把二维码插入到 sn_list表
}
......@@ -324,9 +329,16 @@ namespace Siger.ApiACC.Controllers
if (monitor==null)
{
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);
_automationTaskList.Insert(new siger_automation_task_list
{
no = taskNo,
......@@ -350,7 +362,8 @@ namespace Siger.ApiACC.Controllers
productcode = productcode,
processid = routeid,
programnumber = "",
remark = "质量检验",
remark = "质量检验->上下料位置",
extend1=tasklst.sectionid.ToString(),//上下料位发起到检验的工站
});
monitor.taskno = taskNo;
......
......@@ -14,6 +14,7 @@ using Siger.Middlelayer.Repository;
using Siger.Middlelayer.Repository.Extensions;
using System.Linq;
using Siger.Middlelayer.Repository.Entities;
using Siger.Middlelayer.Share.Enum.ModuleEnum;
namespace Siger.ApiACC.Controllers
{
......@@ -22,50 +23,61 @@ namespace Siger.ApiACC.Controllers
private readonly IUnitOfWork _unitOfWork;
private readonly IAutomationSectionPropertyRepository _sectionPropertyRepository;
private readonly ISigerProjectLevelSectionRepository _levelSectionRepository;
private readonly IProductionBeatSetRepository _beatSetRepository;
private readonly IAutomationFixtureMonitor _fixtureMonitor;
private readonly IProductRouteRepository _routeRepository;
private readonly IAutomationTaskListRepository _taskListRepository;
private readonly ISigerProjectProductRepository _productRepository;
public SectionPropertyController(IUnitOfWork unitOfWork, IAutomationSectionPropertyRepository sectionPropertyRepository,
ISigerProjectLevelSectionRepository levelSectionRepository, IProductionBeatSetRepository beatSetRepository,
IAutomationFixtureMonitor fixtureMonitor)
ISigerProjectLevelSectionRepository levelSectionRepository, IAutomationFixtureMonitor fixtureMonitor, IProductRouteRepository routeRepository,
IAutomationTaskListRepository taskListRepository, ISigerProjectProductRepository productRepository)
{
_unitOfWork = unitOfWork;
_sectionPropertyRepository = sectionPropertyRepository;
_levelSectionRepository = levelSectionRepository;
_beatSetRepository = beatSetRepository;
_fixtureMonitor = fixtureMonitor;
_routeRepository = routeRepository;
_productRepository = productRepository;
}
[HttpGet]
public IActionResult GetSections(string line)
{
var sectionIds = _levelSectionRepository.GetLevelSectionIds(line.ToInt(), ProjectId);
var sectionids = _sectionPropertyRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && sectionIds.Contains(q.sectionid)).
Select(q => q.sectionid).ToList();
var sectionids = _sectionPropertyRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && sectionIds.Contains(q.sectionid) &&
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)).
Select(q => new { q.id, q.title }).ToList();
return new ObjectResult(sections);
}
[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() &&
q.section_id == sectionId).Select(q => new
{
q.id,
name = q.route_name,
q.route_number
}).ToList();
var list = _routeRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.productId == productId.ToInt()).Select(q => new
{
q.id,
q.name,
route_number = q.serialNumber
}).ToList();
return new ObjectResult(list);
}
[HttpGet]
public IActionResult GetSn(int sectionid)
public IActionResult GetMonitorSnProduct(int sectionid)
{
var monitor = _fixtureMonitor.Get(sectionid);
return new ObjectResult(monitor?.sn ?? "");
var res = new ResponseMonitorSnProduct();
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;
using Siger.Middlelayer.AccRepository.Request;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Common.Configuration;
using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.Helpers;
using Siger.Middlelayer.Common.Log;
using Siger.Middlelayer.Share.Enum.ModuleEnum;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -43,10 +45,17 @@ namespace Siger.ApiACC.Tasks
var task = tasks.FirstOrDefault();
if (task.send == 1)
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)
return;
var attr = dbhelper.GetAttribution(task.sectionid);
var attr = dbhelper.GetAttribution(section);
if (attr == null)
return;
......@@ -66,7 +75,8 @@ namespace Siger.ApiACC.Tasks
RobotStep = (int)task.action,
StorageNo = task.locationid,
SN = task.sn,
Program = task.programnumber
Program = task.programnumber,
TaskType = (int)task.tasktype
};
Logger.WriteLineError($"TASK 开始下发 : {EnumHelper.GetEnumDesc(task.action)}");
......
......@@ -344,6 +344,8 @@ namespace Siger.Middlelayer.Common.ModuleEnum
TaskIsSend,
[Description("该储位无工件")]
LocationNoSn,
[Description("工站属性为空")]
SectionPropertyNull
}
public enum SeriNumCfg
......
......@@ -15,11 +15,13 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
/// <summary>
/// 手动任务
/// </summary>
Manual=1,
[Description("手动任务")]
Manual =1,
/// <summary>
/// 自动任务
/// </summary>
Auto=2
[Description("自动任务")]
Auto =2
}
/// <summary>
/// 执行任务 任务发方式 0,未执行 1 手动执行 2 自动执行
......@@ -29,14 +31,17 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
/// <summary>
/// 未执行
/// </summary>
[Description("未执行")]
None=0,
/// <summary>
/// 手动执行
/// </summary>
[Description("手动执行")]
Manual = 1,
/// <summary>
/// 自动执行
/// </summary>
[Description("自动执行")]
Auto = 2
}
/// <summary>
......@@ -71,14 +76,17 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
/// <summary>
/// 待生产
/// </summary>
[Description("待生产")]
Waiting = 1,
/// <summary>
/// 生产中
/// </summary>
[Description("生产中")]
Produce = 2,
/// <summary>
/// 生产完成
/// </summary>
[Description("生产完成")]
Complated = 3
}
......@@ -156,5 +164,22 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
[Description("不在库内")]
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
[Description("请填写仓库名称")]
PleaseInputWarehouseName,
[Description("请输入工件编号")]
PleaseInputPartSerialNumber,
}
}
......@@ -249,4 +249,45 @@ namespace Siger.Middlelayer.Utility.ImportEntities
[ExcelColumn("维护时间")]
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
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_detail> siger_check_sn_trace_detail { get; set; }
}
}
......@@ -15,17 +15,17 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary>
public int sectionid { get; set; }
/// <summary>
/// 1:上下料工位2:加工工位3:检验工位4:装配工位5:存储工位
/// 1:上下料工位2:加工工位3:检验工位4:清洗5:存储工位
/// </summary>
public int propertytype { get; set; }
/// <summary>
/// 0:不是上料1:是上料
/// </summary>
public string upload { get; set; }
public int upload { get; set; }
/// <summary>
/// 0:不是下料1:是下料
/// </summary>
public string down { get; set; }
public int down { get; set; }
public DateTime createtime { get; set; }
......
......@@ -102,6 +102,9 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary>
public string remark { get; set; }
/// <summary>
/// 准备前往下一个工站ID
/// </summary>
public string extend1 { get; set; }
public int route { get; set; }
......
......@@ -171,15 +171,15 @@ namespace Siger.Middlelayer.AccRepository.Repositories
}
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 ||
q.productid == product.id));
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);
if (data != null)
{
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}");
}
......
......@@ -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
join t in _context.siger_automation_fixture_tools on q.fixtureguid equals t.guid
......@@ -121,8 +121,10 @@ namespace Siger.Middlelayer.AccRepository.Repositories
route=r!=null?$"{r.serialNumber}-{r.name}":"",
send=q.send,
tasktype=EnumHelper.GetEnumDesc(q.tasktype),
tasktypeid = Convert.ToInt32(q.tasktype),
status=q.status,
actionTypeid = Convert.ToInt32(q.actiontype)
};
Expression<Func<ResponseAutomationTasklist, bool>> sectonsExpression = f => true;
if (sections.Any())
......@@ -165,14 +167,26 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{
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)
.And(actionTypeExpression).And(triggerTimeTypeExpression).And(comptimeExpression);
.And(actionTypeExpression).And(triggerTimeTypeExpression).And(comptimeExpression).And(statusExpression);
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);
if (toexcel.ToInt() == 1)
{
var entities = query.Where(expression).AsNoTracking().ToList();
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
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
public string Program { get; set; }
public int LineID { get; set; }
public int TaskType { get; set; }
}
public class ResponsePlC
......
......@@ -162,4 +162,16 @@ namespace Siger.Middlelayer.AccRepository.Response
public int son_categoryid { 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
public int Machine { get; set; }
public string Pn { get; set; }
public int ProductId { get; set; }
public string ProductCode { get; set; }
public string ProductName { get; set; }
public int Route { get; set; }
public string RouteName { get; set; }
......
......@@ -38,7 +38,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
from m in mm.DefaultIfEmpty()
join s in _context.siger_project_level_section on q.sectionid equals s.id into ss
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()
join u1 in _context.siger_project_user on q.send_mid equals u1.mid into uu1
from u1 in uu1.DefaultIfEmpty()
......@@ -60,7 +60,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
check_time = (q.check_time.HasValue && q.check_time != DateTime.Now) ?
q.check_time.Value.ToString(ParameterConstant.DateTimeFormat) : "",
routeid = q.routeid,
routename = r.route_name ?? "",
routename = r.name ?? "",
materialid = q.materialid,
materialname = m.name ?? "",
materialpn = m.pn ?? "",
......
......@@ -34,7 +34,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
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
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()
join u1 in _context.siger_user on q.send_mid equals u1.id into uu1
from u1 in uu1.DefaultIfEmpty()
......@@ -58,7 +58,7 @@ namespace Siger.Middlelayer.QmsRepository.Repositories
sectionid = q.sectionid,
sectionname = s.title ?? "",
routeid = q.routeid,
routename = r.route_name ?? "",
routename = r.name ?? "",
testroom = q.testroom,
sn = q.sn,
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