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
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
98 additions
and
21 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
This diff is collapsed.
Click to expand it.
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