Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
李苗
/
Vion-DevOps
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2e88b2e6
authored
Jan 19, 2024
by
HlQ
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[chg] 优化发货记录更新和工单列表代码
1 parent
ef11ee50
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
93 deletions
src/main/java/vion/service/impl/DeliveryRecordServiceImpl.java
src/main/java/vion/service/impl/TaskServiceImpl.java
src/main/java/vion/service/impl/DeliveryRecordServiceImpl.java
View file @
2e88b2e
...
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
...
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.ObjUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
...
@@ -14,6 +15,7 @@ import com.github.yulichang.base.MPJBaseServiceImpl;
...
@@ -14,6 +15,7 @@ import com.github.yulichang.base.MPJBaseServiceImpl;
import
com.github.yulichang.wrapper.MPJLambdaWrapper
;
import
com.github.yulichang.wrapper.MPJLambdaWrapper
;
import
io.github.linpeilie.Converter
;
import
io.github.linpeilie.Converter
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -38,6 +40,7 @@ import java.util.stream.Collectors;
...
@@ -38,6 +40,7 @@ import java.util.stream.Collectors;
* @date 2023/12/5
* @date 2023/12/5
*/
*/
@Service
@Service
@Slf4j
@RequiredArgsConstructor
@RequiredArgsConstructor
public
class
DeliveryRecordServiceImpl
extends
MPJBaseServiceImpl
<
DeliveryRecordMapper
,
DeliveryRecord
>
implements
IDeliveryRecordService
{
public
class
DeliveryRecordServiceImpl
extends
MPJBaseServiceImpl
<
DeliveryRecordMapper
,
DeliveryRecord
>
implements
IDeliveryRecordService
{
...
@@ -76,40 +79,10 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
...
@@ -76,40 +79,10 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
@Override
@Override
public
String
save
(
DeliveryRecordDTO
dto
)
{
public
String
save
(
DeliveryRecordDTO
dto
)
{
DeliveryRecord
record
=
converter
.
convert
(
dto
,
DeliveryRecord
.
class
);
DeliveryRecord
deliveryRecord
=
converter
.
convert
(
dto
,
DeliveryRecord
.
class
);
if
(
this
.
save
(
record
))
{
if
(
this
.
save
(
deliveryRecord
))
{
updStatusAndPushMsg
(
record
);
updStatusAndPushMsg
(
deliveryRecord
);
saveFile
(
dto
,
deliveryRecord
);
Opt
.
ofNullable
(
dto
.
getFiles
())
.
ifPresent
(
fileList
->
{
UserVO
userVO
=
(
UserVO
)
StpUtil
.
getTokenSession
().
get
(
"curLoginUser"
);
Arrays
.
stream
(
fileList
).
forEach
(
infile
->
{
String
orgName
=
infile
.
getOriginalFilename
();
String
mainName
=
FileUtil
.
mainName
(
orgName
);
String
fileExt
=
FileUtil
.
extName
(
orgName
);
String
filename
=
StrUtil
.
format
(
"{}_{}.{}"
,
mainName
,
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd_HHmmss"
),
fileExt
);
String
path
=
fileUrl
+
FileUtil
.
FILE_SEPARATOR
+
"delivery"
+
FileUtil
.
FILE_SEPARATOR
+
dto
.
getContractId
()
+
FileUtil
.
FILE_SEPARATOR
+
record
.
getId
()
+
FileUtil
.
FILE_SEPARATOR
+
filename
;
File
file
=
FileUtil
.
touch
(
path
);
try
{
infile
.
transferTo
(
file
);
}
catch
(
IOException
e
)
{
log
.
error
(
"保存文件出错"
,
e
);
}
FileInfo
fileInfo
=
new
FileInfo
();
fileInfo
.
setStoreId
(
0L
);
fileInfo
.
setSourceId
(
record
.
getId
());
fileInfo
.
setContractId
(
dto
.
getContractId
());
fileInfo
.
setSourceType
(
6
);
fileInfo
.
setName
(
filename
);
fileInfo
.
setUrl
(
path
);
fileInfo
.
setType
(
FileUtil
.
extName
(
file
));
fileInfo
.
setSha256
(
SecureUtil
.
sha256
(
file
).
toUpperCase
());
fileInfo
.
setUploader
(
userVO
.
getUsername
());
fileService
.
save
(
fileInfo
);
});
});
return
"新增成功"
;
return
"新增成功"
;
}
else
{
}
else
{
return
"新增失败"
;
return
"新增失败"
;
...
@@ -127,10 +100,30 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
...
@@ -127,10 +100,30 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
}
}
}
}
@Override
public
String
updateById
(
DeliveryRecordDTO
dto
)
{
DeliveryRecord
record
=
converter
.
convert
(
dto
,
DeliveryRecord
.
class
);
if
(
this
.
updateById
(
record
))
{
DeliveryRecord
deliveryRecord
=
this
.
getById
(
dto
.
getId
());
saveFile
(
dto
,
deliveryRecord
);
return
"更新成功"
;
}
else
{
return
"更新失败"
;
}
}
/**
* 更新合同状态和点位设计记录状态,并推送发货消息提醒
*
* @param record 发货记录
*/
private
void
updStatusAndPushMsg
(
DeliveryRecord
record
)
{
private
void
updStatusAndPushMsg
(
DeliveryRecord
record
)
{
ContractDTO
contractDTO
=
new
ContractDTO
();
ContractDTO
contractDTO
=
new
ContractDTO
();
contractDTO
.
setStatus
(
2
);
contractDTO
.
setStatus
(
2
);
Contract
existContract
=
contractService
.
lambdaQuery
().
eq
(
Contract:
:
getContractNo
,
record
.
getContractNo
()).
one
();
Contract
existContract
=
contractService
.
lambdaQuery
().
eq
(
Contract:
:
getContractNo
,
record
.
getContractNo
()).
one
();
if
(
ObjUtil
.
isNull
(
existContract
)
||
ObjUtil
.
isNull
(
existContract
.
getStatus
()))
{
log
.
error
(
"根据发货记录,更新合同状态出错,该合同不存在:{}"
,
record
.
getContractNo
());
}
if
(
existContract
.
getStatus
()
<
2
)
{
if
(
existContract
.
getStatus
()
<
2
)
{
contractService
.
updateById
(
null
,
record
.
getContractNo
(),
contractDTO
);
contractService
.
updateById
(
null
,
record
.
getContractNo
(),
contractDTO
);
}
}
...
@@ -176,44 +169,36 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
...
@@ -176,44 +169,36 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
return
jsonObj
;
return
jsonObj
;
}
}
@Override
private
void
saveFile
(
DeliveryRecordDTO
dto
,
DeliveryRecord
deliveryRecord
)
{
public
String
updateById
(
DeliveryRecordDTO
dto
)
{
Opt
.
ofNullable
(
dto
.
getFiles
())
DeliveryRecord
record
=
converter
.
convert
(
dto
,
DeliveryRecord
.
class
);
.
ifPresent
(
fileList
->
{
if
(
this
.
updateById
(
record
))
{
UserVO
userVO
=
(
UserVO
)
StpUtil
.
getTokenSession
().
get
(
"curLoginUser"
);
DeliveryRecord
deliveryRecord
=
this
.
getById
(
dto
.
getId
());
Opt
.
ofNullable
(
dto
.
getFiles
())
Arrays
.
stream
(
fileList
).
forEach
(
infile
->
{
.
ifPresent
(
fileList
->
{
String
orgName
=
infile
.
getOriginalFilename
();
UserVO
userVO
=
(
UserVO
)
StpUtil
.
getTokenSession
().
get
(
"curLoginUser"
);
String
mainName
=
FileUtil
.
mainName
(
orgName
);
String
fileExt
=
FileUtil
.
extName
(
orgName
);
Arrays
.
stream
(
fileList
).
forEach
(
infile
->
{
String
filename
=
StrUtil
.
format
(
"{}_{}.{}"
,
mainName
,
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd_HHmmss"
),
fileExt
);
String
orgName
=
infile
.
getOriginalFilename
();
String
path
=
fileUrl
+
FileUtil
.
FILE_SEPARATOR
+
"delivery"
+
FileUtil
.
FILE_SEPARATOR
+
deliveryRecord
.
getContractId
()
+
FileUtil
.
FILE_SEPARATOR
+
deliveryRecord
.
getId
()
+
FileUtil
.
FILE_SEPARATOR
+
filename
;
String
mainName
=
FileUtil
.
mainName
(
orgName
);
File
file
=
FileUtil
.
touch
(
path
);
String
fileExt
=
FileUtil
.
extName
(
orgName
);
try
{
String
filename
=
StrUtil
.
format
(
"{}_{}.{}"
,
mainName
,
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd_HHmmss"
),
fileExt
);
infile
.
transferTo
(
file
);
String
path
=
fileUrl
+
FileUtil
.
FILE_SEPARATOR
+
"delivery"
+
FileUtil
.
FILE_SEPARATOR
+
deliveryRecord
.
getContractId
()
+
FileUtil
.
FILE_SEPARATOR
+
record
.
getId
()
+
FileUtil
.
FILE_SEPARATOR
+
filename
;
}
catch
(
IOException
e
)
{
File
file
=
FileUtil
.
touch
(
path
);
log
.
error
(
"保存文件出错"
,
e
);
try
{
}
infile
.
transferTo
(
file
);
}
catch
(
IOException
e
)
{
FileInfo
fileInfo
=
new
FileInfo
();
log
.
error
(
"保存文件出错"
,
e
);
fileInfo
.
setStoreId
(
0L
);
}
fileInfo
.
setSourceId
(
deliveryRecord
.
getId
());
fileInfo
.
setContractId
(
deliveryRecord
.
getContractId
());
FileInfo
fileInfo
=
new
FileInfo
();
fileInfo
.
setSourceType
(
6
);
fileInfo
.
setStoreId
(
0L
);
fileInfo
.
setName
(
filename
);
fileInfo
.
setSourceId
(
record
.
getId
());
fileInfo
.
setUrl
(
path
);
fileInfo
.
setContractId
(
deliveryRecord
.
getContractId
());
fileInfo
.
setType
(
FileUtil
.
extName
(
file
));
fileInfo
.
setSourceType
(
6
);
fileInfo
.
setSha256
(
SecureUtil
.
sha256
(
file
).
toUpperCase
());
fileInfo
.
setName
(
filename
);
fileInfo
.
setUploader
(
userVO
.
getUsername
());
fileInfo
.
setUrl
(
path
);
fileService
.
save
(
fileInfo
);
fileInfo
.
setType
(
FileUtil
.
extName
(
file
));
fileInfo
.
setSha256
(
SecureUtil
.
sha256
(
file
).
toUpperCase
());
fileInfo
.
setUploader
(
userVO
.
getUsername
());
fileService
.
save
(
fileInfo
);
});
});
});
return
"更新成功"
;
});
}
else
{
return
"更新失败"
;
}
}
}
}
}
src/main/java/vion/service/impl/TaskServiceImpl.java
View file @
2e88b2e
...
@@ -58,6 +58,36 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -58,6 +58,36 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
@Override
@Override
public
Page
<
TaskVO
>
getTaskList
(
TaskDTO
data
)
{
public
Page
<
TaskVO
>
getTaskList
(
TaskDTO
data
)
{
UserVO
userVO
=
(
UserVO
)
StpUtil
.
getTokenSession
().
get
(
"curLoginUser"
);
UserVO
userVO
=
(
UserVO
)
StpUtil
.
getTokenSession
().
get
(
"curLoginUser"
);
Set
<
Long
>
taskIdSet
=
getTaskIdSet
(
userVO
);
MPJLambdaWrapper
<
Task
>
wrapper
=
new
MPJLambdaWrapper
<>(
converter
.
convert
(
data
,
Task
.
class
))
.
selectAll
(
Task
.
class
)
.
selectAs
(
Store:
:
getName
,
TaskVO:
:
getStoreName
)
.
selectAs
(
Account:
:
getName
,
TaskVO:
:
getAccountName
)
.
selectAssociation
(
ServiceOrder
.
class
,
TaskVO:
:
getServiceOrder
)
.
leftJoin
(
Store
.
class
,
Store:
:
getId
,
Task:
:
getStoreId
)
.
leftJoin
(
Account
.
class
,
Account:
:
getId
,
Task:
:
getAccountId
)
.
leftJoin
(
ServiceOrder
.
class
,
ServiceOrder:
:
getTaskId
,
Task:
:
getId
)
.
between
(
ArrayUtil
.
isAllNotNull
(
data
.
getStartdate
(),
data
.
getEnddate
()),
Task:
:
getRepairTime
,
data
.
getStartdate
(),
data
.
getEnddate
())
.
lt
(
data
.
getCurDate
()
!=
null
,
Task:
:
getExpDate
,
data
.
getCurDate
());
// todo 优化
if
(
taskIdSet
.
size
()
==
1
&&
CollUtil
.
get
(
taskIdSet
,
0
).
equals
(-
99L
))
{
// 不是管理员,并且第一次处理工单,但当前处理人是他
}
else
if
(
taskIdSet
.
size
()
==
1
&&
CollUtil
.
get
(
taskIdSet
,
0
).
equals
(
0L
))
{
// 管理员逻辑
}
else
{
wrapper
.
in
(
Task:
:
getId
,
taskIdSet
);
}
return
this
.
selectJoinListPage
(
Page
.
of
(
data
.
getPageNum
(),
data
.
getPageSize
()),
TaskVO
.
class
,
wrapper
);
}
/**
* 根据当前登录用户,判断其权限和其参与过的工单,获取工单id集合
*
* @param userVO 当前登录用户
* @return java.util.Set<java.lang.Long>
*/
private
Set
<
Long
>
getTaskIdSet
(
UserVO
userVO
)
{
Set
<
Long
>
taskIdSet
=
CollUtil
.
newHashSet
();
Set
<
Long
>
taskIdSet
=
CollUtil
.
newHashSet
();
Opt
.
ofEmptyAble
(
userVO
.
getRoleVOList
())
Opt
.
ofEmptyAble
(
userVO
.
getRoleVOList
())
.
map
(
l
->
l
.
stream
().
map
(
RoleVO:
:
getCode
).
collect
(
Collectors
.
toList
()))
.
map
(
l
->
l
.
stream
().
map
(
RoleVO:
:
getCode
).
collect
(
Collectors
.
toList
()))
...
@@ -85,26 +115,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -85,26 +115,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
}
}
})
})
.
ifPresent
(
logs
->
taskIdSet
.
addAll
(
logs
.
stream
().
map
(
FaultLog:
:
getTaskId
).
collect
(
Collectors
.
toSet
())));
.
ifPresent
(
logs
->
taskIdSet
.
addAll
(
logs
.
stream
().
map
(
FaultLog:
:
getTaskId
).
collect
(
Collectors
.
toSet
())));
return
taskIdSet
;
MPJLambdaWrapper
<
Task
>
wrapper
=
new
MPJLambdaWrapper
<>(
converter
.
convert
(
data
,
Task
.
class
))
.
selectAll
(
Task
.
class
)
.
selectAs
(
Store:
:
getName
,
TaskVO:
:
getStoreName
)
.
selectAs
(
Account:
:
getName
,
TaskVO:
:
getAccountName
)
.
selectAssociation
(
ServiceOrder
.
class
,
TaskVO:
:
getServiceOrder
)
.
leftJoin
(
Store
.
class
,
Store:
:
getId
,
Task:
:
getStoreId
)
.
leftJoin
(
Account
.
class
,
Account:
:
getId
,
Task:
:
getAccountId
)
.
leftJoin
(
ServiceOrder
.
class
,
ServiceOrder:
:
getTaskId
,
Task:
:
getId
)
.
between
(
ArrayUtil
.
isAllNotNull
(
data
.
getStartdate
(),
data
.
getEnddate
()),
Task:
:
getRepairTime
,
data
.
getStartdate
(),
data
.
getEnddate
())
.
lt
(
data
.
getCurDate
()
!=
null
,
Task:
:
getExpDate
,
data
.
getCurDate
());
// todo 优化
if
(
taskIdSet
.
size
()
==
1
&&
CollUtil
.
get
(
taskIdSet
,
0
).
equals
(-
99L
))
{
// 不是管理员,并且第一次处理工单,但当前处理人是他
}
else
if
(
taskIdSet
.
size
()
==
1
&&
CollUtil
.
get
(
taskIdSet
,
0
).
equals
(
0L
))
{
// 管理员逻辑
}
else
{
wrapper
.
in
(
Task:
:
getId
,
taskIdSet
);
}
return
this
.
selectJoinListPage
(
Page
.
of
(
data
.
getPageNum
(),
data
.
getPageSize
()),
TaskVO
.
class
,
wrapper
);
}
}
@Override
@Override
...
@@ -138,7 +149,6 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -138,7 +149,6 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
*
*
* @param data 前端传参
* @param data 前端传参
*/
*/
private
void
handleTaskTemp
(
TaskDTO
data
)
{
private
void
handleTaskTemp
(
TaskDTO
data
)
{
if
(
ObjUtil
.
isNotNull
(
data
.
getTaskTempId
()))
{
if
(
ObjUtil
.
isNotNull
(
data
.
getTaskTempId
()))
{
Task
existTask
=
this
.
lambdaQuery
().
eq
(
Task:
:
getTaskTempId
,
data
.
getTaskTempId
()).
one
();
Task
existTask
=
this
.
lambdaQuery
().
eq
(
Task:
:
getTaskTempId
,
data
.
getTaskTempId
()).
one
();
...
...
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