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 120e5df6
authored
Jan 11, 2024
by
yangxiujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:上传工单修改问题
1 parent
95b8f085
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
162 additions
and
90 deletions
project-interface/src/main/java/com/dituhui/pea/enums/RedisKeyGroup.java
project-order/src/main/java/com/dituhui/pea/order/common/ContractsListener.java
project-order/src/main/java/com/dituhui/pea/order/common/RedisService.java
project-order/src/main/java/com/dituhui/pea/order/controller/FileController.java
project-order/src/main/java/com/dituhui/pea/order/dto/FileRateDTO.java
project-order/src/main/java/com/dituhui/pea/order/dto/OrderInfoExcelDTO.java
project-order/src/main/java/com/dituhui/pea/order/service/OrderCreateService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/CommonServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderCreateServiceImpl.java
project-interface/src/main/java/com/dituhui/pea/enums/RedisKeyGroup.java
View file @
120e5df
...
...
@@ -19,6 +19,10 @@ public enum RedisKeyGroup {
* 资源信息
*/
resourceKey
,
/**
* 错误模版
*/
errorTemplate
,
/**
* 坐标距离信息
...
...
project-order/src/main/java/com/dituhui/pea/order/common/ContractsListener.java
View file @
120e5df
...
...
@@ -42,7 +42,7 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> {
*/
private
OrderCreateService
orderCreateService
;
private
ThreadLocal
local
=
new
ThreadLocal
();
private
HttpServletResponse
response
;
private
String
token
;
...
...
@@ -56,13 +56,10 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> {
*
* @param contractsService
*/
public
ContractsListener
(
OrderCreateService
contractsService
,
String
token
,
HttpServletResponse
response
)
{
public
ContractsListener
(
OrderCreateService
contractsService
,
String
token
)
{
this
.
orderCreateService
=
contractsService
;
this
.
token
=
token
;
this
.
response
=
response
;
}
...
...
@@ -147,6 +144,14 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> {
return
;
}
if
(
StringUtils
.
isBlank
(
data
.
getOrderTags
()))
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
BeanUtil
.
copyProperties
(
data
,
orderInfoError
);
orderInfoError
.
setError
(
"工单标签不能为空"
);
errorList
.
add
(
orderInfoError
);
return
;
}
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
if
(
StringUtils
.
isBlank
(
data
.
getExpectTimeBegin
()))
{
OrderInfoErrorExcelDTO
orderInfoError
=
new
OrderInfoErrorExcelDTO
();
...
...
@@ -212,7 +217,7 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> {
*/
private
void
saveData
()
{
log
.
info
(
"{}条数据,开始存储数据库!"
,
cachedDataList
.
size
());
orderCreateService
.
saveBatch
(
cachedDataList
,
token
,
local
,
response
);
orderCreateService
.
saveBatch
(
cachedDataList
,
token
,
local
);
log
.
info
(
"存储数据库成功!"
);
}
}
\ No newline at end of file
project-order/src/main/java/com/dituhui/pea/order/common/RedisService.java
View file @
120e5df
...
...
@@ -71,9 +71,7 @@ public class RedisService {
public
boolean
set
(
final
String
key
,
String
value
,
Long
expireTime
)
{
boolean
result
=
false
;
try
{
ValueOperations
<
String
,
String
>
operations
=
redisTemplate
.
opsForValue
();
operations
.
set
(
key
,
value
);
redisTemplate
.
expire
(
key
,
expireTime
,
TimeUnit
.
MILLISECONDS
);
redisTemplate
.
opsForValue
().
set
(
key
,
value
,
expireTime
,
TimeUnit
.
MINUTES
);
result
=
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"[set]---------->redis存值失败, key为: {}, 失败原因:{}"
,
key
,
e
.
getMessage
(),
e
);
...
...
@@ -94,4 +92,15 @@ public class RedisService {
return
result
;
}
/**
*删除缓存
*
* @param key
* @return
*/
public
void
del
(
final
String
key
)
{
redisTemplate
.
delete
(
key
);
}
}
project-order/src/main/java/com/dituhui/pea/order/controller/FileController.java
View file @
120e5df
...
...
@@ -82,7 +82,7 @@ public class FileController {
}
EasyExcel
.
read
(
file
.
getInputStream
(),
OrderInfoExcelDTO
.
class
,
new
ContractsListener
(
orderCreateService
,
token
,
response
)).
sheet
().
doRead
();
,
new
ContractsListener
(
orderCreateService
,
token
)).
sheet
().
doRead
();
long
l1
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"全部时间"
+(
l1
-
l
));
...
...
@@ -102,26 +102,54 @@ public class FileController {
if
(
StringUtils
.
isBlank
(
token
))
{
throw
new
BusinessException
(
"用户未登录"
);
}
FileRateDTO
rate
=
orderCreateService
.
getsuccessRate
(
token
);
if
(
rate
!=
null
&&
(
rate
.
getSuccessCount
()
==
rate
.
getTotalCount
()))
{
//上传成功,删除上传的进度条
orderCreateService
.
delRate
(
token
);
}
if
(
rate
!=
null
&&
(
rate
.
getTotalCount
()
==
rate
.
getErrorCount
()))
{
//上传成功,删除上传的进度条
orderCreateService
.
delRate
(
token
);
}
FileRateDTO
rate
=
orderCreateService
.
orderRate
(
token
);
if
(
rate
==
null
)
{
rate
=
new
FileRateDTO
();
rate
.
setRate
(
"100%"
);
return
Result
.
success
(
rate
);
}
rate
.
setErrorExcelDTOList
(
null
);
return
Result
.
success
(
rate
);
}
/**
* 错误模版下载
*
* @param request
* @return
* @throws IOException
*/
@GetMapping
(
"/file/errorTemplate"
)
public
void
errorTemplate
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
String
token
=
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
);
if
(
StringUtils
.
isBlank
(
token
))
{
throw
new
BusinessException
(
"用户未登录"
);
}
FileRateDTO
rate
=
orderCreateService
.
orderRate
(
token
);
try
{
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setCharacterEncoding
(
"utf-8"
);
String
fileName
=
URLEncoder
.
encode
(
"ORDER-ERROR-"
+
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
()),
"UTF-8"
).
replaceAll
(
"\\+"
,
"%20"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename*=utf-8''"
+
fileName
+
".xlsx"
);
orderCreateService
.
delRate
(
token
);
EasyExcel
.
write
(
response
.
getOutputStream
(),
OrderInfoErrorExcelDTO
.
class
)
.
registerWriteHandler
(
ExcelUtil
.
getDefaultWriteHandler
())
//注入原生 或 自定义转换器
.
registerConverter
(
new
DateStringConverter
())
.
registerConverter
(
new
BigDecimalStringConverter
())
.
sheet
(
"工单错误列表"
).
doWrite
(
rate
.
getErrorExcelDTOList
());
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
"工单错误列表下载异常"
);
}
}
/**
* 订单批量模版下载
*
* @param
...
...
project-order/src/main/java/com/dituhui/pea/order/dto/FileRateDTO.java
View file @
120e5df
...
...
@@ -2,6 +2,9 @@ package com.dituhui.pea.order.dto;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 文件上传列表比例查询
*/
...
...
@@ -23,4 +26,17 @@ public class FileRateDTO {
* 比列
*/
private
String
rate
;
private
List
<
OrderInfoErrorExcelDTO
>
errorExcelDTOList
;
/**
* 错误模版添加数据
* @param orderInfoErrorExcelDTO
*/
public
void
addErrorData
(
OrderInfoErrorExcelDTO
orderInfoErrorExcelDTO
)
{
if
(
errorExcelDTOList
==
null
){
errorExcelDTOList
=
new
ArrayList
<
OrderInfoErrorExcelDTO
>();
}
errorExcelDTOList
.
add
(
orderInfoErrorExcelDTO
);
}
}
project-order/src/main/java/com/dituhui/pea/order/dto/OrderInfoExcelDTO.java
View file @
120e5df
...
...
@@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import
javax.validation.constraints.NotBlank
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
@Data
@Builder
...
...
@@ -93,6 +94,13 @@ public class OrderInfoExcelDTO {
private
String
description
;
/**
* 服务单标签列表
*/
@ExcelProperty
(
value
=
"工单标签"
)
@ColumnWidth
(
value
=
20
)
private
String
orderTags
;
/**
* 省份
*/
@ExcelIgnore
...
...
project-order/src/main/java/com/dituhui/pea/order/service/OrderCreateService.java
View file @
120e5df
...
...
@@ -18,6 +18,7 @@ package com.dituhui.pea.order.service;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.FileRateDTO
;
import
com.dituhui.pea.order.dto.OrderInfoExcelDTO
;
import
com.dituhui.pea.order.dto.param.OrderDTO
;
...
...
@@ -40,6 +41,9 @@ public interface OrderCreateService {
*/
OrderDTO
.
StageResult
orderStage
(
String
orderId
);
void
saveBatch
(
List
<
OrderInfoExcelDTO
>
cachedDataList
,
String
token
,
ThreadLocal
local
,
HttpServletResponse
response
);
void
saveBatch
(
List
<
OrderInfoExcelDTO
>
cachedDataList
,
String
token
,
ThreadLocal
local
);
FileRateDTO
orderRate
(
String
token
);
void
delRate
(
String
token
);
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/CommonServiceImpl.java
View file @
120e5df
...
...
@@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.*
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
...
...
@@ -37,6 +38,7 @@ public class CommonServiceImpl implements CommonService {
private
PubParamsDao
pubParamsDao
;
@Async
public
OrderEventEntity
addOrderEvent
(
String
orderId
,
String
subOrderId
,
String
source
,
String
operator
,
String
event
,
String
content
,
String
memo
)
{
OrderEventEntity
entity
=
new
OrderEventEntity
();
if
(
StringUtils
.
isBlank
(
source
))
{
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderCreateServiceImpl.java
View file @
120e5df
...
...
@@ -25,13 +25,8 @@ import com.alibaba.fastjson.JSONObject;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.ResultEnum
;
import
com.dituhui.pea.enums.StatusCodeEnum
;
import
com.dituhui.pea.order.common.CapacityUtils
;
import
com.dituhui.pea.order.common.DateUtils
;
import
com.dituhui.pea.order.common.EngineerUtils
;
import
com.dituhui.pea.order.common.OrderAssignCheck
;
import
com.dituhui.pea.order.common.SaasUtils
;
import
com.dituhui.pea.order.common.Stapial4jUtil
;
import
com.dituhui.pea.enums.*
;
import
com.dituhui.pea.order.common.*
;
import
com.dituhui.pea.order.dao.EngineerBusinessDao
;
import
com.dituhui.pea.order.dao.EngineerInfoDao
;
import
com.dituhui.pea.order.dao.EngineerSkillDao
;
...
...
@@ -46,9 +41,6 @@ import com.dituhui.pea.order.dto.param.Location;
import
com.dituhui.pea.order.dto.param.OrderDTO
;
import
com.dituhui.pea.order.dto.param.OrgTeamInfo
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.enums.AppointmentMethodEnum
;
import
com.dituhui.pea.enums.OrderEventEnum
;
import
com.dituhui.pea.enums.OrderFlowEnum
;
import
com.dituhui.pea.order.service.CommonService
;
import
com.dituhui.pea.order.service.FendanService
;
import
com.dituhui.pea.order.service.MsgService
;
...
...
@@ -66,6 +58,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -130,17 +123,11 @@ public class OrderCreateServiceImpl implements OrderCreateService {
@Autowired
private
OrderInfoService
orderInfoService
;
@Autowired
private
RedisService
redisService
;
private
static
volatile
HashMap
<
String
,
FileRateDTO
>
tokenCount
=
new
HashMap
();
public
static
FileRateDTO
getsuccessRate
(
String
token
)
{
return
tokenCount
.
get
(
token
);
}
private
final
String
redisGroup
=
RedisKeyGroup
.
errorTemplate
+
":order:"
;
public
static
void
delRate
(
String
token
)
{
//上传成功,删除上传的进度条
tokenCount
.
remove
(
token
);
}
private
List
<
LabelValueDTO
>
getPriorities
()
{
String
[]
priorities
=
{
"紧急"
,
"正常"
};
...
...
@@ -271,23 +258,27 @@ public class OrderCreateServiceImpl implements OrderCreateService {
@Override
@Transactional
public
void
saveBatch
(
List
<
OrderInfoExcelDTO
>
cachedDataList
,
String
token
,
ThreadLocal
local
,
HttpServletResponse
response
)
{
FileRateDTO
fileRateDTO
=
new
FileRateDTO
();
public
void
saveBatch
(
List
<
OrderInfoExcelDTO
>
cachedDataList
,
String
token
,
ThreadLocal
local
)
{
String
key
=
redisGroup
+
token
;
ArrayList
<
OrderInfoErrorExcelDTO
>
errorList
=
(
ArrayList
<
OrderInfoErrorExcelDTO
>)
local
.
get
();
if
(
errorList
==
null
)
{
errorList
=
new
ArrayList
<
OrderInfoErrorExcelDTO
>();
if
(
errorList
==
null
)
{
errorList
=
new
ArrayList
<
OrderInfoErrorExcelDTO
>();
local
.
set
(
errorList
);
}
Integer
successCount
=
0
;
if
(
cachedDataList
.
size
()
==
0
&&
errorList
.
size
()
==
0
)
{
throw
new
BusinessException
(
"模版数据不能为空"
);
}
if
(
tokenCount
.
get
(
token
)
!=
null
)
{
if
(
redisService
.
get
(
key
)
!=
null
)
{
throw
new
BusinessException
(
"用户正在上传中,请稍后再试"
);
}
//创建保存的对象
FileRateDTO
fileRateDTO
=
new
FileRateDTO
();
ArrayList
<
OrderInfoErrorExcelDTO
>
errorExcelDTOS
=
new
ArrayList
<>();
fileRateDTO
.
setTotalCount
(
cachedDataList
.
size
());
tokenCount
.
put
(
token
,
fileRateDTO
);
try
{
for
(
OrderInfoExcelDTO
req
:
cachedDataList
)
{
OrderInfoEntity
byOrderId
=
orderInfoDao
.
getByOrderId
(
req
.
getOrderId
());
String
peaBrand
=
req
.
getBrand
();
...
...
@@ -296,8 +287,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
StatusCodeEnum
.
ORDER_EXISTS
.
getDesc
());
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
()
)+
1
);
tokenCount
.
put
(
token
,
fileRateDTO
);
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
());
...
...
@@ -306,8 +298,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
StatusCodeEnum
.
ORDER_SKILL_NOT_EXISTS
.
getDesc
());
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
()
)+
1
);
tokenCount
.
put
(
token
,
fileRateDTO
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
...
...
@@ -327,8 +320,14 @@ public class OrderCreateServiceImpl implements OrderCreateService {
saasByAddresss
=
saasUtils
.
getSaasByAddresss
(
fendanDTO
);
}
catch
(
Exception
e
)
{
//上传成功,删除上传的进度条
tokenCount
.
remove
(
token
);
throw
new
BusinessException
(
e
.
getMessage
());
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
());
...
...
@@ -336,7 +335,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
// 处理技能和标签
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
()))
{
...
...
@@ -358,8 +359,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
"地址解析失败"
);
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
()
)+
1
);
tokenCount
.
put
(
token
,
fileRateDTO
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
location
.
setLongitude
(
saasByAddresss
.
getX
());
...
...
@@ -377,8 +379,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
"地址解析失败"
);
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
()
)+
1
);
tokenCount
.
put
(
token
,
fileRateDTO
);
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
()))
{
...
...
@@ -386,8 +389,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
BeanUtil
.
copyProperties
(
req
,
orderInfoError
);
orderInfoError
.
setError
(
StatusCodeEnum
.
ORDER_SKILL_NOT_EXISTS
.
getCode
());
errorList
.
add
(
orderInfoError
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
()
)+
1
);
tokenCount
.
put
(
token
,
fileRateDTO
);
fileRateDTO
.
setErrorCount
((
fileRateDTO
.
getErrorCount
()
==
null
?
0
:
fileRateDTO
.
getErrorCount
())
+
1
);
fileRateDTO
.
addErrorData
(
orderInfoError
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
continue
;
}
...
...
@@ -471,43 +475,33 @@ public class OrderCreateServiceImpl implements OrderCreateService {
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
);
tokenCount
.
put
(
token
,
fileRateDTO
);
fileRateDTO
.
setSuccessCount
((
fileRateDTO
.
getSuccessCount
()
==
null
?
0
:
fileRateDTO
.
getSuccessCount
())
+
1
);
redisService
.
set
(
key
,
JSONObject
.
toJSONString
(
fileRateDTO
),
60L
);
}
}
catch
(
Exception
e
)
{
tokenCount
.
remove
(
token
);
throw
new
BusinessException
(
"订单上传异常"
);
if
(
fileRateDTO
.
getErrorCount
()>
0
){
throw
new
BusinessException
(
"订单上传失败,请检查错误模版"
);
}
if
(
errorList
.
size
()
>
0
)
{
if
(
errorList
!=
null
&&
errorList
.
size
()
>
0
)
{
try
{
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setCharacterEncoding
(
"utf-8"
);
String
fileName
=
URLEncoder
.
encode
(
"ORDER-ERROR-"
+
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
()),
"UTF-8"
).
replaceAll
(
"\\+"
,
"%20"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename*=utf-8''"
+
fileName
+
".xlsx"
);
EasyExcel
.
write
(
response
.
getOutputStream
(),
OrderInfoErrorExcelDTO
.
class
)
.
registerWriteHandler
(
ExcelUtil
.
getDefaultWriteHandler
())
//注入原生 或 自定义转换器
.
registerConverter
(
new
DateStringConverter
())
.
registerConverter
(
new
BigDecimalStringConverter
())
.
sheet
(
"工单错误列表"
).
doWrite
(
errorList
);
}
catch
(
Exception
e
)
{
local
.
remove
();
throw
new
BusinessException
(
"工单错误列表下载异常:"
+
e
.
getMessage
());
}
}
local
.
remove
();
throw
new
BusinessException
(
"订单上传异常"
);
/**
* 查询上传进度
*
* @param token
* @return
*/
@Override
public
FileRateDTO
orderRate
(
String
token
)
{
String
s
=
redisService
.
get
(
redisGroup
+
token
);
return
JSONObject
.
parseObject
(
s
,
FileRateDTO
.
class
);
}
@Override
public
void
delRate
(
String
token
)
{
redisService
.
del
(
redisGroup
+
token
);
}
@Override
...
...
@@ -693,8 +687,8 @@ public class OrderCreateServiceImpl implements OrderCreateService {
log
.
info
(
"[createOrder] orderId:{}, 结束,订单信息:{}"
,
req
.
getOrderId
(),
entity
);
return
Result
.
success
(
null
);
}
p
rivate
void
sendMsg
(
String
branchId
,
String
orderId
,
LocalDate
toLocalDate
,
OrderInfoEntity
orderInfo
)
{
@Async
p
ublic
void
sendMsg
(
String
branchId
,
String
orderId
,
LocalDate
toLocalDate
,
OrderInfoEntity
orderInfo
)
{
MsgDTO
msgDTO
=
new
MsgDTO
();
msgDTO
.
setBranchId
(
branchId
);
msgDTO
.
setType
(
0
);
...
...
@@ -766,4 +760,5 @@ public class OrderCreateServiceImpl implements OrderCreateService {
return
String
.
format
(
"%s_%s"
,
orderId
,
DateUtils
.
formatDateTime
(
LocalDateTime
.
now
(),
"MMdd"
));
}
}
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