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
b8279a53
Commit
b8279a53
authored
Jan 20, 2021
by
jiawei.su
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
someupdate
parent
0aa7939e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
165 additions
and
17 deletions
+165
-17
AutomationController.cs
Server/Apis/Siger.ApiACC/Controllers/AutomationController.cs
+108
-4
AccDictCost.cs
...er/Common/Siger.Middlelayer.Share/Constant/AccDictCost.cs
+8
-0
DictKeyValConst.cs
...ommon/Siger.Middlelayer.Share/Constant/DictKeyValConst.cs
+13
-0
AccEnum.cs
...Common/Siger.Middlelayer.Share/Enum/ModuleEnum/AccEnum.cs
+3
-1
Automation.cs
...mon/Siger.Middlelayer.Share/Enum/ModuleEnum/Automation.cs
+12
-1
siger_automation_task_list.cs
...ayer.AccRepository/Entities/siger_automation_task_list.cs
+16
-7
DB.script
Server/Infrastructure/Script/DB.script
+5
-4
No files found.
Server/Apis/Siger.ApiACC/Controllers/AutomationController.cs
View file @
b8279a53
...
...
@@ -3,27 +3,38 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.CodeAnalysis
;
using
Siger.Middlelayer.AccRepository.Entities
;
using
Siger.Middlelayer.AccRepository.Repositories.Interface
;
using
Siger.Middlelayer.AccRepository.Request
;
using
Siger.Middlelayer.Common
;
using
Siger.Middlelayer.Common.Log
;
using
Siger.Middlelayer.Common.ModuleEnum
;
using
Siger.Middlelayer.Repository
;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
using
Siger.Middlelayer.Repository.Repositories.Interface
;
using
Siger.Middlelayer.Share.Constant
;
using
Siger.Middlelayer.Share.Enum.ModuleEnum
;
using
static
Siger
.
Middlelayer
.
Share
.
Enum
.
ModuleEnum
.
Automation
;
namespace
Siger.ApiACC.Controllers
{
public
class
AutomationController
:
LaisiBaseController
{
private
readonly
IUnitOfWork
_unitOfWork
;
private
readonly
ISigerProjectLevelSectionRepository
_sigerProjectLevelSection
;
private
readonly
IAutomationLineMode
_automationLineMode
;
private
readonly
IAutomationMachineStatus
_automationMachineStatus
;
private
readonly
ISigerDict
_sigerDict
;
private
readonly
IAutomationTaskListRepository
_automationTaskList
;
public
AutomationController
(
IUnitOfWork
unitOfWork
,
I
AutomationLineMode
automationLineMode
,
IAutomationMachineStatus
automationMachineStatus
)
public
AutomationController
(
IUnitOfWork
unitOfWork
,
I
SigerProjectLevelSectionRepository
sigerProjectLevelSection
,
IAutomationLineMode
automationLineMode
,
IAutomationMachineStatus
automationMachineStatus
,
ISigerDict
sigerDict
,
IAutomationTaskListRepository
automationTaskList
)
{
_unitOfWork
=
unitOfWork
;
_sigerProjectLevelSection
=
sigerProjectLevelSection
;
_automationLineMode
=
automationLineMode
;
_automationMachineStatus
=
automationMachineStatus
;
_sigerDict
=
sigerDict
;
_automationTaskList
=
automationTaskList
;
}
/// <summary>
...
...
@@ -63,10 +74,103 @@ namespace Siger.ApiACC.Controllers
/// <returns></returns>
public
IActionResult
TaskResult
([
FromBody
]
RequestAutomationTaskResult
request
)
{
//1.检查Tasklist
var
taskObj
=
_automationTaskList
.
Get
(
f
=>
f
.
guid
==
request
.
guid
);
if
(
taskObj
==
null
)
{
throw
new
BadRequestException
(
CommonEnum
.
RecordNotFound
);
}
if
(
taskObj
.
status
==(
int
)
TaskResultStatus
.
Complated
)
{
throw
new
BadRequestException
(
AccEnum
.
AutoTaskDone
);
}
//2.更新状态
taskObj
.
status
=
request
.
status
;
if
(
_unitOfWork
.
Commit
()
<=
0
)
{
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
}
return
new
ObjectResult
(
"1"
);
//是否还有未完成任务
var
taskDone
=
_automationTaskList
.
Get
(
f
=>
f
.
projectId
==
PID
&&
f
.
status
>
(
int
)
TaskResultStatus
.
Cancel
&&
f
.
status
<
(
int
)
TaskResultStatus
.
Complated
);
if
(
taskDone
!=
null
)
{
//还有未完成任务 退出 等待任务下发
return
new
ObjectResult
(
CommonEnum
.
Succefull
);
}
//3.Tasklist 任务全部完成 ,创建自动任务
switch
(
request
.
status
)
{
case
(
int
)
TaskResultStatus
.
Cancel
:
case
(
int
)
TaskResultStatus
.
Complated
:
{
CreateAutoTask
(
taskObj
);
break
;
}
case
(
int
)
TaskResultStatus
.
Waiting
:
case
(
int
)
TaskResultStatus
.
Produce
:
default
:
{
break
;
}
}
return
new
ObjectResult
(
CommonEnum
.
Succefull
);
}
/// <summary>
/// 创建自动 Task任务
/// </summary>
/// <param name="tasklist"></param>
void
CreateAutoTask
(
siger_automation_task_list
tasklist
)
{
var
section
=
_sigerProjectLevelSection
.
Get
(
f
=>
f
.
id
==
tasklist
.
startsection
);
if
(
section
==
null
)
{
Logger
.
WriteLineInfo
(
$"CreateAutoTask 工站未找到"
);
throw
new
BadRequestException
(
RequestEnum
.
LevelSectionNotFound
);
}
var
lineMode
=
_automationLineMode
.
Get
(
f
=>
f
.
projectId
==
PID
&&
f
.
section
==
section
.
parentid
);
if
(
lineMode
==
null
)
{
Logger
.
WriteLineInfo
(
$"CreateAutoTask 产线未找到"
);
throw
new
BadRequestException
(
RequestEnum
.
LevelSectionNotFound
);
}
if
(
lineMode
.
mode
==
0
)
{
Logger
.
WriteLineInfo
(
$"CreateAutoTask 手动模式"
);
//手动模式时 退出
return
;
}
var
machineList
=
_automationMachineStatus
.
GetList
(
f
=>
f
.
projectId
==
PID
&&
f
.
enable
==
1
);
//自动Task任务 顺序
//1.清洗机下料
//2.其他设备上料
//3.其他设备下料
var
stationDicts
=
_sigerDict
.
GetDataByCat
(
AccDictCost
.
Automation
,
PID
);
if
(!
stationDicts
.
Any
())
{
Logger
.
WriteLineInfo
(
$"CreateAutoTask 未配置设备类型字典"
);
return
;
}
var
dictClean
=
stationDicts
.
FirstOrDefault
(
s
=>
s
.
dkey
==
DictKeyValConst
.
CleanStation
);
if
(
dictClean
==
null
)
{
Logger
.
WriteLineInfo
(
$"CreateAutoTask 未配置清洗机字典"
);
return
;
}
}
/// <summary>
/// 产线模式 0:手动模式 /1:自动模式(产生自动任务)
/// </summary>
...
...
Server/Common/Siger.Middlelayer.Share/Constant/AccDictCost.cs
View file @
b8279a53
...
...
@@ -63,6 +63,12 @@ namespace Siger.Middlelayer.Common
/// 罗美特分类
/// </summary>
public
const
string
FlowMetek
=
"FlowMetek"
;
/// <summary>
/// MES 自动线类型
/// </summary>
public
const
string
Automation
=
"automation"
;
}
public
class
AccDictCostNoProjectId
...
...
@@ -102,4 +108,6 @@ namespace Siger.Middlelayer.Common
/// </summary>
public
const
string
outgoing_type
=
"outgoing_type"
;
}
}
Server/Common/Siger.Middlelayer.Share/Constant/DictKeyValConst.cs
View file @
b8279a53
...
...
@@ -28,5 +28,18 @@ namespace Siger.Middlelayer.Share.Constant
/// 表头 工站
/// </summary>
public
const
string
EleHeader
=
"EleHeader"
;
/// <summary>
/// automation key:清洗工站
/// </summary>
public
const
string
CleanStation
=
"CleanStation"
;
/// <summary>
/// key:上料工站
/// </summary>
public
const
string
UploadloadStation
=
"UploadloadStation"
;
/// <summary>
/// key:下料工站
/// </summary>
public
const
string
DownloadStation
=
"DownloadStation"
;
}
}
Server/Common/Siger.Middlelayer.Share/Enum/ModuleEnum/AccEnum.cs
View file @
b8279a53
...
...
@@ -314,7 +314,9 @@ namespace Siger.Middlelayer.Common.ModuleEnum
[
Description
(
"序号规则未配置"
)]
SerinumCfgEmpty
,
[
Description
(
"序号已全部生成"
)]
SerinumFull
SerinumFull
,
[
Description
(
"该任务状态已经完成"
)]
AutoTaskDone
...
...
Server/Common/Siger.Middlelayer.Share/Enum/ModuleEnum/Automation.cs
View file @
b8279a53
...
...
@@ -8,7 +8,7 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
public
class
Automation
{
/// <summary>
/// 任务触发
类型
/// 任务触发
方式 1 手动 2 自动
/// </summary>
public
enum
TaskTrigerType
{
...
...
@@ -61,6 +61,17 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
/// </summary>
Complated
=
3
}
/// <summary>
/// 动作类型 1:load 2:Unload
/// </summary>
public
enum
TaskActionType
{
[
Description
(
"Load"
)]
Load
=
1
,
[
Description
(
"Unload"
)]
Unload
=
2
}
/// <summary>
/// 动作
/// </summary>
...
...
Server/Infrastructure/Repositories/Siger.Middlelayer.AccRepository/Entities/siger_automation_task_list.cs
View file @
b8279a53
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
static
Siger
.
Middlelayer
.
Share
.
Enum
.
ModuleEnum
.
Automation
;
namespace
Siger.Middlelayer.AccRepository.Entities
{
...
...
@@ -15,13 +16,13 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary>
public
string
sectionid
{
get
;
set
;
}
/// <summary>
/// 触发方
/// 触发方
式
/// </summary>
public
int
trigger
{
get
;
set
;
}
public
TaskTrigerType
trigger
{
get
;
set
;
}
/// <summary>
/// 任务类型
/// </summary>
public
string
tasktype
{
get
;
set
;
}
public
TaskActionType
tasktype
{
get
;
set
;
}
/// <summary>
/// 发起工位
/// </summary>
...
...
@@ -54,18 +55,26 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 工装GUID
/// </summary>
public
int
fixturetools
{
get
;
set
;
}
/// <summary>
/// 动作类型 1 手动 2 自动
/// </summary>
public
TaskTrigerType
actiontype
{
get
;
set
;
}
/// <summary>
/// 动作
/// </summary>
public
int
action
{
get
;
set
;
}
public
TaskAction
action
{
get
;
set
;
}
/// <summary>
///
动作类型
///
是否已下发PLC 0:未下发 1:已下发
/// </summary>
public
DateTime
?
actiontype
{
get
;
set
;
}
public
int
send
{
get
;
set
;
}
/// <summary>
/// 触发时间
/// </summary>
public
string
triggertime
{
get
;
set
;
}
public
DateTime
triggertime
{
get
;
set
;
}
/// <summary>
/// 完成时间
/// </summary>
...
...
Server/Infrastructure/Script/DB.script
View file @
b8279a53
...
...
@@ -318,8 +318,8 @@ CREATE TABLE IF NOT EXISTS `siger_automation_task_list` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`guid` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`sectionid` int(11) NOT NULL DEFAULT 0 COMMENT '工位ID',
`trigger` int(1
1
) NOT NULL DEFAULT 0 COMMENT '触发方',
`tasktype`
varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
COMMENT '任务类型',
`trigger` int(1) NOT NULL DEFAULT 0 COMMENT '触发方',
`tasktype`
int(1) NOT NULL DEFAULT 0
COMMENT '任务类型',
`startsection` int(11) NOT NULL DEFAULT 0 COMMENT '发起工位',
`materialid` int(11) NOT NULL DEFAULT 0 COMMENT '工件ID',
`ordercode` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工单号',
...
...
@@ -328,10 +328,11 @@ CREATE TABLE IF NOT EXISTS `siger_automation_task_list` (
`programnumber` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '程序号',
`locationid` int(11) NOT NULL COMMENT '储位位置',
`fixturetools` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工装GUID',
`action`
varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
COMMENT '动作',
`action`
int(1) int(11) NOT NULL DEFAULT 0
COMMENT '动作',
`actiontype` int(11) NOT NULL DEFAULT 0 COMMENT '动作类型',
`projectid` int(11) NOT NULL DEFAULT 0,
`status` int(11) NOT NULL DEFAULT 1 COMMENT '状态',
`send` int(1) NOT NULL DEFAULT 0 COMMENT '0:未下发 1:已下发',
`status` int(11) NOT NULL DEFAULT 1 COMMENT '任务进度状态:0 取消 1待生产 2生产中 3生产完成',
`triggertime` datetime(0) NOT NULL COMMENT '触发时间',
`completetime` datetime(0) NULL DEFAULT NULL COMMENT '完成时间',
`operater` int(11) NOT NULL DEFAULT 0 COMMENT '操作人',
...
...
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