Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
Laisi_AutoMES2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiawei.su
Laisi_AutoMES2
Commits
5649cfdc
Commit
5649cfdc
authored
Jan 22, 2021
by
jiawei.su
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
someupdate
parent
84393164
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
173 additions
and
29 deletions
+173
-29
AutomationController.cs
Server/Apis/Siger.ApiACC/Controllers/AutomationController.cs
+7
-6
AutomationOperateController.cs
...s/Siger.ApiACC/Controllers/AutomationOperateController.cs
+70
-13
AccEnum.cs
...Common/Siger.Middlelayer.Share/Enum/ModuleEnum/AccEnum.cs
+9
-3
Automation.cs
...mon/Siger.Middlelayer.Share/Enum/ModuleEnum/Automation.cs
+18
-0
siger_automation_task_list.cs
...ayer.AccRepository/Entities/siger_automation_task_list.cs
+5
-5
AutomationTaskListRepository.cs
...ccRepository/Repositories/AutomationTaskListRepository.cs
+29
-0
IAutomationTaskListRepository.cs
...y/Repositories/Interface/IAutomationTaskListRepository.cs
+11
-2
ResponseAutomationInfo.cs
...dlelayer.AccRepository/Response/ResponseAutomationInfo.cs
+1
-0
DB.script
Server/Infrastructure/Script/DB.script
+23
-0
No files found.
Server/Apis/Siger.ApiACC/Controllers/AutomationController.cs
View file @
5649cfdc
...
...
@@ -240,7 +240,7 @@ namespace Siger.ApiACC.Controllers
if
(
lineMode
==
null
)
{
Logger
.
WriteLineInfo
(
$"AutoProcess 产线模式未找到"
);
throw
new
BadRequestException
(
RequestEnum
.
LevelSectionNotF
ound
);
throw
new
BadRequestException
(
AccEnum
.
LineModeNotf
ound
);
}
if
(
lineMode
.
mode
==
0
)
{
...
...
@@ -283,7 +283,7 @@ namespace Siger.ApiACC.Controllers
if
(
cleanMachine
.
status
==
(
int
)
Automation
.
MachineStatus
.
Complated
)
{
Logger
.
WriteLineInfo
(
$"AutoProcess 有清洗机完成,创建清洗剂Task"
);
CreateTask
(
cleanMachine
,
TaskActionType
.
Unload
,
TaskAction
.
Step_QXJ_LK
);
CreateTask
(
cleanMachine
,
TaskActionType
.
Unload
,
TaskAction
.
Step_QXJ_LK
);
return
;
//完成当前任务 退出
}
}
...
...
@@ -294,7 +294,7 @@ namespace Siger.ApiACC.Controllers
if
(
freeMachine
!=
null
)
{
Logger
.
WriteLineInfo
(
$"AutoProcess 普通空闲,创建普通设备上料Task"
);
CreateTask
(
freeMachine
,
TaskActionType
.
Load
,
TaskAction
.
Step_LK_JGZX
);
CreateTask
(
freeMachine
,
TaskActionType
.
Load
,
TaskAction
.
Step_LK_JGZX
);
return
;
//完成当前任务 退出
}
//优先级3:其他设备下料 (加工中心 ->立库)
...
...
@@ -304,14 +304,14 @@ namespace Siger.ApiACC.Controllers
if
(
fullMachine
!=
null
&&
cleanMachine
.
status
==(
int
)
Automation
.
MachineStatus
.
Waiting
)
{
Logger
.
WriteLineInfo
(
$"AutoProcess 普通空闲,创建普通设备下料Task "
);
CreateTask
(
fullMachine
,
TaskActionType
.
Unload
,
TaskAction
.
Step_JGZX_QXJ
);
CreateTask
(
fullMachine
,
TaskActionType
.
Unload
,
TaskAction
.
Step_JGZX_QXJ
);
return
;
//完成当前任务 退出
}
}
}
void
CreateTask
(
siger_automation_machine_status
machineStatus
,
TaskActionType
actionType
,
TaskAction
taskAction
)
void
CreateTask
(
siger_automation_machine_status
machineStatus
,
TaskActionType
actionType
,
TaskAction
taskAction
)
{
_automationTaskList
.
Insert
(
new
siger_automation_task_list
...
...
@@ -320,7 +320,7 @@ namespace Siger.ApiACC.Controllers
sectionid
=
machineStatus
.
section
,
trigger
=
TaskTrigerType
.
Auto
,
action
=
taskAction
,
actiontype
=
TaskTrigerType
.
Auto
,
//默认自动动作
actiontype
=
ExcueType
.
None
,
tasktype
=
actionType
,
triggertime
=
DateTime
.
Now
,
completetime
=
DateTime
.
MinValue
,
...
...
@@ -328,6 +328,7 @@ namespace Siger.ApiACC.Controllers
send
=
0
,
operater
=
0
,
status
=
1
,
remark
=
"自动任务"
});
if
(
_unitOfWork
.
Commit
()
>
0
)
...
...
Server/Apis/Siger.ApiACC/Controllers/AutomationOperateController.cs
View file @
5649cfdc
...
...
@@ -9,6 +9,7 @@ using Siger.Middlelayer.AccRepository.Request;
using
Siger.Middlelayer.AccRepository.Response
;
using
Siger.Middlelayer.Common
;
using
Siger.Middlelayer.Common.Extensions
;
using
Siger.Middlelayer.Common.ModuleEnum
;
using
Siger.Middlelayer.Log
;
using
Siger.Middlelayer.Repository
;
using
Siger.Middlelayer.Repository.Repositories.Interface
;
...
...
@@ -26,19 +27,16 @@ namespace Siger.ApiACC.Controllers
private
readonly
ISigerDict
_sigerDict
;
private
readonly
IAutomationMachineStatus
_automationMachineStatus
;
private
readonly
ISigerProjectMachineAttributionRepository
_sigerProjectMachineAttribution
;
private
readonly
IAutomationTaskListRepository
_automationTaskList
;
public
AutomationOperateController
(
IUnitOfWork
unitOfWork
,
ISigerProjectLevelSectionRepository
sigerProjectLevelSection
,
ISigerDict
sigerDict
,
IAutomationMachineStatus
automationMachineStatus
,
ISigerProjectMachineAttributionRepository
sigerProjectMachineAttribution
)
public
AutomationOperateController
(
IUnitOfWork
unitOfWork
,
ISigerProjectLevelSectionRepository
sigerProjectLevelSection
,
ISigerDict
sigerDict
,
IAutomationMachineStatus
automationMachineStatus
,
ISigerProjectMachineAttributionRepository
sigerProjectMachineAttribution
,
IAutomationTaskListRepository
automationTaskList
)
{
_unitOfWork
=
unitOfWork
;
_sigerProjectLevelSection
=
sigerProjectLevelSection
;
_sigerDict
=
sigerDict
;
_automationMachineStatus
=
automationMachineStatus
;
_sigerProjectMachineAttribution
=
sigerProjectMachineAttribution
;
}
public
IActionResult
Get
()
{
return
new
ObjectResult
(
1
);
_automationTaskList
=
automationTaskList
;
}
/// <summary>
...
...
@@ -118,23 +116,82 @@ namespace Siger.ApiACC.Controllers
return
new
ObjectResult
(
data
);
}
/// <summary>
/// 查询状态
/// </summary>
/// <param name="section"></param>
/// <returns></returns>
[
HttpGet
]
public
IActionResult
GetLoadingState
(
int
section
)
{
var
data
=
new
ResponseAutomationInfo
{
sn
=
"sn0001"
,
wo
=
"wo123123"
};
return
new
ObjectResult
(
data
);
}
/// <summary>
/// 准备上料
/// 准备上料
-生成指令
/// </summary>
/// <param name="loading"></param>
/// <returns></returns>
[
HttpPost
]
public
IActionResult
Loading
([
FromBody
]
requestAutomationLoading
loading
)
{
var
data
=
new
ResponseAutomationInfo
{
sn
=
"sn0001"
,
wo
=
"wo123123"
};
return
new
ObjectResult
(
data
);
var
machineAttr
=
_sigerProjectMachineAttribution
.
Get
(
f
=>
f
.
station
==
loading
.
section
&&
f
.
status
==
(
int
)
RowState
.
Valid
);
if
(
machineAttr
==
null
)
{
throw
new
BadRequestException
(
CommonEnum
.
RecordNotFound
);
}
var
machineStatus
=
_automationMachineStatus
.
Get
(
f
=>
f
.
machineid
==
machineAttr
.
machine
);
if
(
machineStatus
==
null
)
{
throw
new
BadRequestException
(
CommonEnum
.
RecordNotFound
);
}
if
(
machineStatus
.
enable
==
0
)
{
throw
new
BadRequestException
(
AccEnum
.
MachineDisable
);
}
if
(
machineStatus
.
status
!=(
int
)
Automation
.
MachineStatus
.
Waiting
)
{
throw
new
BadRequestException
(
AccEnum
.
MachineBusy
);
}
if
(!
_automationTaskList
.
CanTask
(
ProjectId
,
loading
.
section
))
{
throw
new
BadRequestException
(
AccEnum
.
TaskProcessing
);
}
var
taskNo
=
_automationTaskList
.
CrateTaskNumber
(
Automation
.
TaskTrigerType
.
Manual
);
_automationTaskList
.
Insert
(
new
siger_automation_task_list
{
guid
=
taskNo
,
action
=
Automation
.
TaskAction
.
Step_LK_SXLW
,
actiontype
=
Automation
.
ExcueType
.
None
,
triggertime
=
DateTime
.
MinValue
,
tasktype
=
Automation
.
TaskActionType
.
Load
,
operater
=
UserId
,
operatetime
=
DateTime
.
Now
,
sectionid
=
loading
.
section
,
send
=
0
,
status
=
1
,
completetime
=
DateTime
.
MinValue
,
trigger
=
Automation
.
TaskTrigerType
.
Manual
,
projectId
=
ProjectId
,
remark
=
"手动任务"
,
});
if
(
_unitOfWork
.
Commit
()
>
0
)
return
new
ObjectResult
(
CommonEnum
.
Succefull
);
else
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
}
/// <summary>
/// 安装完成
/// 安装完成
-生成指令
/// </summary>
/// <param name="assemble"></param>
/// <returns></returns>
...
...
Server/Common/Siger.Middlelayer.Share/Enum/ModuleEnum/AccEnum.cs
View file @
5649cfdc
...
...
@@ -316,9 +316,15 @@ namespace Siger.Middlelayer.Common.ModuleEnum
[
Description
(
"序号已全部生成"
)]
SerinumFull
,
[
Description
(
"该任务状态已经完成"
)]
AutoTaskDone
AutoTaskDone
,
[
Description
(
"产线模式未找到"
)]
LineModeNotfound
,
[
Description
(
"设备状态不可用"
)]
MachineDisable
,
[
Description
(
"设备正在使用中"
)]
MachineBusy
,
[
Description
(
"任务进行中"
)]
TaskProcessing
}
public
enum
SeriNumCfg
...
...
Server/Common/Siger.Middlelayer.Share/Enum/ModuleEnum/Automation.cs
View file @
5649cfdc
...
...
@@ -22,6 +22,24 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
Auto
=
2
}
/// <summary>
/// 执行任务 任务发方式 0,未执行 1 手动执行 2 自动执行
/// </summary>
public
enum
ExcueType
{
/// <summary>
/// 未执行
/// </summary>
None
=
0
,
/// <summary>
/// 手动执行
/// </summary>
Manual
=
1
,
/// <summary>
/// 自动执行
/// </summary>
Auto
=
2
}
/// <summary>
/// Task任务状态结果
/// </summary>
public
enum
TaskResultStatus
...
...
Server/Infrastructure/Repositories/Siger.Middlelayer.AccRepository/Entities/siger_automation_task_list.cs
View file @
5649cfdc
...
...
@@ -16,11 +16,11 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary>
public
int
sectionid
{
get
;
set
;
}
/// <summary>
/// 触发方式
/// 触发方式
产生TASK
/// </summary>
public
TaskTrigerType
trigger
{
get
;
set
;
}
/// <summary>
/// 任务类型
/// 任务类型
load ,unload
/// </summary>
public
TaskActionType
tasktype
{
get
;
set
;
}
/// <summary>
...
...
@@ -53,12 +53,12 @@ namespace Siger.Middlelayer.AccRepository.Entities
public
int
fixturetools
{
get
;
set
;
}
/// <summary>
/// 动作类型 1 手动 2 自动
///
Task 执行
动作类型 1 手动 2 自动
/// </summary>
public
TaskTriger
Type
actiontype
{
get
;
set
;
}
public
Excue
Type
actiontype
{
get
;
set
;
}
/// <summary>
///
动作
///
Task 动作执行
/// </summary>
public
TaskAction
action
{
get
;
set
;
}
...
...
Server/Infrastructure/Repositories/Siger.Middlelayer.AccRepository/Repositories/AutomationTaskListRepository.cs
View file @
5649cfdc
...
...
@@ -4,8 +4,11 @@ using System.Linq.Expressions;
using
Microsoft.EntityFrameworkCore
;
using
Siger.Middlelayer.AccRepository.Entities
;
using
Siger.Middlelayer.AccRepository.Repositories.Interface
;
using
Siger.Middlelayer.Common.Helpers
;
using
Siger.Middlelayer.Repository.Data.Acc
;
using
Siger.Middlelayer.Repository.Paged
;
using
Siger.Middlelayer.Share.Enum.ModuleEnum
;
using
static
Siger
.
Middlelayer
.
Share
.
Enum
.
ModuleEnum
.
Automation
;
namespace
Siger.Middlelayer.AccRepository.Repositories
{
...
...
@@ -16,5 +19,31 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{
_context
=
context
;
}
public
bool
CanTask
(
int
projectId
,
int
section
)
{
var
taskObj
=
_context
.
siger_automation_task_list
.
FirstOrDefault
(
f
=>
f
.
projectId
==
projectId
&&
f
.
status
>=
(
int
)
TaskResultStatus
.
Cancel
&&
f
.
status
<
(
int
)
TaskResultStatus
.
Complated
);
if
(
taskObj
==
null
)
return
true
;
else
return
false
;
}
public
string
CrateTaskNumber
(
TaskTrigerType
trigerType
)
{
var
date
=
DateTime
.
Now
;
var
lable
=
date
.
ToString
(
UnixTimeHelper
.
DateTimeFormatYmd
)+
date
.
Hour
+
date
.
Minute
+
date
.
Second
+
date
.
Millisecond
;
var
radon
=
new
Random
().
Next
(
1000
,
9999
);
if
(
trigerType
==
TaskTrigerType
.
Auto
)
{
return
$"A
{
radon
}
T
{
lable
}
"
;
}
else
{
return
$"M
{
radon
}
T
{
lable
}
"
;
}
}
}
}
Server/Infrastructure/Repositories/Siger.Middlelayer.AccRepository/Repositories/Interface/IAutomationTaskListRepository.cs
View file @
5649cfdc
using
Siger.Middlelayer.AccRepository.Entities
;
using
Siger.Middlelayer.Repository.Data.Acc
;
using
Siger.Middlelayer.Repository.Paged
;
using
static
Siger
.
Middlelayer
.
Share
.
Enum
.
ModuleEnum
.
Automation
;
namespace
Siger.Middlelayer.AccRepository.Repositories.Interface
{
public
interface
IAutomationTaskListRepository
:
IAccRepositoryBase
<
siger_automation_task_list
>
{
string
CrateTaskNumber
(
TaskTrigerType
trigerType
);
/// <summary>
/// 是否能创建任务
/// </summary>
/// <param name="projectId"></param>
/// <param name="section"></param>
/// <returns></returns>
bool
CanTask
(
int
projectId
,
int
section
);
}
}
Server/Infrastructure/Repositories/Siger.Middlelayer.AccRepository/Response/ResponseAutomationInfo.cs
View file @
5649cfdc
...
...
@@ -18,6 +18,7 @@ namespace Siger.Middlelayer.AccRepository.Response
public
string
sn
{
get
;
set
;
}
public
int
status
{
get
;
set
;
}
public
int
statusDesc
{
get
;
set
;
}
public
int
location
{
get
;
set
;
}
/// <summary>
/// 储位位置
/// </summary>
...
...
Server/Infrastructure/Script/DB.script
View file @
5649cfdc
...
...
@@ -379,4 +379,27 @@ CREATE TABLE `siger_automation_line_mode` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- 生产线模式
-- Table structure for siger_automation_produce_history
-- ----------------------------
DROP TABLE IF EXISTS `siger_automation_produce_history`;;
CREATE TABLE `siger_automation_produce_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`statusid` int(11) NOT NULL DEFAULT 0 COMMENT '设备状态ID',
`section` int(11) NOT NULL DEFAULT 0 COMMENT '产线ID',
`projectid` int(11) NOT NULL DEFAULT 0,
`productid` int(1) NOT NULL DEFAULT 1 COMMENT '产品ID',
`productcode` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '产品编号',
`productname` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '产品名称',
`locationid` int(11) NOT NULL DEFAULT 0 COMMENT '储位ID',
`locationname` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '储位名称',
`sn` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工件编号',
`route` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工序',
`updatetime` datetime(0) NULL DEFAULT NULL COMMENT '操作时间',
`status` int(1) NOT NULL DEFAULT 1 COMMENT '',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment