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 52e22438
authored
Jan 12, 2024
by
yangxiujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:优化下载上传中禁止再次上传
1 parent
ec227128
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
206 additions
and
202 deletions
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderCreateServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderCreateServiceImpl.java
View file @
52e2243
...
...
@@ -258,7 +258,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
@Override
@Transactional
public
void
saveBatch
(
List
<
OrderInfoExcelDTO
>
cachedDataList
,
String
token
,
ThreadLocal
local
)
{
public
void
saveBatch
(
List
<
OrderInfoExcelDTO
>
cachedDataList
,
String
token
,
ThreadLocal
local
)
{
String
key
=
redisGroup
+
token
;
ArrayList
<
OrderInfoErrorExcelDTO
>
errorList
=
(
ArrayList
<
OrderInfoErrorExcelDTO
>)
local
.
get
();
...
...
@@ -270,7 +270,8 @@ public class OrderCreateServiceImpl implements OrderCreateService {
if
(
cachedDataList
.
size
()
==
0
&&
errorList
.
size
()
==
0
)
{
throw
new
BusinessException
(
"模版数据不能为空"
);
}
if
(
redisService
.
get
(
key
)
!=
null
)
{
FileRateDTO
fileRateDTO1
=
JSONObject
.
parseObject
(
redisService
.
get
(
key
),
FileRateDTO
.
class
);
if
(
fileRateDTO1
.
getFlag
()
==
1
)
{
throw
new
BusinessException
(
"用户正在上传中,请稍后再试"
);
}
//创建保存的对象
...
...
@@ -282,218 +283,220 @@ public class OrderCreateServiceImpl implements OrderCreateService {
fileRateDTO
.
setTotalCount
(
cachedDataList
.
size
());
fileRateDTO
.
setErrorCount
(
errorExcelDTOS
.
size
());
if
(
errorExcelDTOS
.
size
()
>
0
){
if
(
errorExcelDTOS
.
size
()
>
0
)
{
fileRateDTO
.
setErrorExcelDTOList
(
errorExcelDTOS
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
}
}
fileRateDTO
.
setFlag
(
1
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
for
(
OrderInfoExcelDTO
req
:
cachedDataList
)
{
OrderInfoEntity
byOrderId
=
orderInfoDao
.
getByOrderId
(
req
.
getOrderId
());
String
peaBrand
=
req
.
getBrand
();
if
(
ObjectUtil
.
isNotNull
(
byOrderId
))
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
StatusCodeEnum
.
ORDER_EXISTS
.
getDesc
());
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
SkillInfoEntity
skillInfoEntity
=
skillInfoDao
.
getByBrandAndTypeAndSkill
(
peaBrand
,
req
.
getType
(),
req
.
getSkill
());
if
(
ObjectUtil
.
isNull
(
skillInfoEntity
))
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
StatusCodeEnum
.
ORDER_SKILL_NOT_EXISTS
.
getDesc
());
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
for
(
OrderInfoExcelDTO
req
:
cachedDataList
)
{
OrderInfoEntity
byOrderId
=
orderInfoDao
.
getByOrderId
(
req
.
getOrderId
());
String
peaBrand
=
req
.
getBrand
();
if
(
ObjectUtil
.
isNotNull
(
byOrderId
))
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
StatusCodeEnum
.
ORDER_EXISTS
.
getDesc
());
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
OrderInfoEntity
entity
=
new
OrderInfoEntity
();
entity
.
setExpectTimeBegin
(
DateUtil
.
fromDate
(
req
.
getExpectBegin
()));
entity
.
setExpectTimeEnd
(
DateUtil
.
fromDate
(
req
.
getExpectEnd
()));
entity
.
setAppointmentStatus
(
OrderFlowEnum
.
INIT
.
name
());
entity
.
setAppointmentMethod
(
AppointmentMethodEnum
.
AUTO_BATCH
.
name
());
entity
.
setDt
(
entity
.
getExpectTimeBegin
().
toLocalDate
());
entity
.
setOrderId
(
req
.
getOrderId
());
FendanDTO
fendanDTO
=
new
FendanDTO
();
fendanDTO
.
setAddress
(
req
.
getDetail
());
//获取地址的信息
SaasAddressResult
saasByAddresss
=
null
;
try
{
saasByAddresss
=
saasUtils
.
getSaasByAddresss
(
fendanDTO
);
}
catch
(
Exception
e
)
{
//上传成功,删除上传的进度条
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
"地址解析失败"
);
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
entity
.
setProvince
(
saasByAddresss
.
getProvince
());
entity
.
setCity
(
saasByAddresss
.
getCity
());
entity
.
setCounty
(
saasByAddresss
.
getCounty
());
// 处理技能和标签
entity
.
setTakeTime
(
skillInfoEntity
.
getTakeTime
());
String
joinTags
=
String
.
join
(
","
,
req
.
getOrderTags
());
entity
.
setBeanTags
(
joinTags
);
entity
.
setIsMultiple
(
joinTags
.
contains
(
"重物搬运"
)
?
1
:
0
);
entity
.
setBeanPriority
(
req
.
getBeanPriority
());
if
(
req
.
getBeanPriority
().
equals
(
"1"
))
{
if
(!
DateUtil
.
judgeTimeIsToday
(
entity
.
getExpectTimeBegin
()))
{
entity
.
setAppointmentMethod
(
AppointmentMethodEnum
.
AUTO_NOW
.
name
());
}
SkillInfoEntity
skillInfoEntity
=
skillInfoDao
.
getByBrandAndTypeAndSkill
(
peaBrand
,
req
.
getType
(),
req
.
getSkill
());
if
(
ObjectUtil
.
isNull
(
skillInfoEntity
))
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
StatusCodeEnum
.
ORDER_SKILL_NOT_EXISTS
.
getDesc
());
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
//一家多单
// Result<String> addMultipleOrders = orderInfoService
// .addMultipleOrders(entity.getDt(), saasByAddresss.getId(), req.getOrderId());
//entity.setMultipleOrders(addMultipleOrders.getResult());
entity
.
setMultipleOrders
(
null
);
//构建参数
OrderDTO
.
OrderCreateRequest
request
=
new
OrderDTO
.
OrderCreateRequest
();
request
.
setOrderId
(
req
.
getOrderId
());
request
.
setBrand
(
req
.
getBrand
());
request
.
setProductType
(
req
.
getType
());
request
.
setServiceType
(
req
.
getSkill
());
Location
location
=
new
Location
();
if
(
saasByAddresss
.
getX
()
==
null
||
saasByAddresss
.
getY
()
==
null
)
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
"地址解析失败"
);
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
location
.
setLongitude
(
saasByAddresss
.
getX
());
location
.
setLatitude
(
saasByAddresss
.
getY
());
location
.
setAddress
(
req
.
getAddress
());
location
.
setAddressId
(
saasByAddresss
.
getId
());
request
.
setLocation
(
location
);
}
OrderInfoEntity
entity
=
new
OrderInfoEntity
();
entity
.
setExpectTimeBegin
(
DateUtil
.
fromDate
(
req
.
getExpectBegin
()));
entity
.
setExpectTimeEnd
(
DateUtil
.
fromDate
(
req
.
getExpectEnd
()));
entity
.
setAppointmentStatus
(
OrderFlowEnum
.
INIT
.
name
());
entity
.
setAppointmentMethod
(
AppointmentMethodEnum
.
AUTO_BATCH
.
name
());
entity
.
setDt
(
entity
.
getExpectTimeBegin
().
toLocalDate
());
entity
.
setOrderId
(
req
.
getOrderId
());
FendanDTO
fendanDTO
=
new
FendanDTO
();
fendanDTO
.
setAddress
(
req
.
getDetail
());
//获取地址的信息
SaasAddressResult
saasByAddresss
=
null
;
try
{
saasByAddresss
=
saasUtils
.
getSaasByAddresss
(
fendanDTO
);
}
catch
(
Exception
e
)
{
//上传成功,删除上传的进度条
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
"地址解析失败"
);
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
entity
.
setProvince
(
saasByAddresss
.
getProvince
());
entity
.
setCity
(
saasByAddresss
.
getCity
());
entity
.
setCounty
(
saasByAddresss
.
getCounty
());
// 处理技能和标签
entity
.
setTakeTime
(
skillInfoEntity
.
getTakeTime
());
String
joinTags
=
String
.
join
(
","
,
req
.
getOrderTags
());
entity
.
setBeanTags
(
joinTags
);
entity
.
setIsMultiple
(
joinTags
.
contains
(
"重物搬运"
)
?
1
:
0
);
entity
.
setBeanPriority
(
req
.
getBeanPriority
());
if
(
req
.
getBeanPriority
().
equals
(
"1"
))
{
if
(!
DateUtil
.
judgeTimeIsToday
(
entity
.
getExpectTimeBegin
()))
{
entity
.
setAppointmentMethod
(
AppointmentMethodEnum
.
AUTO_NOW
.
name
());
}
}
//一家多单
// Result<String> addMultipleOrders = orderInfoService
// .addMultipleOrders(entity.getDt(), saasByAddresss.getId(), req.getOrderId());
//entity.setMultipleOrders(addMultipleOrders.getResult());
entity
.
setMultipleOrders
(
null
);
//构建参数
OrderDTO
.
OrderCreateRequest
request
=
new
OrderDTO
.
OrderCreateRequest
();
request
.
setOrderId
(
req
.
getOrderId
());
request
.
setBrand
(
req
.
getBrand
());
request
.
setProductType
(
req
.
getType
());
request
.
setServiceType
(
req
.
getSkill
());
Location
location
=
new
Location
();
if
(
saasByAddresss
.
getX
()
==
null
||
saasByAddresss
.
getY
()
==
null
)
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
"地址解析失败"
);
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
location
.
setLongitude
(
saasByAddresss
.
getX
());
location
.
setLatitude
(
saasByAddresss
.
getY
());
location
.
setAddress
(
req
.
getAddress
());
location
.
setAddressId
(
saasByAddresss
.
getId
());
request
.
setLocation
(
location
);
// 分单处理
Result
<
OrgTeamInfo
>
fendanResult
=
null
;
try
{
fendanResult
=
fendanService
.
fendanToGroupCapacity
(
request
,
2
,
entity
.
getExpectTimeBegin
().
toLocalDate
(),
entity
.
getExpectTimeBegin
().
toLocalTime
(),
entity
.
getExpectTimeEnd
().
toLocalTime
());
}
catch
(
Exception
e
)
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
"地址解析失败"
);
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
if
(
fendanResult
.
getCode
().
equals
(
StatusCodeEnum
.
ORDER_SKILL_NOT_EXISTS
.
getCode
()))
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
StatusCodeEnum
.
ORDER_SKILL_NOT_EXISTS
.
getCode
());
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
// 分单处理
Result
<
OrgTeamInfo
>
fendanResult
=
null
;
try
{
fendanResult
=
fendanService
.
fendanToGroupCapacity
(
request
,
2
,
entity
.
getExpectTimeBegin
().
toLocalDate
(),
entity
.
getExpectTimeBegin
().
toLocalTime
(),
entity
.
getExpectTimeEnd
().
toLocalTime
());
}
catch
(
Exception
e
)
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
"地址解析失败"
);
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
if
(
fendanResult
.
getCode
().
equals
(
StatusCodeEnum
.
ORDER_SKILL_NOT_EXISTS
.
getCode
()))
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
StatusCodeEnum
.
ORDER_SKILL_NOT_EXISTS
.
getCode
());
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
if
(!
fendanResult
.
getCode
().
equals
(
ResultEnum
.
SUCCESS
.
getCode
())
||
ObjectUtil
.
isNull
(
fendanResult
.
getResult
()))
{
if
(
fendanResult
.
getCode
().
equals
(
StatusCodeEnum
.
FENDAN_IS_TRANSCEND
.
getCode
()))
{
// 处理超派
entity
.
setTranscend
(
1
);
}
if
(!
fendanResult
.
getCode
().
equals
(
ResultEnum
.
SUCCESS
.
getCode
())
||
ObjectUtil
.
isNull
(
fendanResult
.
getResult
()))
{
if
(
fendanResult
.
getCode
().
equals
(
StatusCodeEnum
.
FENDAN_IS_TRANSCEND
.
getCode
()))
{
// 处理超派
entity
.
setTranscend
(
1
);
}
if
(
fendanResult
.
getCode
().
equals
(
StatusCodeEnum
.
FENDAN_IS_TRANSCEND_AND_SPECIAL
.
getCode
()))
{
// 处理超派和特殊时间
entity
.
setTranscend
(
1
);
entity
.
setIsSpecialTime
(
1
);
}
OrgBranchEntity
branchEntity
=
orgBranchDao
.
findByCitycodeListLike
(
"%"
+
saasByAddresss
.
getCity
()
+
"%"
);
if
(
branchEntity
!=
null
)
{
entity
.
setOrgClusterId
(
branchEntity
.
getClusterId
());
entity
.
setOrgBranchId
(
branchEntity
.
getBranchId
());
entity
.
setAppointmentMethod
(
AppointmentMethodEnum
.
MANUAL
.
name
());
if
(
fendanResult
.
getCode
().
equals
(
StatusCodeEnum
.
FENDAN_IS_TRANSCEND_AND_SPECIAL
.
getCode
()))
{
// 处理超派和特殊时间
entity
.
setTranscend
(
1
);
entity
.
setIsSpecialTime
(
1
);
}
OrgBranchEntity
branchEntity
=
orgBranchDao
.
findByCitycodeListLike
(
"%"
+
saasByAddresss
.
getCity
()
+
"%"
);
if
(
branchEntity
!=
null
)
{
entity
.
setOrgClusterId
(
branchEntity
.
getClusterId
());
entity
.
setOrgBranchId
(
branchEntity
.
getBranchId
());
entity
.
setAppointmentMethod
(
AppointmentMethodEnum
.
MANUAL
.
name
());
Integer
cutoff
=
CommonUtil
.
isCutoff
(
entity
.
getExpectTimeBegin
(),
null
);
entity
.
setIsCutoff
(
cutoff
);
//发送通知分部消息
sendMsg
(
branchEntity
.
getBranchId
(),
req
.
getOrderId
(),
entity
.
getExpectTimeBegin
().
toLocalDate
(),
entity
);
Integer
cutoff
=
CommonUtil
.
isCutoff
(
entity
.
getExpectTimeBegin
(),
null
);
entity
.
setIsCutoff
(
cutoff
);
//发送通知分部消息
sendMsg
(
branchEntity
.
getBranchId
(),
req
.
getOrderId
(),
entity
.
getExpectTimeBegin
().
toLocalDate
(),
entity
);
}
}
else
{
// 根据分单工作队,填写clusterId/branchId/groupId/teamId等
OrgTeamInfo
teamInfo
=
fendanResult
.
getResult
();
entity
.
setOrgClusterId
(
teamInfo
.
getClusterId
());
entity
.
setOrgBranchId
(
teamInfo
.
getBranchId
());
entity
.
setOrgGroupId
(
teamInfo
.
getGroupId
());
entity
.
setOrgTeamId
(
teamInfo
.
getTeamId
());
//特殊时间段
Integer
special
=
CommonUtil
.
isSpecial
(
entity
.
getExpectTimeBegin
().
toLocalTime
(),
entity
.
getExpectTimeEnd
().
toLocalTime
(),
teamInfo
.
getWorkOn
(),
teamInfo
.
getWorkOff
());
Integer
cutoff
=
CommonUtil
.
isCutoff
(
entity
.
getExpectTimeBegin
(),
teamInfo
.
getWorkOff
());
// 处理cutoff 动态排班结束后创建的当日单和次日单
boolean
isTomorrow
=
DateUtil
.
judgeTimeIsisTomorrow
(
entity
.
getExpectTimeBegin
());
//次日单自动批量
if
(
isTomorrow
)
{
entity
.
setAppointmentMethod
(
AppointmentMethodEnum
.
AUTO_BATCH
.
name
());
}
// 特殊时间段,当天单,cutoff需要人工处理
if
(
cutoff
==
1
||
special
==
1
)
{
//判断是否在今天cutoff之后
entity
.
setIsCutoff
(
cutoff
);
entity
.
setIsSpecialTime
(
special
);
entity
.
setAppointmentMethod
(
AppointmentMethodEnum
.
MANUAL
.
name
());
//发送通知分部消息
sendMsg
(
teamInfo
.
getBranchId
(),
req
.
getOrderId
(),
entity
.
getExpectTimeBegin
().
toLocalDate
(),
entity
);
}
}
// 字段转换
entity
.
setSource
(
req
.
getSource
());
entity
.
setName
(
req
.
getName
());
entity
.
setPhone
(
req
.
getPhone
());
entity
.
setBeanBrand
(
req
.
getBrand
());
entity
.
setBrand
(
peaBrand
);
entity
.
setType
(
req
.
getType
());
entity
.
setSkill
(
req
.
getSkill
());
entity
.
setFaultDescribe
(
req
.
getFaultDescribe
());
entity
.
setExpectTimeDesc
(
req
.
getExpectTimeDesc
());
// 使用期望时间来初始化计划时间,后面在指派环节更新为真正的有效的计划时间
entity
.
setPlanStartTime
(
entity
.
getExpectTimeBegin
());
entity
.
setPlanEndTime
(
entity
.
getExpectTimeEnd
());
// order_request的description字段,仅仅用于内部备注,不对外
entity
.
setApplyNote
(
req
.
getDescription
());
entity
.
setSubId
(
newSubId
(
entity
.
getOrderId
(),
entity
.
getDt
()));
entity
.
setX
(
location
.
getLongitude
().
toString
());
entity
.
setY
(
location
.
getLatitude
().
toString
());
entity
.
setAddress
(
location
.
getAddress
());
entity
.
setAddressId
(
location
.
getAddressId
());
// 默认值
// entity.setAppointmentStatus(OrderFlowEnum.INIT.name());
entity
.
setBeanStatus
(
"OPEN"
);
entity
.
setBeanSubStatus
(
""
);
entity
.
setWorkshop
(
false
);
// 记录订单和节点
orderInfoDao
.
save
(
entity
);
commonService
.
addOrderEvent
(
req
.
getOrderId
(),
""
,
req
.
getSource
(),
"API"
,
OrderEventEnum
.
createOrder
.
getEvent
(),
String
.
format
(
OrderEventEnum
.
createOrder
.
getMsg
(),
req
.
getSource
(),
"BEAN"
,
req
.
getOrderId
()),
""
);
successCount
++;
//每次上传成功更新上传进度条
fileRateDTO
.
setSuccessCount
((
fileRateDTO
.
getSuccessCount
()
==
null
?
0
:
fileRateDTO
.
getSuccessCount
())
+
1
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
}
if
(
fileRateDTO
.
getErrorCount
()>
0
){
throw
new
BusinessException
(
"订单上传失败,请检查错误模版"
);
}
else
{
// 根据分单工作队,填写clusterId/branchId/groupId/teamId等
OrgTeamInfo
teamInfo
=
fendanResult
.
getResult
();
entity
.
setOrgClusterId
(
teamInfo
.
getClusterId
());
entity
.
setOrgBranchId
(
teamInfo
.
getBranchId
());
entity
.
setOrgGroupId
(
teamInfo
.
getGroupId
());
entity
.
setOrgTeamId
(
teamInfo
.
getTeamId
());
//特殊时间段
Integer
special
=
CommonUtil
.
isSpecial
(
entity
.
getExpectTimeBegin
().
toLocalTime
(),
entity
.
getExpectTimeEnd
().
toLocalTime
(),
teamInfo
.
getWorkOn
(),
teamInfo
.
getWorkOff
());
Integer
cutoff
=
CommonUtil
.
isCutoff
(
entity
.
getExpectTimeBegin
(),
teamInfo
.
getWorkOff
());
// 处理cutoff 动态排班结束后创建的当日单和次日单
boolean
isTomorrow
=
DateUtil
.
judgeTimeIsisTomorrow
(
entity
.
getExpectTimeBegin
());
//次日单自动批量
if
(
isTomorrow
)
{
entity
.
setAppointmentMethod
(
AppointmentMethodEnum
.
AUTO_BATCH
.
name
());
}
// 特殊时间段,当天单,cutoff需要人工处理
if
(
cutoff
==
1
||
special
==
1
)
{
//判断是否在今天cutoff之后
entity
.
setIsCutoff
(
cutoff
);
entity
.
setIsSpecialTime
(
special
);
entity
.
setAppointmentMethod
(
AppointmentMethodEnum
.
MANUAL
.
name
());
//发送通知分部消息
sendMsg
(
teamInfo
.
getBranchId
(),
req
.
getOrderId
(),
entity
.
getExpectTimeBegin
().
toLocalDate
(),
entity
);
}
}
// 字段转换
entity
.
setSource
(
req
.
getSource
());
entity
.
setName
(
req
.
getName
());
entity
.
setPhone
(
req
.
getPhone
());
entity
.
setBeanBrand
(
req
.
getBrand
());
entity
.
setBrand
(
peaBrand
);
entity
.
setType
(
req
.
getType
());
entity
.
setSkill
(
req
.
getSkill
());
entity
.
setFaultDescribe
(
req
.
getFaultDescribe
());
entity
.
setExpectTimeDesc
(
req
.
getExpectTimeDesc
());
// 使用期望时间来初始化计划时间,后面在指派环节更新为真正的有效的计划时间
entity
.
setPlanStartTime
(
entity
.
getExpectTimeBegin
());
entity
.
setPlanEndTime
(
entity
.
getExpectTimeEnd
());
// order_request的description字段,仅仅用于内部备注,不对外
entity
.
setApplyNote
(
req
.
getDescription
());
entity
.
setSubId
(
newSubId
(
entity
.
getOrderId
(),
entity
.
getDt
()));
entity
.
setX
(
location
.
getLongitude
().
toString
());
entity
.
setY
(
location
.
getLatitude
().
toString
());
entity
.
setAddress
(
location
.
getAddress
());
entity
.
setAddressId
(
location
.
getAddressId
());
// 默认值
// entity.setAppointmentStatus(OrderFlowEnum.INIT.name());
entity
.
setBeanStatus
(
"OPEN"
);
entity
.
setBeanSubStatus
(
""
);
entity
.
setWorkshop
(
false
);
// 记录订单和节点
orderInfoDao
.
save
(
entity
);
commonService
.
addOrderEvent
(
req
.
getOrderId
(),
""
,
req
.
getSource
(),
"API"
,
OrderEventEnum
.
createOrder
.
getEvent
(),
String
.
format
(
OrderEventEnum
.
createOrder
.
getMsg
(),
req
.
getSource
(),
"BEAN"
,
req
.
getOrderId
()),
""
);
successCount
++;
//每次上传成功更新上传进度条
fileRateDTO
.
setSuccessCount
((
fileRateDTO
.
getSuccessCount
()
==
null
?
0
:
fileRateDTO
.
getSuccessCount
())
+
1
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
}
fileRateDTO
.
setFlag
(
0
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
if
(
fileRateDTO
.
getErrorCount
()
>
0
)
{
throw
new
BusinessException
(
"订单上传失败,请检查错误模版"
);
}
}
...
...
@@ -698,6 +701,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
log
.
info
(
"[createOrder] orderId:{}, 结束,订单信息:{}"
,
req
.
getOrderId
(),
entity
);
return
Result
.
success
(
null
);
}
@Async
public
void
sendMsg
(
String
branchId
,
String
orderId
,
LocalDate
toLocalDate
,
OrderInfoEntity
orderInfo
)
{
MsgDTO
msgDTO
=
new
MsgDTO
();
...
...
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