Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b6ab9271
authored
Jun 25, 2023
by
chamberone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 文件目录访问错误修复
1 parent
c32e8488
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
19 deletions
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/DispatchService.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/DispatchServiceImpl.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/DispatchService.java
View file @
b6ab927
...
...
@@ -16,7 +16,7 @@
package
com
.
dituhui
.
pea
.
dispatch
.
service
;
import
java.io.
FileNotFound
Exception
;
import
java.io.
IO
Exception
;
import
java.io.UncheckedIOException
;
import
com.dituhui.pea.common.Result
;
...
...
@@ -26,6 +26,6 @@ import com.dituhui.pea.common.Result;
*/
public
interface
DispatchService
{
Result
<?>
manualDispatch
()
throws
UncheckedIOException
,
FileNotFound
Exception
;
Result
<?>
manualDispatch
()
throws
UncheckedIOException
,
IO
Exception
;
}
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/DispatchServiceImpl.java
View file @
b6ab927
...
...
@@ -19,6 +19,7 @@ package com.dituhui.pea.dispatch.service.impl;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.UncheckedIOException
;
import
java.time.Duration
;
import
java.util.ArrayList
;
...
...
@@ -39,6 +40,7 @@ import org.optaplanner.core.api.solver.SolverFactory;
import
org.optaplanner.core.config.solver.SolverConfig
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ResourceUtils
;
...
...
@@ -60,7 +62,7 @@ public class DispatchServiceImpl implements DispatchService {
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Override
public
Result
<?>
manualDispatch
()
throws
UncheckedIOException
,
FileNotFound
Exception
{
public
Result
<?>
manualDispatch
()
throws
UncheckedIOException
,
IO
Exception
{
logger
.
info
(
"%s"
,
"invoke manualDispatch"
);
// 创建解决方案对象
...
...
@@ -99,9 +101,9 @@ public class DispatchServiceImpl implements DispatchService {
private
static
Map
<
String
,
Integer
>
loadCustomerCodeServiceTimeMap
()
throws
UncheckedIOException
,
FileNotFound
Exception
{
throws
UncheckedIOException
,
IO
Exception
{
List
<
String
>
customerServiceTime
=
IOUtils
.
readLines
(
new
FileInputStream
(
ResourceUtils
.
getFile
(
"classpath:data/customerServiceTime.csv"
)),
"utf-8"
);
new
FileInputStream
(
new
ClassPathResource
(
"data/customerServiceTime.csv"
).
getFile
(
)),
"utf-8"
);
Map
<
String
,
Integer
>
customerCodeServiceTimeMap
=
new
HashMap
<
String
,
Integer
>();
// code-time
for
(
int
i
=
0
;
i
<
customerServiceTime
.
size
();
i
++)
{
String
line
=
customerServiceTime
.
get
(
i
);
...
...
@@ -112,9 +114,9 @@ public class DispatchServiceImpl implements DispatchService {
}
private
static
Map
<
String
,
Map
<
String
,
Long
>>
loadPreferredlocationDistanceMap
()
throws
UncheckedIOException
,
FileNotFound
Exception
{
throws
UncheckedIOException
,
IO
Exception
{
List
<
String
>
technicianCodeLocation
=
IOUtils
.
readLines
(
new
FileInputStream
(
ResourceUtils
.
getFile
(
"classpath:data/technicianLocation.csv"
)),
"utf-8"
);
.
readLines
(
new
FileInputStream
(
new
ClassPathResource
(
"data/technicianLocation.csv"
).
getFile
(
)),
"utf-8"
);
Map
<
String
,
String
>
technicianCodeLocationMap
=
new
HashMap
<
String
,
String
>();
// 序号-code
for
(
int
i
=
0
;
i
<
technicianCodeLocation
.
size
();
i
++)
{
String
line
=
technicianCodeLocation
.
get
(
i
);
...
...
@@ -123,7 +125,7 @@ public class DispatchServiceImpl implements DispatchService {
}
List
<
String
>
customerCodeLocation
=
IOUtils
.
readLines
(
new
FileInputStream
(
ResourceUtils
.
getFile
(
"classpath:data/customerLocation.csv"
)),
"utf-8"
);
.
readLines
(
new
FileInputStream
(
new
ClassPathResource
(
"data/customerLocation.csv"
).
getFile
(
)),
"utf-8"
);
Map
<
String
,
String
>
customerCodeLocationMap
=
new
HashMap
<
String
,
String
>();
// 序号-code
for
(
int
i
=
0
;
i
<
customerCodeLocation
.
size
();
i
++)
{
String
line
=
customerCodeLocation
.
get
(
i
);
...
...
@@ -171,8 +173,8 @@ public class DispatchServiceImpl implements DispatchService {
return
6378137
*
c
;
}
private
static
Map
<
String
,
String
>
loadCustomerCodeSkillMap
()
throws
UncheckedIOException
,
FileNotFound
Exception
{
List
<
String
>
customerSkill
=
IOUtils
.
readLines
(
new
FileInputStream
(
ResourceUtils
.
getFile
(
"classpath:data/customerSkill.csv"
)),
"utf-8"
);
private
static
Map
<
String
,
String
>
loadCustomerCodeSkillMap
()
throws
UncheckedIOException
,
IO
Exception
{
List
<
String
>
customerSkill
=
IOUtils
.
readLines
(
new
FileInputStream
(
new
ClassPathResource
(
"data/customerSkill.csv"
).
getFile
(
)),
"utf-8"
);
Map
<
String
,
String
>
customerCodeSkillMap
=
new
HashMap
<
String
,
String
>();
// code-技能
for
(
int
i
=
0
;
i
<
customerSkill
.
size
();
i
++)
{
String
line
=
customerSkill
.
get
(
i
);
...
...
@@ -183,8 +185,8 @@ public class DispatchServiceImpl implements DispatchService {
}
private
static
Map
<
String
,
Set
<
String
>>
loadTechnicianCodeSkillsMap
()
throws
UncheckedIOException
,
FileNotFound
Exception
{
List
<
String
>
technicianSkills
=
IOUtils
.
readLines
(
new
FileInputStream
(
ResourceUtils
.
getFile
(
"classpath:data/technicianSkills.csv"
)),
"utf-8"
);
throws
UncheckedIOException
,
IO
Exception
{
List
<
String
>
technicianSkills
=
IOUtils
.
readLines
(
new
FileInputStream
(
new
ClassPathResource
(
"data/technicianSkills.csv"
).
getFile
(
)),
"utf-8"
);
Map
<
String
,
Set
<
String
>>
technicianCodeSkillsMap
=
new
HashMap
<
String
,
Set
<
String
>>();
// code-技能
for
(
int
i
=
0
;
i
<
technicianSkills
.
size
();
i
++)
{
String
line
=
technicianSkills
.
get
(
i
);
...
...
@@ -201,8 +203,8 @@ public class DispatchServiceImpl implements DispatchService {
return
technicianCodeSkillsMap
;
}
private
static
Map
<
Integer
,
String
>
loadTechnicianIndex
()
throws
UncheckedIOException
,
FileNotFound
Exception
{
List
<
String
>
technicianIndexlines
=
IOUtils
.
readLines
(
new
FileInputStream
(
ResourceUtils
.
getFile
(
"classpath:data/technicianIndex.csv"
)),
"utf-8"
);
private
static
Map
<
Integer
,
String
>
loadTechnicianIndex
()
throws
UncheckedIOException
,
IO
Exception
{
List
<
String
>
technicianIndexlines
=
IOUtils
.
readLines
(
new
FileInputStream
(
new
ClassPathResource
(
"data/technicianIndex.csv"
).
getFile
(
)),
"utf-8"
);
Map
<
Integer
,
String
>
technicianIndexMap
=
new
HashMap
<
Integer
,
String
>();
// 序号-code
for
(
int
i
=
0
;
i
<
technicianIndexlines
.
size
();
i
++)
{
technicianIndexMap
.
put
(
i
+
1
,
technicianIndexlines
.
get
(
i
));
...
...
@@ -210,8 +212,8 @@ public class DispatchServiceImpl implements DispatchService {
return
technicianIndexMap
;
}
private
static
Map
<
Integer
,
String
>
loadCustomerIndex
()
throws
UncheckedIOException
,
FileNotFound
Exception
{
List
<
String
>
customerIndexlines
=
IOUtils
.
readLines
(
new
FileInputStream
(
ResourceUtils
.
getFile
(
"classpath:data/customerIndex.csv"
)),
"utf-8"
);
private
static
Map
<
Integer
,
String
>
loadCustomerIndex
()
throws
UncheckedIOException
,
IO
Exception
{
List
<
String
>
customerIndexlines
=
IOUtils
.
readLines
(
new
FileInputStream
(
new
ClassPathResource
(
"data/customerIndex.csv"
).
getFile
(
)),
"utf-8"
);
Map
<
Integer
,
String
>
customerIndexMap
=
new
HashMap
<
Integer
,
String
>();
// 序号-code
for
(
int
i
=
0
;
i
<
customerIndexlines
.
size
();
i
++)
{
customerIndexMap
.
put
(
i
+
1
,
customerIndexlines
.
get
(
i
));
...
...
@@ -221,14 +223,14 @@ public class DispatchServiceImpl implements DispatchService {
private
static
VehicleRoutingSolution
createVehicleRoutingSolution
(
Map
<
Integer
,
String
>
customerIndexMap
,
Map
<
Integer
,
String
>
technicianIndexMap
,
Map
<
String
,
Set
<
String
>>
technicianCodeSkillsMap
,
Map
<
String
,
String
>
customerCodeSkillMap
,
Map
<
String
,
Map
<
String
,
Long
>>
preferredlocationDistanceMap
,
Map
<
String
,
Integer
>
customerCodeServiceTimeMap
)
throws
UncheckedIOException
,
FileNotFound
Exception
{
Map
<
String
,
String
>
customerCodeSkillMap
,
Map
<
String
,
Map
<
String
,
Long
>>
preferredlocationDistanceMap
,
Map
<
String
,
Integer
>
customerCodeServiceTimeMap
)
throws
UncheckedIOException
,
IO
Exception
{
VehicleRoutingSolution
vehicleRoutingSolution
=
new
VehicleRoutingSolution
();
// 翻转map
Map
<
String
,
Integer
>
customerIndexMap2
=
customerIndexMap
.
entrySet
().
stream
()
.
collect
(
Collectors
.
toMap
(
Map
.
Entry
::
getValue
,
Map
.
Entry
::
getKey
));
// 初始化距离矩阵
List
<
String
>
pathMatrixlines
=
IOUtils
.
readLines
(
new
FileInputStream
(
ResourceUtils
.
getFile
(
"classpath:data/pathMatrix.csv"
)),
"utf-8"
);
List
<
String
>
pathMatrixlines
=
IOUtils
.
readLines
(
new
FileInputStream
(
new
ClassPathResource
(
"data/pathMatrix.csv"
).
getFile
(
)),
"utf-8"
);
long
[][]
pathMatrix
=
new
long
[
customerIndexMap
.
keySet
().
size
()
+
1
][
customerIndexMap
.
keySet
().
size
()
+
1
];
for
(
int
i
=
0
;
i
<
pathMatrixlines
.
size
();
i
++)
{
String
line
=
pathMatrixlines
.
get
(
i
);
...
...
@@ -253,7 +255,7 @@ public class DispatchServiceImpl implements DispatchService {
// 初始化时间矩阵
// 初始化订单服务窗
List
<
String
>
customerWindowslines
=
IOUtils
.
readLines
(
new
FileInputStream
(
ResourceUtils
.
getFile
(
"classpath:data/customerWindows.csv"
)),
"utf-8"
);
List
<
String
>
customerWindowslines
=
IOUtils
.
readLines
(
new
FileInputStream
(
new
ClassPathResource
(
"data/customerWindows.csv"
).
getFile
(
)),
"utf-8"
);
Map
<
Integer
,
Integer
>
customerStartMap
=
new
HashMap
<
Integer
,
Integer
>();
Map
<
Integer
,
Integer
>
customerEndMap
=
new
HashMap
<
Integer
,
Integer
>();
for
(
int
i
=
0
;
i
<
customerWindowslines
.
size
();
i
++)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment