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
7f13f955
Commit
7f13f955
authored
Feb 08, 2021
by
chenzhengpeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code repo
parent
91115f3c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
43 deletions
+88
-43
AutomationController.cs
Server/Apis/Siger.ApiACC/Controllers/AutomationController.cs
+0
-0
AutomationTaskListRepository.cs
...ccRepository/Repositories/AutomationTaskListRepository.cs
+88
-43
No files found.
Server/Apis/Siger.ApiACC/Controllers/AutomationController.cs
View file @
7f13f955
This diff is collapsed.
Click to expand it.
Server/Infrastructure/Repositories/Siger.Middlelayer.AccRepository/Repositories/AutomationTaskListRepository.cs
View file @
7f13f955
using
System
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq.Expressions
;
...
...
@@ -25,18 +26,18 @@ namespace Siger.Middlelayer.AccRepository.Repositories
_context
=
context
;
}
public
bool
CanTask
(
int
projectId
,
int
section
)
public
bool
CanTask
(
int
projectId
,
int
section
)
{
//已经下发,并且任务完成
var
taskObjs
=
_context
.
siger_automation_task_list
.
Where
(
f
=>
f
.
projectId
==
projectId
&&
f
.
send
==
0
);
var
taskObjs
=
_context
.
siger_automation_task_list
.
Where
(
f
=>
f
.
projectId
==
projectId
&&
f
.
send
==
0
);
if
(
taskObjs
.
Any
())
{
return
false
;
}
else
{
var
unDolist
=
_context
.
siger_automation_task_list
.
Where
(
f
=>
f
.
send
==
1
&&
f
.
status
!=
(
int
)
TaskResultStatus
.
Complated
).
Count
();
if
(
unDolist
==
0
)
var
unDolist
=
_context
.
siger_automation_task_list
.
Where
(
f
=>
f
.
send
==
1
&&
f
.
status
!=
(
int
)
TaskResultStatus
.
Complated
).
Count
();
if
(
unDolist
==
0
)
return
true
;
else
return
false
;
...
...
@@ -51,18 +52,59 @@ namespace Siger.Middlelayer.AccRepository.Repositories
/// <returns></returns>
public
string
CrateTaskNumber
(
TaskTrigerType
trigerType
)
{
var
date
=
DateTime
.
Now
;
var
serinum
=
date
.
DayOfYear
+
date
.
Month
+
date
.
Day
+
date
.
Hour
+
date
.
Minute
+
date
.
Second
+
date
.
Millisecond
;
var
dayofyear
=
GetDayOfYear
(
date
);
if
(
trigerType
==
TaskTrigerType
.
Auto
)
//var date = DateTime.Now;
//var serinum = date.DayOfYear+date.Month +date.Day+ date.Hour + date.Minute + date.Second + date.Millisecond;
//var dayofyear = GetDayOfYear(date);
//if (trigerType== TaskTrigerType.Auto)
//{
// return $"A{date.Year}{dayofyear}{serinum}";
//}
//else
//{
// return $"M{date.Year}{dayofyear}{serinum}";
//}
if
(
trigerType
==
TaskTrigerType
.
Auto
)
{
return
$"A
{
date
.
Year
}{
dayofyear
}{
serinum
}
"
;
return
$"A
{
GetId
()
}
"
;
}
else
{
return
$"M
{
date
.
Year
}{
dayofyear
}{
serinum
}
"
;
return
$"M
{
GetId
()}
"
;
}
}
public
static
object
objLock
=
new
object
();
private
static
int
defaultStepLength
=
100
;
private
static
DateTime
dtStart
=
new
DateTime
(
2020
,
1
,
1
);
private
static
ConcurrentQueue
<
string
>
stackIds
=
new
ConcurrentQueue
<
string
>();
private
static
string
GetId
()
{
if
(
stackIds
.
Count
<=
0
)
{
lock
(
objLock
)
{
if
(
stackIds
.
Count
<=
0
)
{
var
dtTs
=
(
DateTime
.
Now
-
dtStart
).
Ticks
;
for
(
int
i
=
0
;
i
<
defaultStepLength
;
i
++)
{
//todo://增加机器信息;单机暂且放弃
stackIds
.
Enqueue
((
dtTs
+
i
).
ToString
());
}
}
}
}
if
(
stackIds
.
TryDequeue
(
out
string
actIds
))
{
return
actIds
;
}
else
{
throw
new
Exception
(
"Id生成器报错,队列异常;"
);
}
}
/// <summary>
/// 工件长度10 PLC 限制
/// </summary>
...
...
@@ -70,19 +112,22 @@ namespace Siger.Middlelayer.AccRepository.Repositories
/// <returns></returns>
public
string
CreateRandonSn
(
string
productCode
)
{
var
date
=
DateTime
.
Now
;
var
serinum
=
date
.
DayOfYear
+
date
.
Month
+
date
.
Day
+
date
.
Hour
+
date
.
Minute
+
date
.
Second
+
date
.
Millisecond
;
var
dayofyear
=
GetDayOfYear
(
date
);
var
lable
=
$"
{
date
.
Year
}{
dayofyear
}{
serinum
}
"
;
//var date = DateTime.Now;
//var seriNum = $"{date.ToString("HHmmssfff")}";
//var serinum = date.DayOfYear + date.Month + date.Day + date.Hour + date.Minute + date.Second + date.Millisecond;
//var dayofyear = GetDayOfYear(date);
//var lable = $"{date.Year}{dayofyear}{serinum}";
var
lable
=
$"
{
Math
.
Abs
(
productCode
.
GetHashCode
())}{
GetId
()}
"
;
return
lable
;
}
private
string
GetDayOfYear
(
DateTime
dt
)
{
var
lable
=
dt
.
DayOfYear
.
ToString
();
var
result
=
string
.
Empty
;
for
(
int
i
=
0
;
i
<
3
-
lable
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
3
-
lable
.
Length
;
i
++)
{
result
+=
"0"
;
result
+=
"0"
;
}
return
$"
{
result
}{
lable
}
"
;
...
...
@@ -100,39 +145,39 @@ namespace Siger.Middlelayer.AccRepository.Repositories
where
q
.
projectId
==
projectid
select
new
ResponseAutomationTasklist
{
id
=
q
.
id
,
taskno
=
q
.
no
,
sectionid
=
q
.
sectionid
,
section
=
$"
{
lv
.
title
}
-
{
s
.
title
}
"
,
trigger
=
EnumHelper
.
GetEnumDesc
(
q
.
trigger
),
triggervalue
=
q
.
triggertime
,
triggerTime
=
q
.
triggertime
==
DateTime
.
MinValue
?
""
:
q
.
triggertime
.
ToString
(),
complatevalue
=
q
.
completetime
,
complatetime
=
q
.
completetime
==
DateTime
.
MinValue
?
""
:
q
.
completetime
.
ToString
(),
action
=
EnumHelper
.
GetEnumDesc
(
q
.
action
),
actionType
=
EnumHelper
.
GetEnumDesc
(
q
.
actiontype
),
fixtureCode
=
t
.
code
,
fixtureName
=
t
.
name
,
location
=
q
.
locationid
.
ToString
(),
sn
=
q
.
sn
,
ordernumber
=
q
.
ordercode
,
productCode
=
q
.
productcode
,
program
=
q
.
programnumber
,
route
=
r
!=
null
?
$"
{
r
.
serialNumber
}
-
{
r
.
name
}
"
:
""
,
send
=
q
.
send
,
tasktype
=
EnumHelper
.
GetEnumDesc
(
q
.
tasktype
),
id
=
q
.
id
,
taskno
=
q
.
no
,
sectionid
=
q
.
sectionid
,
section
=
$"
{
lv
.
title
}
-
{
s
.
title
}
"
,
trigger
=
EnumHelper
.
GetEnumDesc
(
q
.
trigger
),
triggervalue
=
q
.
triggertime
,
triggerTime
=
q
.
triggertime
==
DateTime
.
MinValue
?
""
:
q
.
triggertime
.
ToString
(),
complatevalue
=
q
.
completetime
,
complatetime
=
q
.
completetime
==
DateTime
.
MinValue
?
""
:
q
.
completetime
.
ToString
(),
action
=
EnumHelper
.
GetEnumDesc
(
q
.
action
),
actionType
=
EnumHelper
.
GetEnumDesc
(
q
.
actiontype
),
fixtureCode
=
t
.
code
,
fixtureName
=
t
.
name
,
location
=
q
.
locationid
.
ToString
(),
sn
=
q
.
sn
,
ordernumber
=
q
.
ordercode
,
productCode
=
q
.
productcode
,
program
=
q
.
programnumber
,
route
=
r
!=
null
?
$"
{
r
.
serialNumber
}
-
{
r
.
name
}
"
:
""
,
send
=
q
.
send
,
tasktype
=
EnumHelper
.
GetEnumDesc
(
q
.
tasktype
),
tasktypeid
=
Convert
.
ToInt32
(
q
.
tasktype
),
status
=
q
.
status
,
status
=
q
.
status
,
actionTypeid
=
Convert
.
ToInt32
(
q
.
actiontype
)
};
Expression
<
Func
<
ResponseAutomationTasklist
,
bool
>>
sectonsExpression
=
f
=>
true
;
if
(
sections
.
Any
())
{
sectonsExpression
=
q
=>
sections
.
Contains
(
q
.
sectionid
);
sectonsExpression
=
q
=>
sections
.
Contains
(
q
.
sectionid
);
}
Expression
<
Func
<
ResponseAutomationTasklist
,
bool
>>
taskTypeExpression
=
f
=>
true
;
if
(
taskType
!=
0
)
if
(
taskType
!=
0
)
{
taskTypeExpression
=
q
=>
q
.
tasktypeid
==
taskType
;
}
...
...
@@ -152,15 +197,15 @@ namespace Siger.Middlelayer.AccRepository.Repositories
snExpression
=
q
=>
q
.
sn
.
Contains
(
sn
);
}
Expression
<
Func
<
ResponseAutomationTasklist
,
bool
>>
actionTypeExpression
=
f
=>
true
;
if
(
actionType
!=
0
)
if
(
actionType
!=
0
)
{
actionTypeExpression
=
q
=>
q
.
actionTypeid
==
actionType
;
actionTypeExpression
=
q
=>
q
.
actionTypeid
==
actionType
;
}
Expression
<
Func
<
ResponseAutomationTasklist
,
bool
>>
triggerTimeTypeExpression
=
f
=>
true
;
if
(!
string
.
IsNullOrEmpty
(
triend
)
&&
!
string
.
IsNullOrEmpty
(
tirbeigin
))
{
triggerTimeTypeExpression
=
q
=>
q
.
triggervalue
>=
tirbeigin
.
ToDateTime
()
&&
q
.
triggervalue
<=
triend
.
ToDateTime
();
triggerTimeTypeExpression
=
q
=>
q
.
triggervalue
>=
tirbeigin
.
ToDateTime
()
&&
q
.
triggervalue
<=
triend
.
ToDateTime
();
}
Expression
<
Func
<
ResponseAutomationTasklist
,
bool
>>
comptimeExpression
=
f
=>
true
;
if
(!
string
.
IsNullOrEmpty
(
compbegin
)
&&
!
string
.
IsNullOrEmpty
(
compend
))
...
...
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