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 2c7ba0c2
authored
Nov 21, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://gitlab.dituhui.com/bsh/project/project
into develop
2 parents
c707d5a6
c3611a0f
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
845 additions
and
98 deletions
project-dispatch/src/main/java/com/dituhui/pea/dispatch/DispatchServiceApplication.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/RedisConfig.java → project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/redis/RedisConfig.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/redis/RedisUtil.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/RedissonConfig.java → project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/redis/RedissonConfig.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/RedissonUtil.java → project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/redis/RedissonUtil.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/constraint/DispatchConstraintProvider.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/constraint/RedisKeyConstant.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/quartz/dispatch/AutoDispatchJob.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/scheduler/BatchScheduler.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/ExtractServiceImpl.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/SchedulerServiceImpl.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/utils/RoadDistanceUtils.java
project-dispatch/src/main/resources/application-dev.yaml
project-dispatch/src/main/resources/logback-spring.xml
project-order/src/main/java/com/dituhui/pea/order/controller/MsgController.java
project-order/src/main/java/com/dituhui/pea/order/dao/MsgDao.java
project-order/src/main/java/com/dituhui/pea/order/dto/MsgDTO.java
project-order/src/main/java/com/dituhui/pea/order/dto/ScheduleEngineerOverviewResp.java
project-order/src/main/java/com/dituhui/pea/order/entity/MsgEntity.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessLayerServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/DispatchServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/MsgServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderAssignImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderInfoServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/ScheduleServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/WorkbenchServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/utils/CommonUtil.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/DispatchServiceApplication.java
View file @
2c7ba0c
...
@@ -19,6 +19,7 @@ package com.dituhui.pea.dispatch;
...
@@ -19,6 +19,7 @@ package com.dituhui.pea.dispatch;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
/**
/**
...
@@ -27,6 +28,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
...
@@ -27,6 +28,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@SpringBootApplication
@EnableScheduling
@EnableScheduling
@EnableFeignClients
(
basePackages
=
{
"com.dituhui.pea.user"
})
@EnableFeignClients
(
basePackages
=
{
"com.dituhui.pea.user"
})
@Import
(
cn
.
hutool
.
extra
.
spring
.
SpringUtil
.
class
)
public
class
DispatchServiceApplication
{
public
class
DispatchServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/RedisConfig.java
→
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/
redis/
RedisConfig.java
View file @
2c7ba0c
package
com
.
dituhui
.
pea
.
dispatch
.
common
;
package
com
.
dituhui
.
pea
.
dispatch
.
common
.
redis
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
@Configuration
@Configuration
...
@@ -16,10 +21,27 @@ public class RedisConfig {
...
@@ -16,10 +21,27 @@ public class RedisConfig {
// objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(),
// objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(),
// ObjectMapper.DefaultTyping.EVERYTHING, JsonTypeInfo.As.PROPERTY);
// ObjectMapper.DefaultTyping.EVERYTHING, JsonTypeInfo.As.PROPERTY);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
Jackson2JsonRedisSerializer
jacksonSerial
=
new
Jackson2JsonRedisSerializer
(
Object
.
class
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
// 指定要序列化的域,field, get和set,以及修饰符范围,ANY是都有包括private和public
objectMapper
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会抛出异常
objectMapper
.
activateDefaultTyping
(
objectMapper
.
getPolymorphicTypeValidator
(),
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
// jsonToBean时,json中有的字段,bean中没有 无法匹配时,忽略此字段,不抛出异常(默认是抛出异常的)
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
jacksonSerial
.
setObjectMapper
(
objectMapper
);
RedisTemplate
<
String
,
String
>
redisTemplate
=
new
RedisTemplate
<>();
RedisTemplate
<
String
,
String
>
redisTemplate
=
new
RedisTemplate
<>();
redisTemplate
.
setConnectionFactory
(
connectionFactory
);
redisTemplate
.
setConnectionFactory
(
connectionFactory
);
redisTemplate
.
setKeySerializer
(
new
StringRedisSerializer
());
redisTemplate
.
setKeySerializer
(
new
StringRedisSerializer
());
redisTemplate
.
setValueSerializer
(
new
StringRedisSerializer
());
redisTemplate
.
setValueSerializer
(
jacksonSerial
);
// 设置hash key 和 value 序列化模式
redisTemplate
.
setHashKeySerializer
(
new
StringRedisSerializer
());
redisTemplate
.
setHashValueSerializer
(
jacksonSerial
);
return
redisTemplate
;
return
redisTemplate
;
}
}
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/redis/RedisUtil.java
0 → 100644
View file @
2c7ba0c
package
com
.
dituhui
.
pea
.
dispatch
.
common
.
redis
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
/**
* @Description: TODO redis 工具类
* @Author: RenPing
* @Date: 2022/7/25 10:27
* @Version: 1.0
*/
@Slf4j
@Component
public
class
RedisUtil
{
private
static
RedisTemplate
<
String
,
Object
>
redisTemplate
;
@PostConstruct
public
void
init
()
{
redisTemplate
=
SpringUtil
.
getBean
(
"redisTemplate"
);
}
// ============================ Common ============================
/**
* 指定缓存失效时间
*
* @param key 键
* @param time 时间(秒)
* @return
*/
public
static
boolean
expire
(
String
key
,
long
time
)
{
try
{
if
(
time
>
0
)
{
redisTemplate
.
expire
(
key
,
time
,
TimeUnit
.
SECONDS
);
}
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 根据key 获取过期时间
*
* @param key 键 不能为null
* @return 时间(秒) 返回0代表为永久有效
*/
public
static
long
getExpire
(
String
key
)
{
return
redisTemplate
.
getExpire
(
key
,
TimeUnit
.
SECONDS
);
}
/**
* 判断key是否存在
*
* @param key 键
* @return true 存在 false不存在
*/
public
static
boolean
hasKey
(
String
key
)
{
try
{
return
redisTemplate
.
hasKey
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 删除缓存
*
* @param key 可以传一个值 或多个
*/
public
static
void
del
(
String
...
key
)
{
if
(
ObjectUtil
.
isNotEmpty
(
key
))
{
redisTemplate
.
delete
(
Arrays
.
asList
(
key
));
}
}
/**
* 模糊查询并删除key,如:cache:user:*
*
* @param regex
*/
public
static
void
deleteByKeys
(
String
regex
)
{
Set
<
String
>
keys
=
redisTemplate
.
keys
(
regex
);
if
(
ObjectUtil
.
isNotEmpty
(
keys
))
{
redisTemplate
.
delete
(
keys
);
}
}
// ============================ String ============================
/**
* 普通缓存获取
*
* @param key 键
* @return 值
*/
public
static
Object
get
(
String
key
)
{
return
key
==
null
?
null
:
redisTemplate
.
opsForValue
().
get
(
key
);
}
/**
* 普通缓存放入
*
* @param key 键
* @param value 值
* @return true成功 false失败
*/
public
static
boolean
set
(
String
key
,
Object
value
)
{
try
{
redisTemplate
.
opsForValue
().
set
(
key
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 普通缓存放入并设置时间
*
* @param key 键
* @param value 值
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
* @return true成功 false 失败
*/
public
static
boolean
set
(
String
key
,
Object
value
,
long
time
)
{
try
{
if
(
time
>
0
)
{
redisTemplate
.
opsForValue
().
set
(
key
,
value
,
time
,
TimeUnit
.
SECONDS
);
}
else
{
set
(
key
,
value
);
}
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 递增
*
* @param key 键
* @param delta 要增加几(大于0)
* @return
*/
public
static
long
incr
(
String
key
,
long
delta
)
{
if
(
delta
<
0
)
{
throw
new
RuntimeException
(
"递增因子必须大于0"
);
}
return
redisTemplate
.
opsForValue
().
increment
(
key
,
delta
);
}
/**
* 递减
*
* @param key 键
* @param delta 要减少几(小于0)
* @return
*/
public
static
long
decr
(
String
key
,
long
delta
)
{
if
(
delta
<
0
)
{
throw
new
RuntimeException
(
"递减因子必须大于0"
);
}
return
redisTemplate
.
opsForValue
().
increment
(
key
,
-
delta
);
}
// ============================ Map ============================
/**
* HashGet
*
* @param key 键 不能为null
* @param item 项 不能为null
* @return 值
*/
public
static
Object
hget
(
String
key
,
String
item
)
{
return
redisTemplate
.
opsForHash
().
get
(
key
,
item
);
}
/**
* 获取hashKey对应的所有键值
*
* @param key 键
* @return 对应的多个键值
*/
public
static
Map
<
Object
,
Object
>
hmget
(
String
key
)
{
return
redisTemplate
.
opsForHash
().
entries
(
key
);
}
/**
* HashSet
*
* @param key 键
* @param map 对应多个键值
* @return true 成功 false 失败
*/
public
static
boolean
hmset
(
String
key
,
Map
<
Object
,
Object
>
map
)
{
try
{
redisTemplate
.
opsForHash
().
putAll
(
key
,
map
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* HashSet 并设置时间
*
* @param key 键
* @param map 对应多个键值
* @param time 时间(秒)
* @return true成功 false失败
*/
public
static
boolean
hmset
(
String
key
,
Map
<
Object
,
Object
>
map
,
long
time
)
{
try
{
redisTemplate
.
opsForHash
().
putAll
(
key
,
map
);
if
(
time
>
0
)
{
expire
(
key
,
time
);
}
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 向一张hash表中放入数据,如果不存在将创建
*
* @param key 键
* @param item 项
* @param value 值
* @return true 成功 false失败
*/
public
static
boolean
hset
(
String
key
,
String
item
,
Object
value
)
{
try
{
redisTemplate
.
opsForHash
().
put
(
key
,
item
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 向一张hash表中放入数据,如果不存在将创建
*
* @param key 键
* @param item 项
* @param value 值
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
* @return true 成功 false失败
*/
public
static
boolean
hset
(
String
key
,
String
item
,
Object
value
,
long
time
)
{
try
{
redisTemplate
.
opsForHash
().
put
(
key
,
item
,
value
);
if
(
time
>
0
)
{
expire
(
key
,
time
);
}
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 删除hash表中的值
*
* @param key 键 不能为null
* @param item 项 可以使多个 不能为null
*/
public
static
void
hdel
(
String
key
,
Object
...
item
)
{
redisTemplate
.
opsForHash
().
delete
(
key
,
item
);
}
/**
* 判断hash表中是否有该项的值
*
* @param key 键 不能为null
* @param item 项 不能为null
* @return true 存在 false不存在
*/
public
static
boolean
hHasKey
(
String
key
,
String
item
)
{
return
redisTemplate
.
opsForHash
().
hasKey
(
key
,
item
);
}
/**
* hash递增 如果不存在,就会创建一个 并把新增后的值返回
*
* @param key 键
* @param item 项
* @param by 要增加几(大于0)
* @return
*/
public
static
double
hincr
(
String
key
,
String
item
,
double
by
)
{
return
redisTemplate
.
opsForHash
().
increment
(
key
,
item
,
by
);
}
/**
* hash递减
*
* @param key 键
* @param item 项
* @param by 要减少记(小于0)
* @return
*/
public
static
double
hdecr
(
String
key
,
String
item
,
double
by
)
{
return
redisTemplate
.
opsForHash
().
increment
(
key
,
item
,
-
by
);
}
// ============================ set ============================
/**
* 根据key获取Set中的所有值
*
* @param key 键
* @return
*/
public
static
Set
<
Object
>
sGet
(
String
key
)
{
try
{
return
redisTemplate
.
opsForSet
().
members
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
null
;
}
}
/**
* 根据value从一个set中查询,是否存在
*
* @param key 键
* @param value 值
* @return true 存在 false不存在
*/
public
static
boolean
sHasKey
(
String
key
,
Object
value
)
{
try
{
return
redisTemplate
.
opsForSet
().
isMember
(
key
,
value
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 将数据放入set缓存
*
* @param key 键
* @param values 值 可以是多个
* @return 成功个数
*/
public
static
long
sSet
(
String
key
,
Object
...
values
)
{
try
{
return
redisTemplate
.
opsForSet
().
add
(
key
,
values
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
/**
* 将set数据放入缓存
*
* @param key 键
* @param time 时间(秒)
* @param values 值 可以是多个
* @return 成功个数
*/
public
static
long
sSetAndTime
(
String
key
,
long
time
,
Object
...
values
)
{
try
{
Long
count
=
redisTemplate
.
opsForSet
().
add
(
key
,
values
);
if
(
time
>
0
)
{
expire
(
key
,
time
);
}
return
count
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
/**
* 获取set缓存的长度
*
* @param key 键
* @return
*/
public
static
long
sGetSetSize
(
String
key
)
{
try
{
return
redisTemplate
.
opsForSet
().
size
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
/**
* 移除值为value的
*
* @param key 键
* @param values 值 可以是多个
* @return 移除的个数
*/
public
static
long
setRemove
(
String
key
,
Object
...
values
)
{
try
{
Long
count
=
redisTemplate
.
opsForSet
().
remove
(
key
,
values
);
return
count
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
// ============================ list ============================
/**
* 获取list缓存的内容
*
* @param key 键
* @param start 开始
* @param end 结束 0 到 -1代表所有值
* @return
*/
public
static
List
<
Object
>
lGet
(
String
key
,
long
start
,
long
end
)
{
try
{
return
redisTemplate
.
opsForList
().
range
(
key
,
start
,
end
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
null
;
}
}
/**
* 获取list缓存的长度
*
* @param key 键
* @return
*/
public
static
long
lGetListSize
(
String
key
)
{
try
{
return
redisTemplate
.
opsForList
().
size
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
/**
* 通过索引 获取list中的值
*
* @param key 键
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
* @return
*/
public
static
Object
lGetIndex
(
String
key
,
long
index
)
{
try
{
return
redisTemplate
.
opsForList
().
index
(
key
,
index
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
null
;
}
}
/**
* 将list放入缓存
*
* @param key 键
* @param value 值
* @return
*/
public
static
boolean
lSet
(
String
key
,
Object
value
)
{
try
{
redisTemplate
.
opsForList
().
rightPush
(
key
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 将list放入缓存
*
* @param key 键
* @param value 值
* @param time 时间(秒)
* @return
*/
public
static
boolean
lSet
(
String
key
,
Object
value
,
long
time
)
{
try
{
redisTemplate
.
opsForList
().
rightPush
(
key
,
value
);
if
(
time
>
0
)
{
expire
(
key
,
time
);
}
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 将list放入缓存
*
* @param key 键
* @param value 值
* @return
*/
public
static
boolean
lSet
(
String
key
,
List
<
Object
>
value
)
{
try
{
redisTemplate
.
opsForList
().
rightPushAll
(
key
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 将list放入缓存
*
* @param key 键
* @param value 值
* @param time 时间(秒)
* @return
*/
public
static
boolean
lSet
(
String
key
,
List
<
Object
>
value
,
long
time
)
{
try
{
redisTemplate
.
opsForList
().
rightPushAll
(
key
,
value
);
if
(
time
>
0
)
{
expire
(
key
,
time
);
}
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 根据索引修改list中的某条数据
*
* @param key 键
* @param index 索引
* 507
* @param value 值
* @return
*/
public
static
boolean
lUpdateIndex
(
String
key
,
long
index
,
Object
value
)
{
try
{
redisTemplate
.
opsForList
().
set
(
key
,
index
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 移除N个值为value
*
* @param key 键
* @param count 移除多少个
* @param value 值
* @return 移除的个数
*/
public
static
long
lRemove
(
String
key
,
long
count
,
Object
value
)
{
try
{
Long
remove
=
redisTemplate
.
opsForList
().
remove
(
key
,
count
,
value
);
return
remove
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
}
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/RedissonConfig.java
→
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/
redis/
RedissonConfig.java
View file @
2c7ba0c
package
com
.
dituhui
.
pea
.
dispatch
.
common
;
package
com
.
dituhui
.
pea
.
dispatch
.
common
.
redis
;
import
org.redisson.Redisson
;
import
org.redisson.Redisson
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.RedissonClient
;
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/RedissonUtil.java
→
project-dispatch/src/main/java/com/dituhui/pea/dispatch/common/
redis/
RedissonUtil.java
View file @
2c7ba0c
package
com
.
dituhui
.
pea
.
dispatch
.
common
;
package
com
.
dituhui
.
pea
.
dispatch
.
common
.
redis
;
import
cn.hutool.extra.spring.SpringUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/constraint/DispatchConstraintProvider.java
View file @
2c7ba0c
...
@@ -67,8 +67,12 @@ public class DispatchConstraintProvider implements ConstraintProvider {
...
@@ -67,8 +67,12 @@ public class DispatchConstraintProvider implements ConstraintProvider {
Integer
arrivalTime
=
customer
.
getArrivalTime
();
Integer
arrivalTime
=
customer
.
getArrivalTime
();
if
(
arrivalTime
!=
null
&&
arrivalTime
>
0
)
{
if
(
arrivalTime
!=
null
&&
arrivalTime
>
0
)
{
boolean
in
=
false
;
boolean
in
=
false
;
Integer
departureTime
=
customer
.
getDepartureTime
();
for
(
int
[]
window
:
timeWindows
)
{
for
(
int
[]
window
:
timeWindows
)
{
if
(
window
[
0
]
<=
arrivalTime
&&
window
[
1
]
>=
arrivalTime
)
{
if
(
window
[
0
]
<=
arrivalTime
&&
window
[
1
]
>=
arrivalTime
&&
window
[
0
]
<=
departureTime
&&
window
[
1
]
>=
departureTime
)
{
in
=
true
;
in
=
true
;
break
;
break
;
}
}
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/constraint/RedisKeyConstant.java
0 → 100644
View file @
2c7ba0c
package
com
.
dituhui
.
pea
.
dispatch
.
constraint
;
public
class
RedisKeyConstant
{
public
static
final
String
LOCATION_DISTANCE_KEY
=
"location:%s:distance:%s"
;
public
static
final
String
LOCATION_DISTANCE_TIME_KEY
=
"location:%s:distanceTime:%s"
;
}
project-dispatch/src/main/java/com/dituhui/pea/dispatch/quartz/dispatch/AutoDispatchJob.java
View file @
2c7ba0c
package
com
.
dituhui
.
pea
.
dispatch
.
quartz
.
dispatch
;
package
com
.
dituhui
.
pea
.
dispatch
.
quartz
.
dispatch
;
import
com.dituhui.pea.dispatch.common.RedissonUtil
;
import
com.dituhui.pea.dispatch.service.SchedulerService
;
import
com.dituhui.pea.dispatch.service.SchedulerService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.quartz.DisallowConcurrentExecution
;
import
org.quartz.DisallowConcurrentExecution
;
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/scheduler/BatchScheduler.java
View file @
2c7ba0c
...
@@ -88,7 +88,7 @@ public class BatchScheduler {
...
@@ -88,7 +88,7 @@ public class BatchScheduler {
log
.
info
(
"dispatchRun done ------ teamId:{}, day:{}"
,
teamId
,
currDay
);
log
.
info
(
"dispatchRun done ------ teamId:{}, day:{}"
,
teamId
,
currDay
);
JacksonSolutionFileIO
<
DispatchSolution
>
exporter
=
new
JacksonSolutionFileIO
<
DispatchSolution
>(
DispatchSolution
.
class
);
JacksonSolutionFileIO
<
DispatchSolution
>
exporter
=
new
JacksonSolutionFileIO
<
DispatchSolution
>(
DispatchSolution
.
class
);
exporter
.
write
(
solution
,
new
File
(
String
.
format
(
"dispatchSolution_%s_%s.json"
,
teamId
,
currDay
)));
exporter
.
write
(
solution
,
new
File
(
String
.
format
(
"dispatchSolution_%s_%s.json"
,
teamId
,
currDay
)));
}
}
}
}
...
@@ -155,7 +155,7 @@ public class BatchScheduler {
...
@@ -155,7 +155,7 @@ public class BatchScheduler {
// Set the output file.
// Set the output file.
exporter
.
write
(
solution
,
new
File
(
String
.
format
(
"dispatchSolution_%s_%s.json"
,
groupId
,
currDay
)));
exporter
.
write
(
solution
,
new
File
(
String
.
format
(
"dispatchSolution_%s_%s.json"
,
groupId
,
currDay
)));
Thread
.
sleep
(
1000
*
5
);
Thread
.
sleep
(
1000
*
5
);
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/ExtractServiceImpl.java
View file @
2c7ba0c
...
@@ -3,9 +3,12 @@ package com.dituhui.pea.dispatch.service.impl;
...
@@ -3,9 +3,12 @@ package com.dituhui.pea.dispatch.service.impl;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.nacos.common.utils.CollectionUtils
;
import
com.alibaba.nacos.common.utils.CollectionUtils
;
import
com.dituhui.pea.dispatch.dao.*
;
import
com.dituhui.pea.dispatch.dao.*
;
import
com.dituhui.pea.dispatch.entity.*
;
import
com.dituhui.pea.dispatch.entity.*
;
import
com.dituhui.pea.dispatch.pojo.Customer
;
import
com.dituhui.pea.dispatch.pojo.DispatchSolution
;
import
com.dituhui.pea.dispatch.service.ExtractService
;
import
com.dituhui.pea.dispatch.service.ExtractService
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
...
@@ -295,7 +298,13 @@ public class ExtractServiceImpl implements ExtractService {
...
@@ -295,7 +298,13 @@ public class ExtractServiceImpl implements ExtractService {
orderInfo
.
setArriveElapsed
(
0
);
orderInfo
.
setArriveElapsed
(
0
);
orderInfo
.
setArriveDistance
(
0
);
orderInfo
.
setArriveDistance
(
0
);
orderInfo
.
setAppointmentStatus
(
"INIT"
);
orderInfo
.
setAppointmentStatus
(
"INIT"
);
if
(
cutOff
)
{
orderInfo
.
setAppointmentMethod
(
"MANUAL"
);
orderInfo
.
setDispatcher
(
"MANUAL"
);
log
.
info
(
"算法结果更新到工单为人工, teamId:{}, batchNo:{}, orderId:{}"
,
teamId
,
batchNo
,
orderId
);
}
else
{
orderInfo
.
setDispatcher
(
"AUTO_BATCH"
);
orderInfo
.
setDispatcher
(
"AUTO_BATCH"
);
}
orderInfo
.
setUpdateTime
(
LocalDateTime
.
now
());
orderInfo
.
setUpdateTime
(
LocalDateTime
.
now
());
orderInfoRepo
.
save
(
orderInfo
);
orderInfoRepo
.
save
(
orderInfo
);
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/SchedulerServiceImpl.java
View file @
2c7ba0c
...
@@ -3,7 +3,6 @@ package com.dituhui.pea.dispatch.service.impl;
...
@@ -3,7 +3,6 @@ package com.dituhui.pea.dispatch.service.impl;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.dituhui.pea.dispatch.common.RedissonUtil
;
import
com.dituhui.pea.dispatch.dao.DispatchBatchRepository
;
import
com.dituhui.pea.dispatch.dao.DispatchBatchRepository
;
import
com.dituhui.pea.dispatch.dao.OrgGroupRepository
;
import
com.dituhui.pea.dispatch.dao.OrgGroupRepository
;
import
com.dituhui.pea.dispatch.dao.OrgTeamDao
;
import
com.dituhui.pea.dispatch.dao.OrgTeamDao
;
...
@@ -11,7 +10,6 @@ import com.dituhui.pea.dispatch.entity.DispatchBatch;
...
@@ -11,7 +10,6 @@ import com.dituhui.pea.dispatch.entity.DispatchBatch;
import
com.dituhui.pea.dispatch.entity.OrgGroup
;
import
com.dituhui.pea.dispatch.entity.OrgGroup
;
import
com.dituhui.pea.dispatch.entity.OrgTeamEntity
;
import
com.dituhui.pea.dispatch.entity.OrgTeamEntity
;
import
com.dituhui.pea.dispatch.pojo.DispatchSolution
;
import
com.dituhui.pea.dispatch.pojo.DispatchSolution
;
import
com.dituhui.pea.dispatch.quartz.dispatch.AutoDispatchJob
;
import
com.dituhui.pea.dispatch.service.BatchService
;
import
com.dituhui.pea.dispatch.service.BatchService
;
import
com.dituhui.pea.dispatch.service.ExtractService
;
import
com.dituhui.pea.dispatch.service.ExtractService
;
import
com.dituhui.pea.dispatch.service.SchedulerService
;
import
com.dituhui.pea.dispatch.service.SchedulerService
;
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/utils/RoadDistanceUtils.java
View file @
2c7ba0c
...
@@ -2,6 +2,7 @@ package com.dituhui.pea.dispatch.utils;
...
@@ -2,6 +2,7 @@ package com.dituhui.pea.dispatch.utils;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.math.BigDecimal
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLConnection
;
...
@@ -10,6 +11,8 @@ import java.util.HashMap;
...
@@ -10,6 +11,8 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
cn.hutool.core.util.StrUtil
;
import
com.dituhui.pea.dispatch.common.redis.RedisUtil
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
com.dituhui.pea.dispatch.pojo.Location
;
import
com.dituhui.pea.dispatch.pojo.Location
;
...
@@ -25,7 +28,6 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -25,7 +28,6 @@ import lombok.extern.slf4j.Slf4j;
* TODO 调用方式需要改成批量调用方式
* TODO 调用方式需要改成批量调用方式
*
*
* @author gpzhang
* @author gpzhang
*
*/
*/
@Component
@Component
@Slf4j
@Slf4j
...
@@ -37,7 +39,7 @@ public class RoadDistanceUtils {
...
@@ -37,7 +39,7 @@ public class RoadDistanceUtils {
/**
/**
* 格式 x1,y1;x2,y2
* 格式 x1,y1;x2,y2
*/
*/
private
static
Map
<
String
,
Distance
>
distanceCache
=
Maps
.
newHashMap
();
//
private static Map<String, Distance> distanceCache = Maps.newHashMap();
private
static
Gson
gson
=
new
Gson
();
private
static
Gson
gson
=
new
Gson
();
/**
/**
...
@@ -50,9 +52,9 @@ public class RoadDistanceUtils {
...
@@ -50,9 +52,9 @@ public class RoadDistanceUtils {
*/
*/
public
Distance
getDistance2
(
Location
from
,
Location
to
,
int
vehicleType
)
{
public
Distance
getDistance2
(
Location
from
,
Location
to
,
int
vehicleType
)
{
try
{
try
{
String
key
=
from
.
getLongitude
()
+
","
+
from
.
getLatitude
()
+
";"
+
to
.
getLongitude
()
+
","
String
key
=
getLocationKey
(
from
,
to
,
vehicleType
);
+
to
.
getLatitude
()
+
"|"
+
vehicleType
;
//Distance distance = distanceCache.get(key)
;
Distance
distance
=
distanceCache
.
get
(
key
);
Distance
distance
=
(
Distance
)
RedisUtil
.
get
(
key
);
if
(
null
==
distance
)
{
if
(
null
==
distance
)
{
distance
=
getDistance
(
from
.
getLatitude
()
+
","
+
from
.
getLongitude
(),
distance
=
getDistance
(
from
.
getLatitude
()
+
","
+
from
.
getLongitude
(),
to
.
getLatitude
()
+
","
+
to
.
getLongitude
(),
vehicleType
);
to
.
getLatitude
()
+
","
+
to
.
getLongitude
(),
vehicleType
);
...
@@ -61,7 +63,8 @@ public class RoadDistanceUtils {
...
@@ -61,7 +63,8 @@ public class RoadDistanceUtils {
Distance
dis
=
new
Distance
();
Distance
dis
=
new
Distance
();
return
dis
;
return
dis
;
}
else
{
}
else
{
distanceCache
.
put
(
key
,
distance
);
//distanceCache.put(key, distance);
RedisUtil
.
set
(
key
,
distance
);
}
}
return
distance
;
return
distance
;
}
else
{
}
else
{
...
@@ -86,9 +89,9 @@ public class RoadDistanceUtils {
...
@@ -86,9 +89,9 @@ public class RoadDistanceUtils {
*/
*/
public
static
Distance
getDistance
(
Location
from
,
Location
to
,
int
vehicleType
)
{
public
static
Distance
getDistance
(
Location
from
,
Location
to
,
int
vehicleType
)
{
try
{
try
{
String
key
=
from
.
getLongitude
()
+
","
+
from
.
getLatitude
()
+
";"
+
to
.
getLongitude
()
+
","
String
key
=
getLocationKey
(
from
,
to
,
vehicleType
);
+
to
.
getLatitude
()
+
"|"
+
vehicleType
;
//Distance distance = distanceCache.get(key)
;
Distance
distance
=
distanceCache
.
get
(
key
);
Distance
distance
=
(
Distance
)
RedisUtil
.
get
(
key
);
if
(
null
==
distance
)
{
if
(
null
==
distance
)
{
distance
=
getDistance
(
from
.
getLatitude
()
+
","
+
from
.
getLongitude
(),
distance
=
getDistance
(
from
.
getLatitude
()
+
","
+
from
.
getLongitude
(),
to
.
getLatitude
()
+
","
+
to
.
getLongitude
(),
vehicleType
);
to
.
getLatitude
()
+
","
+
to
.
getLongitude
(),
vehicleType
);
...
@@ -96,7 +99,8 @@ public class RoadDistanceUtils {
...
@@ -96,7 +99,8 @@ public class RoadDistanceUtils {
Distance
dis
=
new
Distance
();
Distance
dis
=
new
Distance
();
return
dis
;
return
dis
;
}
else
{
}
else
{
distanceCache
.
put
(
key
,
distance
);
//distanceCache.put(key, distance);
RedisUtil
.
set
(
key
,
distance
);
}
}
return
distance
;
return
distance
;
}
else
{
}
else
{
...
@@ -108,6 +112,27 @@ public class RoadDistanceUtils {
...
@@ -108,6 +112,27 @@ public class RoadDistanceUtils {
}
}
}
}
public
static
String
getLocationKey
(
Location
from
,
Location
to
,
int
vehicleType
)
{
return
convertDoubleToStr
(
from
.
getLongitude
())
+
","
+
convertDoubleToStr
(
from
.
getLatitude
())
+
";"
+
convertDoubleToStr
(
to
.
getLongitude
())
+
","
+
convertDoubleToStr
(
to
.
getLatitude
())
+
"|"
+
vehicleType
;
}
public
static
String
convertDoubleToStr
(
double
value
)
{
String
[]
ss
=
BigDecimal
.
valueOf
(
value
).
toString
().
split
(
"\\."
);
if
(
ss
.
length
==
1
)
{
return
ss
[
0
]
+
".00000"
;
}
if
(
ss
[
1
].
length
()
>=
5
)
{
return
ss
[
0
]
+
"."
+
ss
[
1
].
substring
(
0
,
5
);
}
return
ss
[
0
]
+
"."
+
StrUtil
.
padAfter
(
ss
[
1
],
5
,
"0"
);
}
private
static
Distance
getDistance
(
String
yx1
,
String
yx2
,
int
vehicleType
)
throws
Exception
{
private
static
Distance
getDistance
(
String
yx1
,
String
yx2
,
int
vehicleType
)
throws
Exception
{
...
@@ -138,7 +163,7 @@ public class RoadDistanceUtils {
...
@@ -138,7 +163,7 @@ public class RoadDistanceUtils {
String
text
=
requestGetAK
(
url
,
params
);
String
text
=
requestGetAK
(
url
,
params
);
// System.out.println(url + " : " + gson.toJson(params) + " : " + text);
// System.out.println(url + " : " + gson.toJson(params) + " : " + text);
BDResult
webResult
=
gson
.
fromJson
(
text
,
BDResult
.
class
);
BDResult
webResult
=
gson
.
fromJson
(
text
,
BDResult
.
class
);
float
dis
=
webResult
.
getResult
().
get
(
0
).
getDistance
().
getValue
()
/
1000
F
;
float
dis
=
webResult
.
getResult
().
get
(
0
).
getDistance
().
getValue
()
;
int
time
=
webResult
.
getResult
().
get
(
0
).
getDuration
().
getValue
();
int
time
=
webResult
.
getResult
().
get
(
0
).
getDuration
().
getValue
();
Distance
d
=
new
Distance
();
Distance
d
=
new
Distance
();
...
...
project-dispatch/src/main/resources/application-dev.yaml
View file @
2c7ba0c
...
@@ -3,7 +3,7 @@ server:
...
@@ -3,7 +3,7 @@ server:
dispatch
:
dispatch
:
cron
:
cron
:
expr
:
0
9
8-23 * * ?
expr
:
0
20
8-23 * * ?
next-day-limit
:
2
next-day-limit
:
2
scheduler
:
scheduler
:
...
...
project-dispatch/src/main/resources/logback-spring.xml
View file @
2c7ba0c
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
<property
name=
"FILE_LOG_PATTERN"
<property
name=
"FILE_LOG_PATTERN"
value=
"%d{yyyy-MM-dd HH:mm:ss} %-5level ${spring.application.name:-} %thread %logger %msg%n"
/>
value=
"%d{yyyy-MM-dd HH:mm:ss} %-5level ${spring.application.name:-} %thread %logger %msg%n"
/>
<!-- 控制台输出 -->
<!-- 控制台输出 -->
<appender
name=
"
console
"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<appender
name=
"
CONSOLE
"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
DEBUG
</level>
<level>
DEBUG
</level>
</filter>
</filter>
...
@@ -29,23 +29,44 @@
...
@@ -29,23 +29,44 @@
</encoder>
</encoder>
</appender>
</appender>
<!-- 按照每天生成常规日志文件 -->
<appender
name=
"FILE_DEBUG"
<appender
name=
"FileAppender"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_FILE}/info/${spring.application.name:-}.info.log
</file>
<File>
${LOG_FILE}/debug/${spring.application.name:-}.debug.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.debug-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
${FILE_LOG_PATTERN}
</pattern>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
<charset>
UTF-8
</charset>
</encoder>
</encoder>
<!-- 基于时间的分包策略 -->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<level>
DEBUG
</level>
<fileNamePattern>
${LOG_FILE}/info/${spring.application.name:-}.info.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<onMatch>
ACCEPT
</onMatch>
<!--保留时间,单位:天-->
<onMismatch>
DENY
</onMismatch>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
</filter>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
</appender>
<appender
name=
"FILE_INFO"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_FILE}/info/${spring.application.name:-}.info.log
</File>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<FileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.info-%d{yyyy-MM-dd}-%i.zip
</FileNamePattern>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<totalSizeCap>
500MB
</totalSizeCap>
</rollingPolicy>
</rollingPolicy>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<!-- 只打印错误日志 -->
<level>
INFO
</level>
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
<onMismatch>
DENY
</onMismatch>
...
@@ -98,26 +119,6 @@
...
@@ -98,26 +119,6 @@
</filter>
</filter>
</appender>
</appender>
<appender
name=
"FILE_DEBUG"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_FILE}/debug/${spring.application.name:-}.debug.log
</file>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
${FILE_LOG_PATTERN}
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<!-- 基于时间的分包策略 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${LOG_FILE}/debug/${spring.application.name:-}.debug.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<!--保留时间,单位:天-->
<maxHistory>
${LOG_FILEMAXDAY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${LOG_MAXFILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
DEBUG
</level>
</filter>
</appender>
<!-- 异步输出 -->
<!-- 异步输出 -->
<appender
name=
"ASYNC"
class=
"ch.qos.logback.classic.AsyncAppender"
>
<appender
name=
"ASYNC"
class=
"ch.qos.logback.classic.AsyncAppender"
>
<!-- 0-不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<!-- 0-不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
...
@@ -125,7 +126,7 @@
...
@@ -125,7 +126,7 @@
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>
256
</queueSize>
<queueSize>
256
</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref
ref=
"F
ileAppender
"
/>
<appender-ref
ref=
"F
ILE_INFO
"
/>
</appender>
</appender>
<logger
name=
"org.optaplanner"
level=
"info"
/>
<logger
name=
"org.optaplanner"
level=
"info"
/>
...
@@ -133,8 +134,8 @@
...
@@ -133,8 +134,8 @@
<!-- 日志输出级别 -->
<!-- 日志输出级别 -->
<root
level=
"info"
>
<root
level=
"info"
>
<appender-ref
ref=
"
console
"
/>
<appender-ref
ref=
"
CONSOLE
"
/>
<appender-ref
ref=
"F
ileAppender
"
/>
<appender-ref
ref=
"F
ILE_INFO
"
/>
<appender-ref
ref=
"FILE_ERROR"
/>
<appender-ref
ref=
"FILE_ERROR"
/>
<appender-ref
ref=
"FILE_WARN"
/>
<appender-ref
ref=
"FILE_WARN"
/>
</root>
</root>
...
...
project-order/src/main/java/com/dituhui/pea/order/controller/MsgController.java
View file @
2c7ba0c
...
@@ -91,9 +91,6 @@ public class MsgController {
...
@@ -91,9 +91,6 @@ public class MsgController {
@PostMapping
(
"/msg/add"
)
@PostMapping
(
"/msg/add"
)
public
Result
<
Boolean
>
add
(
@RequestBody
@Valid
MsgDTO
dto
)
{
public
Result
<
Boolean
>
add
(
@RequestBody
@Valid
MsgDTO
dto
)
{
CommonUtil
.
setNullValue
(
dto
);
CommonUtil
.
setNullValue
(
dto
);
AssertUtil
.
checkArgument
(
StrUtil
.
isNotEmpty
(
dto
.
getClusterId
())
||
StrUtil
.
isNotEmpty
(
dto
.
getBranchId
())
||
StrUtil
.
isNotEmpty
(
dto
.
getGroupId
()),
"大区Id、分部Id、分组Id不能同时为空"
);
msgService
.
add
(
dto
);
msgService
.
add
(
dto
);
return
Result
.
success
(
true
);
return
Result
.
success
(
true
);
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/dao/MsgDao.java
View file @
2c7ba0c
...
@@ -86,4 +86,20 @@ public interface MsgDao extends JpaRepository<MsgEntity, Integer> {
...
@@ -86,4 +86,20 @@ public interface MsgDao extends JpaRepository<MsgEntity, Integer> {
" from zzz_msg tt join zzz_msg_receiver r on r.deleted=0 and r.msg_id=tt.id and r.is_read=0 and r.user_id=?1"
" from zzz_msg tt join zzz_msg_receiver r on r.deleted=0 and r.msg_id=tt.id and r.is_read=0 and r.user_id=?1"
,
nativeQuery
=
true
)
,
nativeQuery
=
true
)
Integer
getUnReadNum
(
String
userId
);
Integer
getUnReadNum
(
String
userId
);
@Query
(
value
=
"SELECT count(t.id)"
+
" from zzz_msg t"
+
" where IF(:groupId is not null, t.group_id =:groupId, t.group_id is null)"
+
" and IF(:branchId is not null, t.branch_id =:branchId, t.branch_id is null)"
+
" and IF(:clusterId is not null, t.cluster_id =:clusterId, t.cluster_id is null)"
+
" and t.capacity_layer_id = :capacityLayerId"
+
" and t.capacity_date = :capacityDate"
+
" and date_format(t.create_time,'%Y-%m-%d')=date_format(now(),'%Y-%m-%d')"
,
nativeQuery
=
true
)
Integer
getCapacityMsgCount
(
@Param
(
"clusterId"
)
String
clusterId
,
@Param
(
"branchId"
)
String
branchId
,
@Param
(
"groupId"
)
String
groupId
,
@Param
(
"capacityLayerId"
)
String
capacityLayerId
,
@Param
(
"capacityDate"
)
String
capacityDate
);
}
}
project-order/src/main/java/com/dituhui/pea/order/dto/MsgDTO.java
View file @
2c7ba0c
...
@@ -50,6 +50,16 @@ public class MsgDTO {
...
@@ -50,6 +50,16 @@ public class MsgDTO {
@Max
(
value
=
1
,
message
=
"标签类型格式不对"
)
@Max
(
value
=
1
,
message
=
"标签类型格式不对"
)
private
Integer
tag
;
private
Integer
tag
;
/**
* 容量所属图层 ID
*/
private
String
capacityLayerId
;
/**
* 容量所属日期
*/
private
String
capacityDate
;
@Data
@Data
public
static
class
IdDTO
{
public
static
class
IdDTO
{
...
...
project-order/src/main/java/com/dituhui/pea/order/dto/ScheduleEngineerOverviewResp.java
View file @
2c7ba0c
...
@@ -26,7 +26,7 @@ public class ScheduleEngineerOverviewResp {
...
@@ -26,7 +26,7 @@ public class ScheduleEngineerOverviewResp {
/**
/**
* 在途公里数
* 在途公里数
*/
*/
private
Integer
distance
;
private
String
distance
;
/**
/**
* 上门时间
* 上门时间
*/
*/
...
...
project-order/src/main/java/com/dituhui/pea/order/entity/MsgEntity.java
View file @
2c7ba0c
...
@@ -73,5 +73,17 @@ public class MsgEntity {
...
@@ -73,5 +73,17 @@ public class MsgEntity {
@Column
(
name
=
"update_time"
,
nullable
=
false
,
columnDefinition
=
"datetime default current_timestamp"
)
@Column
(
name
=
"update_time"
,
nullable
=
false
,
columnDefinition
=
"datetime default current_timestamp"
)
private
Date
updateTime
;
private
Date
updateTime
;
/**
* 容量类所属图层ID
*/
@Column
(
name
=
"capacity_layer_id"
)
private
String
capacityLayerId
;
/**
* 容量类所属日期:2022-10-20
*/
@Column
(
name
=
"capacity_date"
)
private
String
capacityDate
;
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessLayerServiceImpl.java
View file @
2c7ba0c
...
@@ -304,16 +304,16 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
...
@@ -304,16 +304,16 @@ public class BusinessLayerServiceImpl implements BusinessLayerService {
List
<
String
>
items
=
new
ArrayList
<>();
List
<
String
>
items
=
new
ArrayList
<>();
List
<
SkillInfoEntity
>
skills
=
skillInfoDao
.
findAll
();
List
<
SkillInfoEntity
>
skills
=
skillInfoDao
.
findAll
();
Map
<
String
,
S
tring
>
skillMap
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
Map
<
String
,
S
killInfoEntity
>
skillMap
=
skills
.
stream
().
collect
(
Collectors
.
toMap
(
SkillInfoEntity:
:
getSkillCode
,
SkillInfoEntity:
:
getSkill
));
SkillInfoEntity:
:
getSkillCode
,
e
->
e
));
List
<
MapLayerCustomizeSkillEntity
>
laySkills
=
mapLayerCustomizeSkillDao
.
findByLayerId
(
layerId
);
List
<
MapLayerCustomizeSkillEntity
>
laySkills
=
mapLayerCustomizeSkillDao
.
findByLayerId
(
layerId
);
for
(
MapLayerCustomizeSkillEntity
s
:
laySkills
)
{
for
(
MapLayerCustomizeSkillEntity
s
:
laySkills
)
{
if
(
s
.
getStatus
()
==
0
)
{
if
(
s
.
getStatus
()
==
0
)
{
continue
;
continue
;
}
}
S
tring
skill
=
skillMap
.
getOrDefault
(
s
.
getSkillCode
(),
""
);
S
killInfoEntity
skill
=
skillMap
.
getOrDefault
(
s
.
getSkillCode
(),
null
);
items
.
add
(
skill
);
items
.
add
(
skill
.
getType
()
+
"-"
+
skill
.
getSkill
()
);
}
}
return
items
;
return
items
;
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/DispatchServiceImpl.java
View file @
2c7ba0c
...
@@ -373,8 +373,9 @@ public class DispatchServiceImpl implements DispatchService {
...
@@ -373,8 +373,9 @@ public class DispatchServiceImpl implements DispatchService {
if
(
CollectionUtils
.
isNotEmpty
(
errorList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
errorList
))
{
String
msg
=
errorList
.
size
()
>
3
?
String
.
join
(
","
,
errorList
.
subList
(
0
,
3
))
+
"..."
:
String
.
join
(
","
,
errorList
);
String
msg
=
errorList
.
size
()
>
3
?
String
.
join
(
","
,
errorList
.
subList
(
0
,
3
))
+
"..."
:
String
.
join
(
","
,
errorList
);
resultList
.
add
(
String
.
format
(
StatusCodeEnum
.
ENGINEER_IS_LEAVE_TIME
.
getDesc
(),
msg
,
engineer
.
getName
()));
resultList
.
add
(
String
.
format
(
StatusCodeEnum
.
ENGINEER_IS_LEAVE_TIME
.
getDesc
(),
msg
,
engineer
.
getName
()));
return
Result
.
failed
(
CollectionUtils
.
isNotEmpty
(
resultList
)
?
String
.
join
(
","
,
resultList
)
:
null
);
}
}
return
Result
.
success
(
CollectionUtils
.
isNotEmpty
(
resultList
)
?
String
.
join
(
","
,
resultList
)
:
null
);
return
Result
.
success
();
}
}
@Override
@Override
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/MsgServiceImpl.java
View file @
2c7ba0c
...
@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl;
...
@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dao.*
;
...
@@ -16,6 +17,7 @@ import com.dituhui.pea.order.entity.OrgGroupEntity;
...
@@ -16,6 +17,7 @@ import com.dituhui.pea.order.entity.OrgGroupEntity;
import
com.dituhui.pea.order.enums.MsgTagEnum
;
import
com.dituhui.pea.order.enums.MsgTagEnum
;
import
com.dituhui.pea.order.enums.MsgTypeEnum
;
import
com.dituhui.pea.order.enums.MsgTypeEnum
;
import
com.dituhui.pea.order.service.MsgService
;
import
com.dituhui.pea.order.service.MsgService
;
import
com.dituhui.pea.order.utils.AssertUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.*
;
import
org.springframework.data.domain.*
;
...
@@ -121,6 +123,10 @@ public class MsgServiceImpl implements MsgService {
...
@@ -121,6 +123,10 @@ public class MsgServiceImpl implements MsgService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
add
(
MsgDTO
dto
)
{
public
void
add
(
MsgDTO
dto
)
{
AssertUtil
.
checkArgument
(
StrUtil
.
isNotEmpty
(
dto
.
getClusterId
())
||
StrUtil
.
isNotEmpty
(
dto
.
getBranchId
())
||
StrUtil
.
isNotEmpty
(
dto
.
getGroupId
()),
"大区Id、分部Id、分组Id不能同时为空"
);
if
(
Objects
.
nonNull
(
dto
.
getGroupId
()))
{
if
(
Objects
.
nonNull
(
dto
.
getGroupId
()))
{
OrgGroupEntity
group
=
groupDao
.
getByGroupId
(
dto
.
getGroupId
());
OrgGroupEntity
group
=
groupDao
.
getByGroupId
(
dto
.
getGroupId
());
dto
.
setBranchId
(
group
.
getBranchId
());
dto
.
setBranchId
(
group
.
getBranchId
());
...
@@ -133,6 +139,19 @@ public class MsgServiceImpl implements MsgService {
...
@@ -133,6 +139,19 @@ public class MsgServiceImpl implements MsgService {
dto
.
setClusterId
(
branch
.
getClusterId
());
dto
.
setClusterId
(
branch
.
getClusterId
());
}
}
if
(
ObjectUtil
.
equals
(
MsgTypeEnum
.
CAPACITY
.
getCode
(),
dto
.
getType
()))
{
AssertUtil
.
checkArgument
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCapacityLayerId
())
&&
ObjectUtil
.
isNotEmpty
(
dto
.
getCapacityDate
()),
"容量类消息图层ID、所属日期不能为空"
);
int
count
=
msgDao
.
getCapacityMsgCount
(
dto
.
getClusterId
(),
dto
.
getBranchId
(),
dto
.
getGroupId
(),
dto
.
getCapacityLayerId
(),
dto
.
getCapacityDate
());
if
(
count
>
0
)
{
return
;
}
}
List
<
String
>
userList
=
msgDao
.
getDispatchUserList
(
dto
.
getClusterId
(),
dto
.
getBranchId
(),
dto
.
getGroupId
());
List
<
String
>
userList
=
msgDao
.
getDispatchUserList
(
dto
.
getClusterId
(),
dto
.
getBranchId
(),
dto
.
getGroupId
());
MsgEntity
msgEntity
=
new
MsgEntity
();
MsgEntity
msgEntity
=
new
MsgEntity
();
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderAssignImpl.java
View file @
2c7ba0c
...
@@ -308,7 +308,7 @@ public class OrderAssignImpl implements OrderAssign {
...
@@ -308,7 +308,7 @@ public class OrderAssignImpl implements OrderAssign {
private
OrderInfoEntity
handleMultipleOrders
(
OrderInfoEntity
order
)
{
private
OrderInfoEntity
handleMultipleOrders
(
OrderInfoEntity
order
)
{
//处理一家多单逻辑
//处理一家多单逻辑
Result
<
String
>
deleteMultipleOrders
=
orderInfoService
.
deleteMultipleOrders
(
order
.
getMultipleOrders
(),
order
.
get
Address
Id
());
Result
<
String
>
deleteMultipleOrders
=
orderInfoService
.
deleteMultipleOrders
(
order
.
getMultipleOrders
(),
order
.
get
Order
Id
());
if
(!
deleteMultipleOrders
.
getCode
().
equals
(
ResultEnum
.
SUCCESS
.
getCode
()))
{
if
(!
deleteMultipleOrders
.
getCode
().
equals
(
ResultEnum
.
SUCCESS
.
getCode
()))
{
throw
new
BusinessException
(
"改约日期失败"
);
throw
new
BusinessException
(
"改约日期失败"
);
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderInfoServiceImpl.java
View file @
2c7ba0c
...
@@ -802,7 +802,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
...
@@ -802,7 +802,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
private
OrderInfoEntity
handleMultipleOrders
(
OrderInfoEntity
order
)
{
private
OrderInfoEntity
handleMultipleOrders
(
OrderInfoEntity
order
)
{
//处理一家多单逻辑
//处理一家多单逻辑
Result
<
String
>
deleteMultipleOrders
=
this
.
deleteMultipleOrders
(
order
.
getMultipleOrders
(),
order
.
get
Address
Id
());
Result
<
String
>
deleteMultipleOrders
=
this
.
deleteMultipleOrders
(
order
.
getMultipleOrders
(),
order
.
get
Order
Id
());
if
(!
deleteMultipleOrders
.
getCode
().
equals
(
ResultEnum
.
SUCCESS
.
getCode
()))
{
if
(!
deleteMultipleOrders
.
getCode
().
equals
(
ResultEnum
.
SUCCESS
.
getCode
()))
{
throw
new
BusinessException
(
"改约日期失败"
);
throw
new
BusinessException
(
"改约日期失败"
);
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/ScheduleServiceImpl.java
View file @
2c7ba0c
...
@@ -16,6 +16,7 @@ import com.dituhui.pea.order.entity.*;
...
@@ -16,6 +16,7 @@ import com.dituhui.pea.order.entity.*;
import
com.dituhui.pea.order.enums.OrderFlowEnum
;
import
com.dituhui.pea.order.enums.OrderFlowEnum
;
import
com.dituhui.pea.order.enums.VehicleEnum
;
import
com.dituhui.pea.order.enums.VehicleEnum
;
import
com.dituhui.pea.order.service.ScheduleService
;
import
com.dituhui.pea.order.service.ScheduleService
;
import
com.dituhui.pea.order.utils.CommonUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
...
@@ -128,10 +129,10 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -128,10 +129,10 @@ public class ScheduleServiceImpl implements ScheduleService {
List
<
ScheduleOverviewResp
.
Item
>
children
=
new
ArrayList
<>();
List
<
ScheduleOverviewResp
.
Item
>
children
=
new
ArrayList
<>();
Integer
teamDistance
=
0
;
Integer
teamDistance
=
0
;
Integer
minOrderSum
=
0
;
Integer
minOrderSum
=
0
;
Integer
maxOrderSum
=
0
;
Integer
maxOrderSum
=
0
;
Integer
minDistance
=
0
;
Integer
minDistance
=
0
;
Integer
maxDistance
=
0
;
Integer
maxDistance
=
0
;
for
(
Map
.
Entry
<
String
,
List
<
EngineerInfoEntity
>>
entry
:
engineers
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
EngineerInfoEntity
>>
entry
:
engineers
.
entrySet
())
{
ScheduleOverviewResp
.
Item
child
=
new
ScheduleOverviewResp
.
Item
();
ScheduleOverviewResp
.
Item
child
=
new
ScheduleOverviewResp
.
Item
();
...
@@ -149,31 +150,31 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -149,31 +150,31 @@ public class ScheduleServiceImpl implements ScheduleService {
child
.
setOrderDesc
(
Integer
.
toString
(
orders2
.
size
()));
child
.
setOrderDesc
(
Integer
.
toString
(
orders2
.
size
()));
Integer
distanceSum
=
orders2
.
stream
().
map
(
order
->
Objects
.
nonNull
(
order
.
getArriveDistance
())
?
order
.
getArriveDistance
()
:
0
).
reduce
(
Integer:
:
sum
).
orElse
(
0
);
Integer
distanceSum
=
orders2
.
stream
().
map
(
order
->
Objects
.
nonNull
(
order
.
getArriveDistance
())
?
order
.
getArriveDistance
()
:
0
).
reduce
(
Integer:
:
sum
).
orElse
(
0
);
teamDistance
+=
distanceSum
;
teamDistance
+=
distanceSum
;
child
.
setDistanceDesc
(
distanceSum
+
""
);
child
.
setDistanceDesc
(
CommonUtil
.
converMToKm
(
distanceSum
)
);
children
.
add
(
child
);
children
.
add
(
child
);
if
(
null
==
minOrderSum
||
null
==
maxOrderSum
)
{
if
(
null
==
minOrderSum
||
null
==
maxOrderSum
)
{
minOrderSum
=
child
.
getOrder
().
getTotal
();
minOrderSum
=
child
.
getOrder
().
getTotal
();
maxOrderSum
=
child
.
getOrder
().
getTotal
();
maxOrderSum
=
child
.
getOrder
().
getTotal
();
}
else
{
}
else
{
if
(
child
.
getOrder
().
getTotal
()<
minOrderSum
)
{
if
(
child
.
getOrder
().
getTotal
()
<
minOrderSum
)
{
minOrderSum
=
child
.
getOrder
().
getTotal
();
minOrderSum
=
child
.
getOrder
().
getTotal
();
}
}
if
(
child
.
getOrder
().
getTotal
()>
maxOrderSum
)
{
if
(
child
.
getOrder
().
getTotal
()
>
maxOrderSum
)
{
maxOrderSum
=
child
.
getOrder
().
getTotal
();
maxOrderSum
=
child
.
getOrder
().
getTotal
();
}
}
}
}
if
(
null
==
minDistance
||
null
==
maxDistance
)
{
if
(
null
==
minDistance
||
null
==
maxDistance
)
{
minDistance
=
distanceSum
;
minDistance
=
distanceSum
;
maxDistance
=
distanceSum
;
maxDistance
=
distanceSum
;
}
else
{
}
else
{
if
(
distanceSum
<
minDistance
)
{
if
(
distanceSum
<
minDistance
)
{
minDistance
=
distanceSum
;
minDistance
=
distanceSum
;
}
}
if
(
distanceSum
>
maxDistance
)
{
if
(
distanceSum
>
maxDistance
)
{
maxDistance
=
distanceSum
;
maxDistance
=
distanceSum
;
}
}
}
}
}
}
...
@@ -189,8 +190,8 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -189,8 +190,8 @@ public class ScheduleServiceImpl implements ScheduleService {
teamEngineers
.
size
()
>
0
?
new
BigDecimal
(
teamDistance
)
teamEngineers
.
size
()
>
0
?
new
BigDecimal
(
teamDistance
)
.
divide
(
new
BigDecimal
(
teamEngineers
.
size
()),
2
,
RoundingMode
.
HALF_UP
)
.
divide
(
new
BigDecimal
(
teamEngineers
.
size
()),
2
,
RoundingMode
.
HALF_UP
)
.
stripTrailingZeros
()
:
0
,
.
stripTrailingZeros
()
:
0
,
minDistance
,
CommonUtil
.
converMToKm
(
minDistance
)
,
maxDistance
));
CommonUtil
.
converMToKm
(
maxDistance
)
));
teams
.
add
(
team
);
teams
.
add
(
team
);
}
}
...
@@ -267,7 +268,7 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -267,7 +268,7 @@ public class ScheduleServiceImpl implements ScheduleService {
.
divide
(
new
BigDecimal
(
60
),
2
,
RoundingMode
.
HALF_UP
)
.
divide
(
new
BigDecimal
(
60
),
2
,
RoundingMode
.
HALF_UP
)
.
stripTrailingZeros
()
.
stripTrailingZeros
()
+
"时"
);
+
"时"
);
dynamics
.
setRoadTotalDistance
(
sumDistance
+
"公里"
);
dynamics
.
setRoadTotalDistance
(
CommonUtil
.
converMToKm
(
sumDistance
)
+
"公里"
);
if
(
Objects
.
nonNull
(
engineerBusinessEntity
))
{
if
(
Objects
.
nonNull
(
engineerBusinessEntity
))
{
dynamics
.
setWorkTime
(
engineerBusinessEntity
.
getWorkOn
()
+
"-"
+
engineerBusinessEntity
.
getWorkOff
());
dynamics
.
setWorkTime
(
engineerBusinessEntity
.
getWorkOn
()
+
"-"
+
engineerBusinessEntity
.
getWorkOff
());
}
else
{
}
else
{
...
@@ -289,7 +290,7 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -289,7 +290,7 @@ public class ScheduleServiceImpl implements ScheduleService {
item
.
setSkill
(
o
.
getSkill
());
item
.
setSkill
(
o
.
getSkill
());
item
.
setOrderStatus
(
o
.
getAppointmentStatus
());
item
.
setOrderStatus
(
o
.
getAppointmentStatus
());
item
.
setOrderStatusName
(
""
);
item
.
setOrderStatusName
(
""
);
item
.
setDistance
(
o
.
getArriveDistance
(
));
item
.
setDistance
(
CommonUtil
.
converMToKm
(
o
.
getArriveDistance
()
));
item
.
setTimeType
(
"auto"
);
item
.
setTimeType
(
"auto"
);
if
(
Objects
.
nonNull
(
o
.
getArriveElapsed
()))
{
if
(
Objects
.
nonNull
(
o
.
getArriveElapsed
()))
{
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/WorkbenchServiceImpl.java
View file @
2c7ba0c
...
@@ -11,6 +11,7 @@ import com.dituhui.pea.order.dto.OrderChangeListDTO;
...
@@ -11,6 +11,7 @@ import com.dituhui.pea.order.dto.OrderChangeListDTO;
import
com.dituhui.pea.order.dto.WorkbenchSummaryResp
;
import
com.dituhui.pea.order.dto.WorkbenchSummaryResp
;
import
com.dituhui.pea.order.entity.OrderEventEntity
;
import
com.dituhui.pea.order.entity.OrderEventEntity
;
import
com.dituhui.pea.order.entity.OrderInfoEntity
;
import
com.dituhui.pea.order.entity.OrderInfoEntity
;
import
com.dituhui.pea.order.enums.AppointmentMethodEnum
;
import
com.dituhui.pea.order.enums.OrderFlowEnum
;
import
com.dituhui.pea.order.enums.OrderFlowEnum
;
import
com.dituhui.pea.order.service.WorkbenchService
;
import
com.dituhui.pea.order.service.WorkbenchService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -79,16 +80,26 @@ public class WorkbenchServiceImpl implements WorkbenchService {
...
@@ -79,16 +80,26 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return
Result
.
success
(
rs
);
return
Result
.
success
(
rs
);
}
}
/**
* 工作台工单状态统计
*
* @param levelType
* @param levelValue
* @param dt
* @return
*/
@Override
@Override
public
Result
<?>
getWorkbenchSummary
(
String
levelType
,
String
levelValue
,
LocalDate
dt
)
{
public
Result
<?>
getWorkbenchSummary
(
String
levelType
,
String
levelValue
,
LocalDate
dt
)
{
List
<
WorkbenchSummaryResp
.
ItemDTO
>
items
=
new
ArrayList
<>();
List
<
WorkbenchSummaryResp
.
ItemDTO
>
items
=
new
ArrayList
<>();
//处理工单分配状态 待人工处理 待自动处理 全部订单
HashMap
<
String
,
Long
>
methodSummary
=
this
.
transAppointmentMethod
(
this
.
queryCountByAppointmentMethod
(
levelType
,
levelValue
,
dt
));
HashMap
<
String
,
Long
>
methodSummary
=
this
.
transAppointmentMethod
(
this
.
queryCountByAppointmentMethod
(
levelType
,
levelValue
,
dt
));
WorkbenchSummaryResp
.
ItemDTO
methodItem
=
new
WorkbenchSummaryResp
.
ItemDTO
();
WorkbenchSummaryResp
.
ItemDTO
methodItem
=
new
WorkbenchSummaryResp
.
ItemDTO
();
methodItem
.
setType
(
"order"
);
methodItem
.
setType
(
"order"
);
methodItem
.
setRows
(
this
.
packValueAppointmentMethod
(
methodSummary
));
methodItem
.
setRows
(
this
.
packValueAppointmentMethod
(
methodSummary
));
items
.
add
(
methodItem
);
items
.
add
(
methodItem
);
// 处理改约。取消。超时等状态
HashMap
<
String
,
Long
>
statusSummary
=
this
.
transOrderStatus
(
this
.
queryCountByOrderStatus
(
levelType
,
levelValue
,
dt
));
HashMap
<
String
,
Long
>
statusSummary
=
this
.
transOrderStatus
(
this
.
queryCountByOrderStatus
(
levelType
,
levelValue
,
dt
));
WorkbenchSummaryResp
.
ItemDTO
statusItem
=
new
WorkbenchSummaryResp
.
ItemDTO
();
WorkbenchSummaryResp
.
ItemDTO
statusItem
=
new
WorkbenchSummaryResp
.
ItemDTO
();
statusItem
.
setType
(
"order"
);
statusItem
.
setType
(
"order"
);
...
@@ -99,7 +110,7 @@ public class WorkbenchServiceImpl implements WorkbenchService {
...
@@ -99,7 +110,7 @@ public class WorkbenchServiceImpl implements WorkbenchService {
// - 已延误:已到开始时间,TARO没有反馈开始的工单.
// - 已延误:已到开始时间,TARO没有反馈开始的工单.
valueDTOS
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"已延误"
,
queryDelayNum
(
levelType
,
levelValue
,
dt
),
null
,
"#FF3D44"
,
""
,
new
HashMap
<>()));
valueDTOS
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"已延误"
,
queryDelayNum
(
levelType
,
levelValue
,
dt
),
null
,
"#FF3D44"
,
""
,
new
HashMap
<>()));
statusItem
.
setRows
(
valueDTOS
);
statusItem
.
setRows
(
valueDTOS
);
// - 已超时:已
到开始
时间,TARO没有反馈开始的工单.
// - 已超时:已
过预计结束
时间,TARO没有反馈开始的工单.
valueDTOS
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"已超时"
,
queryOvertimeNum
(
levelType
,
levelValue
,
dt
),
null
,
"#FF3D44"
,
""
,
new
HashMap
<>()));
valueDTOS
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"已超时"
,
queryOvertimeNum
(
levelType
,
levelValue
,
dt
),
null
,
"#FF3D44"
,
""
,
new
HashMap
<>()));
statusItem
.
setRows
(
valueDTOS
);
statusItem
.
setRows
(
valueDTOS
);
items
.
add
(
statusItem
);
items
.
add
(
statusItem
);
...
@@ -186,6 +197,14 @@ public class WorkbenchServiceImpl implements WorkbenchService {
...
@@ -186,6 +197,14 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return
rescheduledNum
;
return
rescheduledNum
;
}
}
/**
* 分组统计订单分配状态
*
* @param levelType
* @param levelValue
* @param dt
* @return
*/
private
List
<
Map
<
String
,
Object
>>
queryCountByAppointmentMethod
(
String
levelType
,
String
levelValue
,
LocalDate
dt
)
{
private
List
<
Map
<
String
,
Object
>>
queryCountByAppointmentMethod
(
String
levelType
,
String
levelValue
,
LocalDate
dt
)
{
CriteriaBuilder
criteriaBuilder
=
entityManager
.
getCriteriaBuilder
();
CriteriaBuilder
criteriaBuilder
=
entityManager
.
getCriteriaBuilder
();
CriteriaQuery
<
Object
[]>
criteriaQuery
=
criteriaBuilder
.
createQuery
(
Object
[].
class
);
CriteriaQuery
<
Object
[]>
criteriaQuery
=
criteriaBuilder
.
createQuery
(
Object
[].
class
);
...
@@ -278,6 +297,12 @@ public class WorkbenchServiceImpl implements WorkbenchService {
...
@@ -278,6 +297,12 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return
mappedResults
;
return
mappedResults
;
}
}
/**
* 组装分组数据
*
* @param results
* @return
*/
private
HashMap
<
String
,
Long
>
transAppointmentMethod
(
List
<
Map
<
String
,
Object
>>
results
)
{
private
HashMap
<
String
,
Long
>
transAppointmentMethod
(
List
<
Map
<
String
,
Object
>>
results
)
{
HashMap
<
String
,
Long
>
map
=
new
HashMap
<>();
HashMap
<
String
,
Long
>
map
=
new
HashMap
<>();
...
@@ -291,15 +316,15 @@ public class WorkbenchServiceImpl implements WorkbenchService {
...
@@ -291,15 +316,15 @@ public class WorkbenchServiceImpl implements WorkbenchService {
total
+=
count
;
total
+=
count
;
if
(
method
.
equals
(
"MANUAL"
))
{
if
(
method
.
equals
(
AppointmentMethodEnum
.
MANUAL
.
name
()
))
{
manualTotal
+=
count
;
manualTotal
+=
count
;
}
else
if
(
method
.
startsWith
(
"AUTO_"
))
{
}
else
if
(
method
.
startsWith
(
"AUTO_"
))
{
autoTotal
+=
count
;
autoTotal
+=
count
;
}
}
if
(
method
.
equals
(
"MANUAL"
)
&&
status
.
equals
(
"INIT"
))
{
if
(
method
.
equals
(
AppointmentMethodEnum
.
MANUAL
.
name
())
&&
status
.
equals
(
OrderFlowEnum
.
INIT
.
name
()
))
{
map
.
put
(
"manualDealing"
,
count
);
map
.
put
(
"manualDealing"
,
count
);
}
else
if
(
method
.
equals
(
"AUTO_"
)
&&
status
.
equals
(
"INIT"
))
{
}
else
if
(
method
.
startsWith
(
"AUTO_"
)
&&
status
.
equals
(
OrderFlowEnum
.
INIT
.
name
()
))
{
map
.
put
(
"autoDealing"
,
count
);
map
.
put
(
"autoDealing"
,
count
);
}
}
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/utils/CommonUtil.java
View file @
2c7ba0c
...
@@ -5,6 +5,7 @@ import com.dituhui.pea.util.DateUtil;
...
@@ -5,6 +5,7 @@ import com.dituhui.pea.util.DateUtil;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.LocalTime
;
...
@@ -112,6 +113,13 @@ public class CommonUtil {
...
@@ -112,6 +113,13 @@ public class CommonUtil {
}
}
}
}
public
static
String
converMToKm
(
Integer
m
)
{
if
(
Objects
.
isNull
(
m
))
{
return
null
;
}
return
BigDecimal
.
valueOf
(
m
/
1000.0
).
stripTrailingZeros
().
toString
();
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
isCutoff
(
LocalDateTime
.
now
(),
"18:00"
);
isCutoff
(
LocalDateTime
.
now
(),
"18:00"
);
}
}
...
...
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