Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Leveraging blockchain usage to enhance slag exchange
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HyperCOG public
Leveraging blockchain usage to enhance slag exchange
Commits
9ca47c44
Commit
9ca47c44
authored
3 years ago
by
Gomez Goiri, Aitor
Browse files
Options
Downloads
Patches
Plain Diff
Estimating composition ranges after aggregating slags
parent
ca89295d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/batch-sim/index.js
+4
-1
4 additions, 1 deletion
apps/batch-sim/index.js
apps/sidenor-cli/lib.js
+69
-26
69 additions, 26 deletions
apps/sidenor-cli/lib.js
with
73 additions
and
27 deletions
apps/batch-sim/index.js
+
4
−
1
View file @
9ca47c44
...
...
@@ -27,7 +27,10 @@ const signInAs = async (apiClient, userMail, password) => {
const
createAssetAndSendToCone
=
async
(
apiClient
,
name
)
=>
{
const
assetId
=
await
createAsset
(
apiClient
,
name
)
await
editComposition
(
apiClient
,
{
assetId
})
await
editComposition
(
apiClient
,
{
assetId
,
caoPercentage
:
faker
.
datatype
.
number
({
min
:
40
,
max
:
70
})
})
return
sendToCone
(
apiClient
,
{
assetId
})
}
...
...
This diff is collapsed.
Click to expand it.
apps/sidenor-cli/lib.js
+
69
−
26
View file @
9ca47c44
...
...
@@ -15,7 +15,7 @@ const createAsset = async (apiClient, { assetName }) => {
id
:
`asst_
${
faker
.
datatype
.
uuid
()}
`
,
type
:
TYPES
.
RESIDUO_PROCESOS_TERMICOS
,
units
:
"
kg
"
,
quantity
:
faker
.
datatype
.
number
({
min
:
0
,
max
:
5000
}),
quantity
:
faker
.
datatype
.
number
({
min
:
40
0
,
max
:
5000
}),
fields
:
{
description
:
"
Escoria
"
,
name
:
assetName
,
...
...
@@ -69,6 +69,24 @@ const editComposition = async (
console
.
log
(
"
New composition measure for
"
,
assetId
)
}
const
updateBatchRange
=
(
batch
=
{},
individualSlag
=
{})
=>
{
const
{
cao
=
null
}
=
(
individualSlag
.
fields
||
{}).
composition
||
{}
const
{
cao
:
caoRange
=
null
}
=
(
batch
.
fields
||
{}).
composition
||
{}
if
(
cao
===
null
)
{
return
caoRange
}
if
(
caoRange
===
null
)
{
return
{
min
:
cao
,
max
:
cao
}
}
return
{
min
:
cao
<
caoRange
.
min
?
cao
:
caoRange
.
min
,
max
:
cao
>
caoRange
.
max
?
cao
:
caoRange
.
max
}
}
const
sendToCone
=
async
(
apiClient
,
{
assetId
:
paramAssetId
})
=>
{
const
assetId
=
paramAssetId
||
...
...
@@ -81,13 +99,12 @@ const sendToCone = async (apiClient, { assetId: paramAssetId }) => {
))
const
assetToBeSent
=
await
apiClient
.
getAsset
(
assetId
)
const
assetsInCone
=
await
apiClient
.
richQuery
({
const
[
firstAsset
=
false
]
=
await
apiClient
.
richQuery
({
fields
:
{
status
:
STATUSES
.
SLAG_BATCH
}
})
const
[
firstAsset
]
=
assetsInCone
const
newConeQuantity
=
assetToBeSent
.
quantity
+
(
firstAsset
?
firstAsset
.
quantity
:
0
)
...
...
@@ -97,29 +114,50 @@ const sendToCone = async (apiClient, { assetId: paramAssetId }) => {
{
parentsShouldExist
:
false
,
bidirectional
:
true
},
{
type
:
TYPES
.
RESIDUO_HIERRO_ACERO
,
location
:
assetsInCone
.
length
===
0
?
assetToBeSent
.
location
:
assetsInCone
[
0
].
location
,
location
:
firstAsset
?
firstAsset
.
location
:
assetToBeSent
.
location
,
units
:
"
kg
"
,
quantity
:
newConeQuantity
,
fields
:
{
name
:
"
Slag batch (in cone)
"
,
status
:
STATUSES
.
SLAG_BATCH
status
:
STATUSES
.
SLAG_BATCH
,
composition
:
{
cao
:
updateBatchRange
(
firstAsset
,
assetToBeSent
)
}
}
}
)
// Archive individual slag and previous cone
await
apiClient
.
deleteAsset
(
assetId
)
if
(
assetsInCone
.
length
>
0
)
await
apiClient
.
deleteAsset
(
assetsInCone
[
0
]
.
id
)
if
(
firstAsset
)
await
apiClient
.
deleteAsset
(
firstAsset
.
id
)
console
.
log
(
"
Moved to cone
"
,
coneAsset
.
id
)
return
coneAsset
.
id
}
const
sendToStock
=
async
(
apiClient
,
{
assetId
:
paramAssetId
})
=>
{
const
updateStockRange
=
(
stock
=
{},
batch
=
{})
=>
{
const
{
cao
:
caoRange
=
null
}
=
(
stock
.
fields
||
{}).
composition
||
{}
const
{
cao
:
newCaoRange
=
null
}
=
(
batch
.
fields
||
{}).
composition
||
{}
if
(
caoRange
===
null
)
{
return
newCaoRange
}
if
(
newCaoRange
===
null
)
{
return
caoRange
}
return
{
min
:
newCaoRange
.
min
<
caoRange
.
min
?
newCaoRange
.
min
:
caoRange
.
min
,
max
:
newCaoRange
.
max
>
caoRange
.
max
?
newCaoRange
.
max
:
caoRange
.
max
}
}
const
sendToStock
=
async
(
apiClient
,
{
assetId
:
paramAssetId
,
stockId
:
paramStockId
}
)
=>
{
const
assetId
=
paramAssetId
||
(
await
promptAssetSelection
(
...
...
@@ -136,7 +174,9 @@ const sendToStock = async (apiClient, { assetId: paramAssetId }) => {
return
}
const
selectedStockId
=
await
promptAssetSelection
(
const
selectedStockId
=
paramStockId
||
(
await
promptAssetSelection
(
[
...(
await
apiClient
.
richQuery
({
fields
:
{
...
...
@@ -150,14 +190,14 @@ const sendToStock = async (apiClient, { assetId: paramAssetId }) => {
}
],
"
Select the stock where the cone will be merged
"
)
)
)
if
(
!
selectedStockId
)
{
console
.
error
(
"
You must select a stock
"
)
return
}
let
previousStock
=
false
let
previousStock
=
undefined
if
(
selectedStockId
!==
"
newStock
"
)
{
previousStock
=
await
apiClient
.
getAsset
(
selectedStockId
)
}
...
...
@@ -179,7 +219,10 @@ const sendToStock = async (apiClient, { assetId: paramAssetId }) => {
quantity
:
newStockQuantity
,
fields
:
{
status
:
STATUSES
.
STOCK
,
name
:
"
Stock
"
name
:
"
Stock
"
,
composition
:
{
cao
:
updateStockRange
(
previousStock
,
assetToBeSent
)
}
}
}
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment