Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CDEK Development
cdek-warehouse
Commits
1d547ed3
Commit
1d547ed3
authored
7 years ago
by
d.maklakov
Browse files
Options
Download
Email Patches
Plain Diff
Исправления в прелоаде.
parent
2db7a1c7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
warehouse-common/warehouse-dao/src/main/java/com/cdek/warehouse/dao/gateway/impl/Ek4SyncObjectsDAOImpl.java
+2
-4
...dek/warehouse/dao/gateway/impl/Ek4SyncObjectsDAOImpl.java
warehouse-common/warehouse-services/src/main/java/com/cdek/warehouse/services/gateway/convert/converters/document/DocumentConverter.java
+9
-3
...ateway/convert/converters/document/DocumentConverter.java
warehouse-common/warehouse-services/src/main/java/com/cdek/warehouse/services/gateway/convert/converters/document/ShipmentConverter.java
+5
-5
...ateway/convert/converters/document/ShipmentConverter.java
warehouse-common/warehouse-services/src/main/java/com/cdek/warehouse/services/gateway/impl/ChainPriorityServiceImpl.java
+4
-5
...house/services/gateway/impl/ChainPriorityServiceImpl.java
warehouse-common/warehouse-services/src/main/java/com/cdek/warehouse/services/gateway/impl/Ek4DataPreLoaderImpl.java
+12
-4
...warehouse/services/gateway/impl/Ek4DataPreLoaderImpl.java
warehouse-common/warehouse-services/src/test/java/com/cdek/warehouse/services/gateway/load/GatewayIntTest.java
+33
-0
.../cdek/warehouse/services/gateway/load/GatewayIntTest.java
with
65 additions
and
21 deletions
+65
-21
warehouse-common/warehouse-dao/src/main/java/com/cdek/warehouse/dao/gateway/impl/Ek4SyncObjectsDAOImpl.java
View file @
1d547ed3
...
...
@@ -50,8 +50,7 @@ public class Ek4SyncObjectsDAOImpl implements Ek4SyncObjectsDAO {
.
collect
(
Collectors
.
toList
()));
List
<
List
<
OpisOrders
>>
parts
=
ListUtils
.
partition
(
entities
,
OPIS_ORDERS_SAVE_CHUNK_SIZE
);
parts
.
parallelStream
()
.
forEach
(
part
->
batchInsert
(
OPIS_ORDERS_TABLE
,
part
));
parts
.
forEach
(
part
->
batchInsert
(
OPIS_ORDERS_TABLE
,
part
));
}
@Override
...
...
@@ -88,8 +87,7 @@ public class Ek4SyncObjectsDAOImpl implements Ek4SyncObjectsDAO {
.
collect
(
Collectors
.
toList
()));
List
<
List
<
SendingOpis
>>
parts
=
ListUtils
.
partition
(
entities
,
SENDING_OPIS_SAVE_CHUNK_SIZE
);
parts
.
parallelStream
()
.
forEach
(
part
->
batchInsert
(
SENDING_OPIS_TABLE
,
part
));
parts
.
forEach
(
part
->
batchInsert
(
SENDING_OPIS_TABLE
,
part
));
}
@Override
...
...
This diff is collapsed.
Click to expand it.
warehouse-common/warehouse-services/src/main/java/com/cdek/warehouse/services/gateway/convert/converters/document/DocumentConverter.java
View file @
1d547ed3
...
...
@@ -9,6 +9,8 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Required
;
import
java.sql.Timestamp
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
...
...
@@ -29,19 +31,23 @@ public abstract class DocumentConverter<T extends Document> {
T
convertDocument
(
OpisZagolovok
opisZagolovok
,
T
document
,
UserCodeEmployee
userCodeEmployee
)
{
document
.
setUuid
(
UUID
.
randomUUID
().
toString
());
document
.
setDate
(
opisZagolovok
.
getDate
());
document
.
setDateCreated
(
opisZagolovok
.
getDate
());
document
.
setDateUpdated
(
opisZagolovok
.
getDate
());
document
.
setDateCreated
(
convertDate
(
opisZagolovok
.
getDate
())
)
;
document
.
setDateUpdated
(
convertDate
(
opisZagolovok
.
getDate
())
)
;
document
.
setExternalId
(
opisZagolovok
.
getIdOpis
());
document
.
setSkedNumber
(
opisZagolovok
.
getOpisName
());
document
.
setExternalDateUpdated
(
opisZagolovok
.
getDateUpdate
());
document
.
setCurrentBranch
(
String
.
valueOf
(
opisZagolovok
.
getIdCity
()));
document
.
setDateClosed
(
opisZagolovok
.
getDateFix
());
document
.
setDateClosed
(
convertDate
(
opisZagolovok
.
getDateFix
())
)
;
document
.
setDescription
(
LocalizedStringConverter
.
convert
(
opisZagolovok
.
getNote
()));
setFieldsByEmployeeCode
(
opisZagolovok
,
document
,
userCodeEmployee
);
return
document
;
}
Date
convertDate
(
Timestamp
timestamp
)
{
return
com
.
cdek
.
warehouse
.
common
.
util
.
date
.
DateUtils
.
ek4ToLocalTime
(
timestamp
);
}
private
void
setFieldsByEmployeeCode
(
OpisZagolovok
opisZagolovok
,
T
document
,
UserCodeEmployee
userCodeEmployee
)
{
String
employeeCode
;
...
...
This diff is collapsed.
Click to expand it.
warehouse-common/warehouse-services/src/main/java/com/cdek/warehouse/services/gateway/convert/converters/document/ShipmentConverter.java
View file @
1d547ed3
...
...
@@ -28,8 +28,8 @@ public class ShipmentConverter extends DocumentConverter<Shipment> implements Fu
Shipment
shipment
=
Shipment
.
build
();
shipment
.
setUuid
(
UUID
.
randomUUID
().
toString
());
shipment
.
setDate
(
sending
.
getDate
());
shipment
.
setDateCreated
(
sending
.
getDate
());
shipment
.
setDateUpdated
(
sending
.
getDate
());
shipment
.
setDateCreated
(
convertDate
(
sending
.
getDate
())
)
;
shipment
.
setDateUpdated
(
convertDate
(
sending
.
getDate
())
)
;
shipment
.
setExternalId
(
sending
.
getIdSending
());
shipment
.
setExternalDateUpdated
(
sending
.
getDateUpdate
());
...
...
@@ -49,9 +49,9 @@ public class ShipmentConverter extends DocumentConverter<Shipment> implements Fu
LOG
.
warn
(
String
.
format
(
"Cannot find flight = %d"
,
sending
.
getIdTransrout
()));
}
shipment
.
setDateOfSending
(
sending
.
getDateOut
());
shipment
.
setFactDateOfMeeting
(
sending
.
getDateRec
());
shipment
.
setPlannedDateOfMeeting
(
sending
.
getDateRecPlan
());
shipment
.
setDateOfSending
(
convertDate
(
sending
.
getDateOut
())
)
;
shipment
.
setFactDateOfMeeting
(
convertDate
(
sending
.
getDateRec
())
)
;
shipment
.
setPlannedDateOfMeeting
(
convertDate
(
sending
.
getDateRecPlan
())
)
;
//todo нет данных как расчитывать по ПГМ находящихся в КГМ добавленном в отправку
shipment
.
setFactWeight
(
sending
.
getWeight
());
...
...
This diff is collapsed.
Click to expand it.
warehouse-common/warehouse-services/src/main/java/com/cdek/warehouse/services/gateway/impl/ChainPriorityServiceImpl.java
View file @
1d547ed3
...
...
@@ -44,8 +44,8 @@ public class ChainPriorityServiceImpl implements ChainPriorityService {
Assert
.
notNull
(
chainEk4
.
getNumberOrd
());
Waybill
waybill
=
waybillService
.
findByNumber
(
chainEk4
.
getNumberOrd
());
Assert
.
notNull
(
waybill
.
getUuid
());
List
<
CargoPlace
>
cargoPlaces
=
cargoPlaceService
.
findByWaybillUuid
(
waybill
.
getUuid
());
List
<
CargoPlace
>
cargoPlaces
=
cargoPlaceService
.
findByWaybillUuid
(
waybill
.
getUuid
());
Assert
.
notNull
(
cargoPlaces
);
if
(
cargoPlaces
.
isEmpty
())
{
return
NEW_CHAIN_HAS_MORE_PRIORITY
;
...
...
@@ -60,7 +60,8 @@ public class ChainPriorityServiceImpl implements ChainPriorityService {
return
NEW_CHAIN_HAS_MORE_PRIORITY
;
}
if
(
cargoPlaceHistory
.
getOperationType
()
==
OperationType
.
DOCUMENT_REMOVE_CARGO_PLACE
)
{
if
(
cargoPlaceHistory
.
getOperationType
()
==
OperationType
.
DOCUMENT_REMOVE_CARGO_PLACE
||
cargoPlaceHistory
.
getOperationType
()
==
OperationType
.
FORCE_REMOVE_CARGO_PLACE
)
{
return
NEW_CHAIN_HAS_MORE_PRIORITY
;
}
...
...
@@ -73,10 +74,8 @@ public class ChainPriorityServiceImpl implements ChainPriorityService {
return
CURRENT_CHAIN_HAS_MORE_PRIORITY
;
}
Assert
.
notNull
(
document
.
getExternalId
());
Assert
.
notNull
(
document
.
getType
());
return
Objects
.
nonNull
(
findDocumentEk4
(
document
.
getType
(),
document
.
getExternalId
()))
?
NEW_CHAIN_HAS_MORE_PRIORITY:
CURRENT_CHAIN_HAS_MORE_PRIORITY
;
NEW_CHAIN_HAS_MORE_PRIORITY
:
CURRENT_CHAIN_HAS_MORE_PRIORITY
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
warehouse-common/warehouse-services/src/main/java/com/cdek/warehouse/services/gateway/impl/Ek4DataPreLoaderImpl.java
View file @
1d547ed3
...
...
@@ -27,11 +27,19 @@ public class Ek4DataPreLoaderImpl implements Ek4DataPreLoader {
@Override
public
void
load
()
{
LOG
.
info
(
"PRELOAD is starting..."
);
clean
();
try
{
clean
();
loadOpises
();
loadSendings
();
LOG
.
info
(
"PRELOAD is finished successfully"
);
}
catch
(
Exception
ex
)
{
LOG
.
error
(
"PRELOAD is failed"
,
ex
);
}
catch
(
Throwable
ex
)
{
LOG
.
error
(
"PRELOAD is failed"
,
ex
);
throw
ex
;
}
loadOpises
();
loadSendings
();
LOG
.
info
(
"PRELOAD is finished successfully"
);
}
private
void
clean
()
{
...
...
This diff is collapsed.
Click to expand it.
warehouse-common/warehouse-services/src/test/java/com/cdek/warehouse/services/gateway/load/GatewayIntTest.java
View file @
1d547ed3
package
com.cdek.warehouse.services.gateway.load
;
import
com.cdek.commons.utils.JSONUtil
;
import
com.cdek.warehouse.common.rest.ErrorResponseException
;
import
com.cdek.warehouse.dao.gateway.Ek4WaybillDAO
;
import
com.cdek.warehouse.services.gateway.ChainEk5Builder
;
import
com.cdek.warehouse.services.gateway.ChainPriorityService
;
import
com.cdek.warehouse.services.gateway.Ek4ConversionService
;
import
com.cdek.warehouse.services.gateway.Ek4DataPreLoader
;
import
com.cdek.warehouse.services.gateway.chains.ChainEk4
;
...
...
@@ -21,6 +24,9 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.IOException
;
import
java.util.List
;
import
static
com
.
cdek
.
warehouse
.
services
.
gateway
.
ChainPriorityService
.
PriorityType
.
CURRENT_CHAIN_HAS_MORE_PRIORITY
;
/**
* Временный интеграционный тест для проверки работы компонетов Шлюза
...
...
@@ -38,9 +44,15 @@ public class GatewayIntTest {
@Autowired
private
ChainEk5Builder
chainEk5Builder
;
@Autowired
private
Ek4WaybillDAO
ek4WaybillDAO
;
@Autowired
private
ChainPriorityService
chainPriorityService
;
@Autowired
private
Ek4DataPreLoader
ek4DataPreLoader
;
@Autowired
private
Ek4ConversionService
ek4ConversionService
;
@Autowired
private
MigrationService
migrationService
;
@Ignore
@Test
...
...
@@ -48,6 +60,7 @@ public class GatewayIntTest {
ek4DataPreLoader
.
load
();
}
@Ignore
@Test
public
void
testBuildChain
()
throws
IOException
{
long
numberOrd
=
1048102337L
;
...
...
@@ -57,4 +70,24 @@ public class GatewayIntTest {
ChainEk5
chainEk5
=
chainEk5Builder
.
buildChain
(
chainEk4
);
}
@Ignore
@Test
public
void
testChainPriority
()
throws
IOException
,
ErrorResponseException
{
List
<
Long
>
inNumberOrds
=
ek4WaybillDAO
.
loadWaybills
(
1000
,
0
);
List
<
Long
>
numberOrds
=
migrationService
.
migrateWaybills
(
inNumberOrds
);
for
(
Long
numberOrd:
numberOrds
)
{
try
{
ChainEk4
chainEk4
=
ek4ConversionService
.
makeChainEk4
(
numberOrd
);
if
(
chainPriorityService
.
chainPriority
(
chainEk4
)
==
CURRENT_CHAIN_HAS_MORE_PRIORITY
)
{
LOG
.
debug
(
"Current chain has more priority"
);
}
else
{
LOG
.
trace
(
"New chain has more priority"
);
}
}
catch
(
RuntimeException
ex
)
{
LOG
.
error
(
String
.
format
(
"Failed get chain priority for waybill = %d: %s"
,
numberOrd
,
ex
.
toString
()),
ex
);
throw
ex
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help