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
ca66dc14
Commit
ca66dc14
authored
Jan 23, 2021
by
jiawei.su
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
someupdate
parent
ec6ca0ab
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
197 additions
and
42 deletions
+197
-42
AccRegistry.cs
Server/Apis/Siger.ApiACC/Tasks/AccRegistry.cs
+3
-1
AutoMES.cs
Server/Apis/Siger.ApiACC/Tasks/AutoMES.cs
+95
-5
DBhelper.cs
Server/Apis/Siger.ApiACC/Tasks/DBhelper.cs
+38
-12
CncRegistry.cs
Server/Apis/Siger.ApiCNC/Tasks/CncRegistry.cs
+1
-1
CommonConst.cs
...er/Common/Siger.Middlelayer.Share/Constant/CommonConst.cs
+2
-0
RequestPLC.cs
...ies/Siger.Middlelayer.AccRepository/Request/RequestPLC.cs
+44
-0
DB.script
Server/Infrastructure/Script/DB.script
+14
-23
No files found.
Server/Apis/Siger.ApiACC/Tasks/AccRegistry.cs
View file @
ca66dc14
using
FluentScheduler
;
using
NPOI.SS.Formula.Functions
;
using
Siger.Middlelayer.Log
;
using
Module
=
Siger
.
Middlelayer
.
Common
.
Module
;
...
...
@@ -11,7 +12,8 @@ namespace Siger.ApiACC.Tasks
//Logger.RegisterLogEngine(Module.Acc);
//Schedule<AccCalculateTraceJob>().ToRunNow().AndEvery(30).Minutes();
Logger
.
RegisterTxtLogEngine
(
Module
.
Acc
);
Schedule
<
AutoMES
>().
ToRunNow
().
AndEvery
(
10
).
Seconds
();
}
}
}
Server/Apis/Siger.ApiACC/Tasks/AutoMES.cs
View file @
ca66dc14
using
FluentScheduler
;
using
Newtonsoft.Json
;
using
Siger.Middlelayer.AccRepository.Request
;
using
Siger.Middlelayer.Common
;
using
Siger.Middlelayer.Common.Configuration
;
using
Siger.Middlelayer.Common.Helpers
;
using
Siger.Middlelayer.Common.Log
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -12,19 +18,103 @@ namespace Siger.ApiACC.Tasks
public
void
Execute
()
{
throw
new
NotImplementedException
();
Logger
.
WriteLineInfo
(
$"execute mes job"
);
var
projectId
=
GetProjectId
();
var
hostDic
=
GetHost
();
if
(
projectId
==
0
||
!
hostDic
.
Any
())
{
Logger
.
WriteLineInfo
(
$"配置未完整"
);
return
;
}
using
(
DBhelper
dbhelper
=
new
DBhelper
())
{
var
tasklist
=
dbhelper
.
GetTaskList
(
projectId
);
if
(!
tasklist
.
Any
())
{
Logger
.
WriteLineInfo
(
$"无任务下发"
);
return
;
}
var
tasks
=
tasklist
.
OrderBy
(
s
=>
s
.
actiontype
);
var
task
=
tasks
.
FirstOrDefault
();
var
sendToPLC
=
new
RequestPLC
{
RStation
=
task
.
sectionid
,
Fixture
=
task
.
fixtureguid
,
RequestForm
=
task
.
no
,
RobotStep
=
(
int
)
task
.
action
,
StorageNo
=
task
.
locationid
,
SN
=
task
.
sn
,
Program
=
task
.
programnumber
};
var
result
=
PushTask
(
hostDic
,
sendToPLC
,
out
string
message
);
if
(!
result
)
{
Logger
.
WriteLineError
(
$"TASK 下发失败 :
{
message
}
"
);
return
;
}
task
.
send
=
1
;
if
(!
dbhelper
.
UpdateTask
(
task
))
{
Logger
.
WriteLineError
(
$"更新TASK 下发状态失败"
);
}
}
}
public
void
Dispose
()
{
throw
new
NotImplementedException
();
}
/// <summary>
/// 下发任务
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
/// <param name="request"></param>
/// <param name="msg"></param>
private
bool
PushTask
(
string
ip
,
RequestPLC
request
,
out
string
msg
)
{
msg
=
string
.
Empty
;
try
{
var
param
=
JsonHelper
.
SerializerToJsonString
(
request
);
var
retstring
=
HttpHelper
.
HttpPost
(
$"
{
ip
}{
CommonConst
.
SenTaskToMES
}
"
,
"application/json"
,
param
);
var
result
=
JsonConvert
.
DeserializeObject
<
ResponsePlC
>(
retstring
);
if
(
result
.
return_code
!=
0
)
{
msg
=
$"PushTask failed,URL
{
ip
}
input:
{
param
}
result :
{
result
.
return_desc
}
"
;
return
false
;
}
return
true
;
}
catch
(
Exception
ex
)
{
msg
=
ex
.
ToString
();
}
return
false
;
}
//获取TaskList
private
List
<
int
>
GetTaskList
()
private
int
GetProjectId
()
{
var
_pid
=
ConfigManager
.
GetValue
(
"ProjectSetting"
,
"ProjectId"
,
string
.
Empty
);
if
(
string
.
IsNullOrEmpty
(
_pid
))
Logger
.
WriteLineError
(
"DbSetting about [ProjectSetting] ProjectId not found."
);
return
int
.
Parse
(
_pid
);
}
private
string
GetHost
()
{
var
host
=
ConfigManager
.
GetValue
(
"ProjectSetting"
,
"Host"
,
string
.
Empty
);
if
(
string
.
IsNullOrEmpty
(
host
))
{
Logger
.
WriteLineError
(
"DbSetting about [ProjectSetting] Host not found."
);
return
null
;
}
return
host
;
return
new
List
<
int
>();
}
}
}
Server/Apis/Siger.ApiACC/Tasks/DBhelper.cs
View file @
ca66dc14
using
Siger.Middlelayer.AccRepository
;
using
Siger.Middlelayer.AccRepository.Entities
;
using
Siger.Middlelayer.CncRepository
;
using
Siger.Middlelayer.Repository
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
static
Siger
.
Middlelayer
.
Share
.
Enum
.
ModuleEnum
.
Automation
;
namespace
Siger.ApiACC.Tasks
{
public
class
DBhelper
public
class
DBhelper
:
IDisposable
{
private
static
DBhelper
_helper
;
public
static
DBhelper
Instance
=
_helper
??
(
_helper
=
new
DBhelper
());
p
ublic
ApiCncDbContext
CncDbContext
;
p
ublic
ApiAccDbContext
AccDbContext
;
p
ublic
ApiConfigDbContext
ConfigDbContext
;
p
rivate
readonly
ApiCncDbContext
CncDbContext
;
p
rivate
readonly
ApiAccDbContext
AccDbContext
;
p
rivate
readonly
ApiConfigDbContext
ConfigDbContext
;
static
DBhelper
()
{
}
public
void
LoadDbContext
()
public
DBhelper
()
{
CncDbContext
=
new
ApiCncDbContext
();
AccDbContext
=
new
ApiAccDbContext
();
ConfigDbContext
=
new
ApiConfigDbContext
();
}
public
List
<
int
>
GetTaskList
()
internal
bool
CanTask
(
int
projectId
,
int
section
)
{
return
new
List
<
int
>();
var
taskObj
=
AccDbContext
.
siger_automation_task_list
.
FirstOrDefault
(
f
=>
f
.
projectId
==
projectId
&&
f
.
status
>=
(
int
)
TaskResultStatus
.
Cancel
&&
f
.
status
<
(
int
)
TaskResultStatus
.
Complated
);
if
(
taskObj
==
null
)
return
true
;
else
return
false
;
}
/// <summary>
/// 获取未推送tasklist
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public
IEnumerable
<
siger_automation_task_list
>
GetTaskList
(
int
projectId
)
{
var
taskObjs
=
AccDbContext
.
siger_automation_task_list
.
Where
(
f
=>
f
.
projectId
==
projectId
&&
f
.
send
==
0
&&
f
.
status
>=
(
int
)
TaskResultStatus
.
Cancel
&&
f
.
status
<
(
int
)
TaskResultStatus
.
Complated
);
return
taskObjs
;
}
public
siger_automation_fixture_tools_monitor
GetMonitor
(
int
section
)
{
return
AccDbContext
.
siger_automation_fixture_tools_moniter
.
FirstOrDefault
(
f
=>
f
.
section
==
section
);
}
public
bool
UpdateTask
(
siger_automation_task_list
taskNo
)
{
AccDbContext
.
siger_automation_task_list
.
Update
(
taskNo
);
return
AccDbContext
.
SaveChanges
()
>
0
;
}
public
void
Dispose
()
{
...
...
@@ -37,5 +62,6 @@ namespace Siger.ApiACC.Tasks
AccDbContext
?.
Dispose
();
ConfigDbContext
?.
Dispose
();
}
}
}
Server/Apis/Siger.ApiCNC/Tasks/CncRegistry.cs
View file @
ca66dc14
...
...
@@ -9,7 +9,7 @@ namespace Siger.ApiCNC.Tasks
{
public
CncRegistry
()
{
Schedule
<
ProduceEfficiencyJob
>().
ToRunNow
().
AndEvery
(
1
).
Days
().
At
(
3
,
0
);
//
Schedule<ProduceEfficiencyJob>().ToRunNow().AndEvery(1).Days().At(3,0);
}
}
}
Server/Common/Siger.Middlelayer.Share/Constant/CommonConst.cs
View file @
ca66dc14
...
...
@@ -105,5 +105,7 @@
/// 罗美特追溯附件 存放路径
/// </summary>
public
const
string
MetekAttachmentFilePath
=
"attachment"
;
public
const
string
SenTaskToMES
=
"/distributiontask"
;
}
}
Server/Infrastructure/Repositories/Siger.Middlelayer.AccRepository/Request/RequestPLC.cs
0 → 100644
View file @
ca66dc14
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Siger.Middlelayer.AccRepository.Request
{
public
class
RequestPLC
{
/// <summary>
/// 工件唯一识别SN
/// </summary>
public
String
SN
{
get
;
set
;
}
/// <summary>
/// 工装唯一编号GUID
/// </summary>
public
string
Fixture
{
get
;
set
;
}
/// <summary>
/// 任务唯一编号
/// </summary>
public
string
RequestForm
{
get
;
set
;
}
/// <summary>
/// 机器人动作指令
/// </summary>
public
int
RobotStep
{
get
;
set
;
}
/// <summary>
/// 发起地
/// </summary>
public
int
RStation
{
get
;
set
;
}
/// <summary>
/// 储位位置编号
/// </summary>
public
int
StorageNo
{
get
;
set
;
}
/// <summary>
/// 加工程序号 ,上料完成后自动加工需要
/// </summary>
public
string
Program
{
get
;
set
;
}
}
public
class
ResponsePlC
{
public
int
return_code
{
get
;
set
;
}
public
string
return_desc
{
get
;
set
;
}
}
}
Server/Infrastructure/Script/DB.script
View file @
ca66dc14
...
...
@@ -351,19 +351,22 @@ CREATE TABLE IF NOT EXISTS `siger_automation_task_list` (
-- ----------------------------
-- 设备可用状态
-- Table structure for siger_automation_
task_list
-- Table structure for siger_automation_
machine_status
-- ----------------------------
DROP TABLE IF EXISTS `siger_automation_machine_status`;
CREATE TABLE `siger_automation_machine_status` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`section` int(11) NOT NULL DEFAULT 0 COMMENT '工位ID',
`machineid` int(11) NOT NULL DEFAULT 0 COMMENT '工位对应设备ID',
`projectid` int(11) NOT NULL DEFAULT 0,
`enable` int(1) NOT NULL DEFAULT 1 COMMENT '设备可用状态 0:不可用 1:可用',
`status` int(1) NOT NULL DEFAULT 1 COMMENT '完工状态 0:取消 1:待生产 2:生产中 3:生产完成 ',
`updatetime` datetime(0) NULL DEFAULT NULL COMMENT '操作时间',
CREATE TABLE `siger_automation_machine_status` (
`id` int NOT NULL AUTO_INCREMENT,
`section` int NOT NULL DEFAULT '0' COMMENT '工位ID',
`machineid` int NOT NULL DEFAULT '0' COMMENT '工位对应设备ID',
`projectid` int NOT NULL DEFAULT '0',
`enable` int NOT NULL DEFAULT '1' COMMENT '设备可用状态 0:不可用 1:可用',
`status` int NOT NULL DEFAULT '1' COMMENT '完工状态 0:取消 1:待生产 2:生产中 3:生产完成 ',
`updatetime` datetime DEFAULT NULL COMMENT '操作时间',
`program` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '程序号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
SET FOREIGN_KEY_CHECKS=1;
-- ----------------------------
...
...
@@ -428,18 +431,6 @@ CREATE TABLE `siger_automation_fixture_tools_moniter` (
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `siger_automation_machine_status`;
CREATE TABLE `siger_automation_machine_status` (
`id` int NOT NULL AUTO_INCREMENT,
`section` int NOT NULL DEFAULT '0' COMMENT '工位ID',
`machineid` int NOT NULL DEFAULT '0' COMMENT '工位对应设备ID',
`projectid` int NOT NULL DEFAULT '0',
`enable` int NOT NULL DEFAULT '1' COMMENT '设备可用状态 0:不可用 1:可用',
`status` int NOT NULL DEFAULT '1' COMMENT '完工状态 0:取消 1:待生产 2:生产中 3:生产完成 ',
`updatetime` datetime DEFAULT NULL COMMENT '操作时间',
`program` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '程序号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
SET FOREIGN_KEY_CHECKS=1;
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