Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Conversion
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vladislav Kiselev
Conversion
Commits
ba46bb65
Commit
ba46bb65
authored
Feb 01, 2019
by
Vladislav Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Парсер и toString() для нового формата.
parent
cace9b38
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
407 additions
and
159 deletions
+407
-159
src/inport/LoadingEquipment.java
src/inport/LoadingEquipment.java
+12
-3
src/inport/LoadingTemplate.java
src/inport/LoadingTemplate.java
+39
-7
src/inport/Main.java
src/inport/Main.java
+13
-0
src/inport/MooringTemplate.java
src/inport/MooringTemplate.java
+26
-3
src/inport/MovingObject.java
src/inport/MovingObject.java
+20
-1
src/inport/MovingTemplate.java
src/inport/MovingTemplate.java
+26
-3
src/inport/TaskCase.java
src/inport/TaskCase.java
+239
-133
src/inport/Tow.java
src/inport/Tow.java
+11
-3
src/inport/TowUsingTemplate.java
src/inport/TowUsingTemplate.java
+10
-4
src/inport/TransportShip.java
src/inport/TransportShip.java
+11
-2
No files found.
src/inport/LoadingEquipment.java
View file @
ba46bb65
...
@@ -4,12 +4,13 @@
...
@@ -4,12 +4,13 @@
*/
*/
package
inport
;
package
inport
;
import
java.util.OptionalInt
;
/**
/**
*
*
* @author topazh_ag
* @author topazh_ag
*/
*/
public
class
LoadingEquipment
extends
MovingObject
{
public
class
LoadingEquipment
extends
MovingObject
{
public
LoadingEquipment
()
{
public
LoadingEquipment
()
{
super
();
super
();
...
@@ -21,11 +22,19 @@ public class LoadingEquipment extends MovingObject{
...
@@ -21,11 +22,19 @@ public class LoadingEquipment extends MovingObject{
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
getId
()
+
";"
+
getName
();
String
res
=
getId
()
+
";"
+
getName
();
if
(
getType
().
isPresent
())
{
res
+=
";"
+
getType
().
getAsInt
();
}
return
res
;
}
}
public
LoadingEquipment
(
String
s
)
{
public
LoadingEquipment
(
String
s
)
{
super
(
s
);
super
(
s
);
String
[]
tokens
=
s
.
split
(
";"
);
if
(
tokens
.
length
>=
4
)
{
setType
(
OptionalInt
.
of
(
Integer
.
parseInt
(
tokens
[
3
].
trim
())));
}
}
}
}
}
src/inport/LoadingTemplate.java
View file @
ba46bb65
...
@@ -6,6 +6,7 @@ package inport;
...
@@ -6,6 +6,7 @@ package inport;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.OptionalInt
;
/**
/**
*
*
...
@@ -14,12 +15,21 @@ import java.util.List;
...
@@ -14,12 +15,21 @@ import java.util.List;
public
class
LoadingTemplate
extends
OperationTemplate
{
public
class
LoadingTemplate
extends
OperationTemplate
{
private
TransportShip
loader
;
private
TransportShip
loader
;
private
OptionalInt
loaderType
=
OptionalInt
.
empty
();
private
Storage
storage
;
private
Storage
storage
;
private
List
<
LoadingEquipment
>
resources
;
private
List
<
LoadingEquipment
>
resources
;
private
List
<
Integer
>
resourcesTypes
;
private
double
intensity
;
private
double
intensity
;
private
boolean
withMooring
;
private
boolean
withMooring
;
private
Cargo
cargo
;
private
Cargo
cargo
;
public
OptionalInt
getLoaderType
()
{
return
loaderType
;
}
public
void
setLoaderType
(
OptionalInt
loaderType
)
{
this
.
loaderType
=
loaderType
;
}
/**
/**
* Get the value of resources
* Get the value of resources
*
*
...
@@ -37,7 +47,14 @@ public class LoadingTemplate extends OperationTemplate {
...
@@ -37,7 +47,14 @@ public class LoadingTemplate extends OperationTemplate {
public
void
setResources
(
List
<
LoadingEquipment
>
resources
)
{
public
void
setResources
(
List
<
LoadingEquipment
>
resources
)
{
this
.
resources
=
resources
;
this
.
resources
=
resources
;
}
}
public
List
<
Integer
>
getResourcesTypes
()
{
return
resourcesTypes
;
}
public
void
setResourcesTypes
(
List
<
Integer
>
resourcesTypes
)
{
this
.
resourcesTypes
=
resourcesTypes
;
}
public
TransportShip
getLoader
()
{
public
TransportShip
getLoader
()
{
return
loader
;
return
loader
;
}
}
...
@@ -83,32 +100,47 @@ public class LoadingTemplate extends OperationTemplate {
...
@@ -83,32 +100,47 @@ public class LoadingTemplate extends OperationTemplate {
this
.
loader
=
loader
;
this
.
loader
=
loader
;
this
.
storage
=
storage
;
this
.
storage
=
storage
;
this
.
resources
=
new
ArrayList
<>();
this
.
resources
=
new
ArrayList
<>();
this
.
resourcesTypes
=
new
ArrayList
<>();
this
.
intensity
=
intensity
;
this
.
intensity
=
intensity
;
}
}
public
LoadingTemplate
()
{
public
LoadingTemplate
()
{
this
.
resources
=
new
ArrayList
<>();
this
.
resources
=
new
ArrayList
<>();
this
.
resourcesTypes
=
new
ArrayList
<>();
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
String
res
=
""
;
String
res
=
""
;
boolean
first
=
true
;
boolean
first
=
true
;
for
(
LoadingEquipment
eq
:
resources
)
for
(
LoadingEquipment
eq
:
resources
)
{
{
if
(!
first
)
if
(!
first
)
res
+=
","
+
eq
.
getId
();
res
+=
","
+
eq
.
getId
();
else
else
res
+=
eq
.
getId
();
res
+=
eq
.
getId
();
first
=
false
;
first
=
false
;
}
}
int
source
=
loader
.
getId
();
for
(
Integer
t
:
getResourcesTypes
())
{
if
(!
first
)
res
+=
","
+
t
;
else
res
+=
t
;
first
=
false
;
}
int
startId
;
if
(
loaderType
.
isPresent
())
{
startId
=
loaderType
.
getAsInt
();
}
else
{
startId
=
loader
.
getId
();
}
int
source
=
startId
;
if
(
intensity
>
0
)
if
(
intensity
>
0
)
source
=
storage
.
getId
();
source
=
storage
.
getId
();
int
target
=
loader
.
getId
()
;
int
target
=
startId
;
if
(
intensity
<=
0
)
if
(
intensity
<=
0
)
target
=
storage
.
getId
();
target
=
storage
.
getId
();
return
getId
()
+
";
"
+
"loa;"
+
twtoString
()
+
";"
+
source
+
";"
+
cargo
.
getId
()
+
";"
+
target
+
";
"
return
getId
()
+
";
"
+
"loa; "
+
twtoString
()
+
"; "
+
source
+
"; "
+
cargo
.
getId
()
+
"; "
+
target
+
";
"
+
getStartLocation
().
getId
()
+
";
["
+
res
+
"];"
+
Math
.
abs
(
intensity
)
+
";
"
+
(
withMooring
?
"M"
:
"U"
);
+
getStartLocation
().
getId
()
+
";
["
+
res
+
"]; "
+
Math
.
abs
(
intensity
)
+
";
"
+
(
withMooring
?
"M"
:
"U"
);
}
}
}
}
src/inport/Main.java
View file @
ba46bb65
...
@@ -118,6 +118,19 @@ public class Main {
...
@@ -118,6 +118,19 @@ public class Main {
}
}
break
;
break
;
}
}
case
"debug"
:
{
String
fileName
=
args
[
1
];
String
output
=
args
[
2
];
TaskCase
task
=
new
TaskCase
();
try
{
task
.
deserialize
(
fileName
);
task
.
serialize
(
output
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
break
;
}
default
:
default
:
System
.
out
.
println
(
"Unknown type \""
+
type
+
"\""
);
System
.
out
.
println
(
"Unknown type \""
+
type
+
"\""
);
}
}
...
...
src/inport/MooringTemplate.java
View file @
ba46bb65
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
*/
*/
package
inport
;
package
inport
;
import
java.util.OptionalInt
;
/**
/**
*
*
* @author topazh_ag
* @author topazh_ag
...
@@ -11,8 +13,16 @@ package inport;
...
@@ -11,8 +13,16 @@ package inport;
public
class
MooringTemplate
extends
TowUsingTemplate
{
public
class
MooringTemplate
extends
TowUsingTemplate
{
private
TransportShip
moorer
;
private
TransportShip
moorer
;
private
OptionalInt
moorerType
=
OptionalInt
.
empty
();
private
boolean
direct
;
private
boolean
direct
;
public
OptionalInt
getMoorerType
()
{
return
moorerType
;
}
public
void
setMoorerType
(
OptionalInt
moorerType
)
{
this
.
moorerType
=
moorerType
;
}
/**
/**
* Get the value of direction
* Get the value of direction
*
*
...
@@ -63,18 +73,31 @@ public class MooringTemplate extends TowUsingTemplate {
...
@@ -63,18 +73,31 @@ public class MooringTemplate extends TowUsingTemplate {
public
String
toString
()
{
public
String
toString
()
{
String
res
=
""
;
String
res
=
""
;
boolean
first
=
true
;
boolean
first
=
true
;
for
(
Tow
eq
:
getResources
())
for
(
Tow
eq
:
getResources
())
{
{
if
(!
first
)
if
(!
first
)
res
+=
","
+
eq
.
getId
();
res
+=
","
+
eq
.
getId
();
else
else
res
+=
eq
.
getId
();
res
+=
eq
.
getId
();
first
=
false
;
first
=
false
;
}
}
for
(
Integer
t
:
getResourcesTypes
())
{
if
(!
first
)
res
+=
","
+
t
;
else
res
+=
t
;
first
=
false
;
}
String
code
=
"mrn"
;
String
code
=
"mrn"
;
if
(!
direct
)
if
(!
direct
)
code
=
"unm"
;
code
=
"unm"
;
return
getId
()
+
";"
+
code
+
";"
+
twtoString
()
+
";"
+
moorer
.
getId
()
+
";"
+
getStartLocation
().
getId
()
+
";["
+
res
+
"];"
+
getDuration
();
String
result
=
getId
()
+
"; "
+
code
+
"; "
+
twtoString
()
+
"; "
;
if
(
moorerType
.
isPresent
())
{
result
+=
moorerType
.
getAsInt
();
}
else
{
result
+=
moorer
.
getId
();
}
return
result
+
"; "
+
getStartLocation
().
getId
()
+
"; ["
+
res
+
"]; "
+
getDuration
();
}
}
}
}
src/inport/MovingObject.java
View file @
ba46bb65
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
*/
*/
package
inport
;
package
inport
;
import
java.util.OptionalInt
;
/**
/**
*
*
* @author topazh_ag
* @author topazh_ag
...
@@ -12,6 +14,7 @@ public class MovingObject {
...
@@ -12,6 +14,7 @@ public class MovingObject {
private
int
id
;
private
int
id
;
private
String
name
;
private
String
name
;
private
OptionalInt
type
;
/**
/**
* Get the value of name
* Get the value of name
...
@@ -49,18 +52,34 @@ public class MovingObject {
...
@@ -49,18 +52,34 @@ public class MovingObject {
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
OptionalInt
getType
()
{
return
type
;
}
public
void
setType
(
OptionalInt
type
)
{
this
.
type
=
type
;
}
public
MovingObject
(
int
id
,
String
name
)
{
public
MovingObject
(
int
id
,
String
name
)
{
this
.
id
=
id
;
this
.
id
=
id
;
this
.
name
=
name
;
this
.
name
=
name
;
this
.
type
=
OptionalInt
.
empty
();
}
public
MovingObject
(
int
id
,
String
name
,
int
typeId
)
{
this
.
id
=
id
;
this
.
name
=
name
;
this
.
type
=
OptionalInt
.
of
(
typeId
);
}
}
public
MovingObject
()
{
public
MovingObject
()
{
type
=
OptionalInt
.
empty
();
}
}
public
MovingObject
(
String
s
)
{
public
MovingObject
(
String
s
)
{
String
[]
tokens
=
s
.
split
(
";"
);
String
[]
tokens
=
s
.
split
(
";"
);
id
=
Integer
.
parseInt
(
tokens
[
0
].
trim
());
id
=
Integer
.
parseInt
(
tokens
[
0
].
trim
());
name
=
tokens
[
1
].
trim
();
name
=
tokens
[
1
].
trim
();
type
=
OptionalInt
.
empty
();
}
}
}
}
src/inport/MovingTemplate.java
View file @
ba46bb65
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
*/
*/
package
inport
;
package
inport
;
import
java.util.OptionalInt
;
/**
/**
*
*
* @author topazh_ag
* @author topazh_ag
...
@@ -11,6 +13,7 @@ package inport;
...
@@ -11,6 +13,7 @@ package inport;
public
class
MovingTemplate
extends
TowUsingTemplate
{
public
class
MovingTemplate
extends
TowUsingTemplate
{
private
MovingObject
mover
;
private
MovingObject
mover
;
private
OptionalInt
moverType
;
private
Berth
destination
;
private
Berth
destination
;
...
@@ -50,6 +53,13 @@ public class MovingTemplate extends TowUsingTemplate {
...
@@ -50,6 +53,13 @@ public class MovingTemplate extends TowUsingTemplate {
this
.
mover
=
mover
;
this
.
mover
=
mover
;
}
}
public
OptionalInt
getMoverType
()
{
return
moverType
;
}
public
void
setMoverType
(
OptionalInt
moverType
)
{
this
.
moverType
=
moverType
;
}
public
MovingTemplate
(
MovingObject
mover
,
Berth
source
,
Berth
destination
,
double
duration
,
int
id
)
{
public
MovingTemplate
(
MovingObject
mover
,
Berth
source
,
Berth
destination
,
double
duration
,
int
id
)
{
super
(
duration
,
id
,
source
);
super
(
duration
,
id
,
source
);
this
.
mover
=
mover
;
this
.
mover
=
mover
;
...
@@ -64,15 +74,28 @@ public class MovingTemplate extends TowUsingTemplate {
...
@@ -64,15 +74,28 @@ public class MovingTemplate extends TowUsingTemplate {
public
String
toString
()
{
public
String
toString
()
{
String
res
=
""
;
String
res
=
""
;
boolean
first
=
true
;
boolean
first
=
true
;
for
(
Tow
eq
:
getResources
())
for
(
Tow
eq
:
getResources
())
{
{
if
(!
first
)
if
(!
first
)
res
+=
","
+
eq
.
getId
();
res
+=
","
+
eq
.
getId
();
else
else
res
+=
eq
.
getId
();
res
+=
eq
.
getId
();
first
=
false
;
first
=
false
;
}
}
return
getId
()
+
";"
+
"mov;"
+
twtoString
()
+
";"
+
mover
.
getId
()
+
";"
+
getStartLocation
().
getId
()
+
";"
+
destination
.
getId
()
+
";["
+
res
+
"];"
+
getDuration
();
for
(
Integer
t
:
getResourcesTypes
())
{
if
(!
first
)
res
+=
","
+
t
;
else
res
+=
t
;
first
=
false
;
}
String
result
=
getId
()
+
"; "
+
"mov; "
+
twtoString
()
+
"; "
;
if
(
getMoverType
().
isPresent
())
{
result
+=
getMoverType
().
getAsInt
();
}
else
{
result
+=
mover
.
getId
();
}
return
result
+
"; "
+
getStartLocation
().
getId
()
+
"; "
+
destination
.
getId
()
+
"; ["
+
res
+
"]; "
+
getDuration
();
}
}
...
...
src/inport/TaskCase.java
View file @
ba46bb65
This diff is collapsed.
Click to expand it.
src/inport/Tow.java
View file @
ba46bb65
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
*/
*/
package
inport
;
package
inport
;
import
java.util.OptionalInt
;
/**
/**
*
*
* @author topazh_ag
* @author topazh_ag
...
@@ -19,12 +21,18 @@ public class Tow extends MovingObject {
...
@@ -19,12 +21,18 @@ public class Tow extends MovingObject {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
getId
()
+
";"
+
getName
()
+
";1000000"
;
String
res
=
getId
()
+
";"
+
getName
()
+
";1000000"
;
if
(
getType
().
isPresent
())
{
res
+=
";"
+
getType
().
getAsInt
();
}
return
res
;
}
}
public
Tow
(
String
s
)
{
public
Tow
(
String
s
)
{
super
(
s
);
super
(
s
);
String
[]
tokens
=
s
.
split
(
";"
);
if
(
tokens
.
length
>=
4
)
{
setType
(
OptionalInt
.
of
(
Integer
.
parseInt
(
tokens
[
3
].
trim
())));
}
}
}
}
}
src/inport/TowUsingTemplate.java
View file @
ba46bb65
...
@@ -12,11 +12,10 @@ import java.util.List;
...
@@ -12,11 +12,10 @@ import java.util.List;
* @author topazh_ag
* @author topazh_ag
*/
*/
public
abstract
class
TowUsingTemplate
extends
OperationTemplate
{
public
abstract
class
TowUsingTemplate
extends
OperationTemplate
{
private
List
<
Tow
>
resources
;
private
List
<
Tow
>
resources
;
private
List
<
Integer
>
resourcesTypes
;
private
double
duration
;
private
double
duration
;
/**
/**
* Get the value of resources
* Get the value of resources
...
@@ -36,6 +35,13 @@ public abstract class TowUsingTemplate extends OperationTemplate {
...
@@ -36,6 +35,13 @@ public abstract class TowUsingTemplate extends OperationTemplate {
this
.
resources
=
resources
;
this
.
resources
=
resources
;
}
}
public
List
<
Integer
>
getResourcesTypes
()
{
return
resourcesTypes
;
}
public
void
setResourcesTypes
(
List
<
Integer
>
resourcesTypes
)
{
this
.
resourcesTypes
=
resourcesTypes
;
}
/**
/**
* Get the value of duration
* Get the value of duration
*
*
...
@@ -59,11 +65,13 @@ public abstract class TowUsingTemplate extends OperationTemplate {
...
@@ -59,11 +65,13 @@ public abstract class TowUsingTemplate extends OperationTemplate {
public
TowUsingTemplate
(
double
duration
,
int
id
,
Berth
startLocation
)
{
public
TowUsingTemplate
(
double
duration
,
int
id
,
Berth
startLocation
)
{
super
(
id
,
startLocation
);
super
(
id
,
startLocation
);
this
.
resources
=
new
ArrayList
<>();
this
.
resources
=
new
ArrayList
<>();
this
.
resourcesTypes
=
new
ArrayList
<>();
this
.
duration
=
duration
;
this
.
duration
=
duration
;
}
}
public
TowUsingTemplate
()
{
public
TowUsingTemplate
()
{
this
.
resources
=
new
ArrayList
<>();
this
.
resources
=
new
ArrayList
<>();
this
.
resourcesTypes
=
new
ArrayList
<>();
}
}
@Override
@Override
...
@@ -80,6 +88,4 @@ public abstract class TowUsingTemplate extends OperationTemplate {
...
@@ -80,6 +88,4 @@ public abstract class TowUsingTemplate extends OperationTemplate {
}
}
return
getId
()
+
";"
+
"tut"
+
";"
+
";["
+
res
+
"];"
+
duration
;
return
getId
()
+
";"
+
"tut"
+
";"
+
";["
+
res
+
"];"
+
duration
;
}
}
}
}
src/inport/TransportShip.java
View file @
ba46bb65
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
*/
*/
package
inport
;
package
inport
;
import
java.util.OptionalInt
;
/**
/**
*
*
* @author topazh_ag
* @author topazh_ag
...
@@ -30,13 +32,20 @@ public class TransportShip extends MovingObject {
...
@@ -30,13 +32,20 @@ public class TransportShip extends MovingObject {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
getId
()
+
";"
+
getName
()
+
";"
+
cargoMax
;
String
res
=
getId
()
+
";"
+
getName
()
+
";"
+
cargoMax
;
if
(
getType
().
isPresent
())
{
res
+=
";"
+
getType
().
getAsInt
();
}
return
res
;
}
}
public
TransportShip
(
String
s
)
{
public
TransportShip
(
String
s
)
{
super
(
s
);
super
(
s
);
String
[]
tokens
=
s
.
split
(
";"
);
String
[]
tokens
=
s
.
split
(
";"
);
cargoMax
=
Double
.
parseDouble
(
tokens
[
2
].
trim
());
cargoMax
=
Double
.
parseDouble
(
tokens
[
2
].
trim
());
if
(
tokens
.
length
>=
4
)
{
setType
(
OptionalInt
.
of
(
Integer
.
parseInt
(
tokens
[
3
].
trim
())));
}
}
}
}
}
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