Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huang.tao
/
jmai-platform
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
bc17b2b2
authored
Jan 06, 2026
by
zhu.zewen
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
新增交接班相关接口
parent
0498b8c9
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
164 additions
and
14 deletions
config/application-dev.yaml
jmai-physic/src/main/java/com/jmai/physic/controller/PhysicBillHandoverController.java
jmai-physic/src/main/java/com/jmai/physic/dto/PhysicBillHandoverQueryReq.java
jmai-physic/src/main/java/com/jmai/physic/entity/PhysicBillHandover.java
jmai-physic/src/main/java/com/jmai/physic/service/PhysicBillService.java
jmai-physic/src/main/java/com/jmai/physic/service/impl/PhysicBillServiceImpl.java
jmai-sys/src/main/java/com/jmai/sys/consts/enums/RoleTypeEum.java
config/application-dev.yaml
View file @
bc17b2b2
...
...
@@ -65,3 +65,14 @@ cloudsign:
businessSystemCode
:
1176
businessSystemAppID
:
w6qpjDk1WBSrFCfgcj
# ################################################
# 交接单配置
# ################################################
handover
:
cancel
:
# 是否允许交班人取消交接单(默认false)
allowTransferor
:
false
# 是否允许接班人取消交接单(默认false)
allowReceiver
:
false
# 允许取消的天数限制(默认3天,从0时开始,含当天)
dayLimit
:
3
jmai-physic/src/main/java/com/jmai/physic/controller/PhysicBillHandoverController.java
View file @
bc17b2b2
...
...
@@ -2,6 +2,7 @@ package com.jmai.physic.controller;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.jmai.physic.dto.PhysicBillHandoverCancelReq
;
import
com.jmai.physic.dto.PhysicBillHandoverCreateReq
;
import
com.jmai.physic.dto.PhysicBillHandoverQueryReq
;
import
com.jmai.physic.dto.PhysicBillHandoverSignReq
;
...
...
@@ -66,4 +67,11 @@ public class PhysicBillHandoverController {
PhysicBillHandover
handover
=
physicBillService
.
signHandover
(
req
);
return
ResponseData
.
ok
(
handover
);
}
@PostMapping
(
"/cancelHandover"
)
@ApiOperation
(
value
=
"交接单-取消"
)
public
ResponseData
<
Void
>
cancelHandover
(
@RequestBody
@Valid
PhysicBillHandoverCancelReq
req
)
{
physicBillService
.
cancelHandover
(
req
);
return
ResponseData
.
ok
();
}
}
\ No newline at end of file
jmai-physic/src/main/java/com/jmai/physic/dto/PhysicBillHandoverQueryReq.java
View file @
bc17b2b2
...
...
@@ -13,7 +13,7 @@ public class PhysicBillHandoverQueryReq extends PageReq {
@ApiModelProperty
(
value
=
"部门"
)
private
Long
deptId
;
@ApiModelProperty
(
value
=
"状态:0-待移交、1-待接收、100-已完成(0-99审核中)"
)
@ApiModelProperty
(
value
=
"状态:
-100-已取消、
0-待移交、1-待接收、100-已完成(0-99审核中)"
)
private
Integer
status
;
@ApiModelProperty
(
value
=
"开始完成时间"
)
...
...
jmai-physic/src/main/java/com/jmai/physic/entity/PhysicBillHandover.java
View file @
bc17b2b2
...
...
@@ -20,7 +20,7 @@ public class PhysicBillHandover extends BaseVersionEntity {
@ApiModelProperty
(
value
=
"截止转账ID(包含)"
)
private
Long
endBillId
;
@ApiModelProperty
(
value
=
"状态:0-待移交、1-待接收、100-已完成(0-99审核中)"
)
@ApiModelProperty
(
value
=
"状态:
-100-已取消、
0-待移交、1-待接收、100-已完成(0-99审核中)"
)
private
Integer
status
;
@ApiModelProperty
(
value
=
"交班人/移交人签名(transferor)"
)
private
String
yjUser
;
...
...
jmai-physic/src/main/java/com/jmai/physic/service/PhysicBillService.java
View file @
bc17b2b2
...
...
@@ -23,4 +23,5 @@ public interface PhysicBillService {
List
<
PhysicBill
>
getPendingHandoverPhysicBills
(
Long
deptId
);
PhysicBillHandover
handover
(
PhysicBillHandoverCreateReq
req
);
PhysicBillHandover
signHandover
(
PhysicBillHandoverSignReq
req
);
void
cancelHandover
(
PhysicBillHandoverCancelReq
req
);
}
jmai-physic/src/main/java/com/jmai/physic/service/impl/PhysicBillServiceImpl.java
View file @
bc17b2b2
...
...
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jmai.api.exception.ServiceException
;
import
com.jmai.physic.cloudsign.CloudsignService
;
import
com.jmai.physic.config.HandoverCancelProperties
;
import
com.jmai.physic.dto.*
;
import
com.jmai.physic.entity.PhysicBill
;
import
com.jmai.physic.entity.PhysicBillHandover
;
...
...
@@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Optional
;
...
...
@@ -41,6 +43,8 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
@Resource
private
CloudsignService
cloudsignService
;
@Resource
private
HandoverCancelProperties
handoverCancelProperties
;
@Resource
private
SysUserMapper
sysUserMapper
;
...
...
@@ -165,6 +169,7 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
// TODO:是否会有未完成的专账?
List
<
PhysicBill
>
billList
=
physicBillMapper
.
selectList
(
Wrappers
.<
PhysicBill
>
lambdaQuery
()
.
gt
(
PhysicBill:
:
getId
,
lastHandoverBillId
)
.
eq
(
PhysicBill:
:
getDeptId
,
deptId
)
.
orderByAsc
(
PhysicBill:
:
getId
));
return
billList
;
}
...
...
@@ -212,9 +217,29 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
@Override
public
PhysicBillHandover
handover
(
PhysicBillHandoverCreateReq
req
)
{
Long
deptId
=
SpringContextUtils
.
getDeptId
();
Long
userId
=
SpringContextUtils
.
getUserId
();
assert
deptId
!=
null
:
"部门ID不能为空"
;
// 验证是否存在未完成的交接单
PhysicBillHandover
unfinishedHandover
=
physicBillHandoverMapper
.
selectOne
(
Wrappers
.
lambdaQuery
(
PhysicBillHandover
.
class
)
.
eq
(
PhysicBillHandover:
:
getDeptId
,
deptId
)
.
ne
(
PhysicBillHandover:
:
getStatus
,
100
)
.
ne
(
PhysicBillHandover:
:
getStatus
,
-
100
)
.
orderByDesc
(
PhysicBillHandover:
:
getId
));
if
(
ObjectUtil
.
isNotEmpty
(
unfinishedHandover
))
{
throw
new
ServiceException
(
"存在未完成交接单"
);
}
// 获取最新已完成的交接单
Optional
<
PhysicBillHandover
>
lastHandover
=
getLastHandover
(
deptId
);
// 验证当前用户是上次接班人
if
(
lastHandover
.
isPresent
())
{
SignInfoDTO
jsUserInfo
=
JSONUtil
.
toBean
(
lastHandover
.
get
().
getJsUser
(),
SignInfoDTO
.
class
);
if
(!
jsUserInfo
.
getUserId
().
equals
(
userId
))
{
throw
new
ServiceException
(
"仅上次接班人有权限进行下一次交接班"
);
}
}
Long
startBillId
=
lastHandover
.
map
(
PhysicBillHandover:
:
getEndBillId
).
orElse
(
0L
);
Long
endBillId
=
startBillId
;
...
...
@@ -234,7 +259,7 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
physicBillHandoverMapper
.
insert
(
billHandover
);
if
(
ObjectUtil
.
isEmpty
(
req
.
getSign
()))
{
if
(
ObjectUtil
.
is
Not
Empty
(
req
.
getSign
()))
{
// 交接人签名
PhysicBillHandoverSignReq
signReq
=
new
PhysicBillHandoverSignReq
();
copyTo
(
req
.
getSign
(),
signReq
);
...
...
@@ -258,20 +283,13 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
if
(!
handover
.
getDeptId
().
equals
(
currentDeptId
))
{
throw
new
ServiceException
(
"交接班只能在同一部门内进行"
);
}
SysUser
sysUser
=
sysUserMapper
.
selectById
(
userId
);
if
(
handover
.
getStatus
().
equals
(
0
))
{
// 交班人/移交人签名
if
(!
RoleTypeEum
.
isPass
(
sysUser
.
getRoleAsList
(),
RoleTypeEum
.
JBX
))
{
throw
new
ServiceException
(
"需要交班人权限才可进行签名"
);
}
handover
.
setStatus
(
1
);
SignInfoDTO
signInfoDTO
=
new
SignInfoDTO
(
getstamp
,
LocalDateTime
.
now
(),
userId
);
handover
.
setYjUser
(
JSONUtil
.
toJsonStr
(
signInfoDTO
));
}
else
if
(
handover
.
getStatus
().
equals
(
1
))
{
// 接班人/接收人签名
if
(!
RoleTypeEum
.
isPass
(
sysUser
.
getRoleAsList
(),
RoleTypeEum
.
JBY
))
{
throw
new
ServiceException
(
"需要接班人权限才可进行签名"
);
}
handover
.
setStatus
(
100
);
SignInfoDTO
signInfoDTO
=
new
SignInfoDTO
(
getstamp
,
LocalDateTime
.
now
(),
userId
);
handover
.
setJsUser
(
JSONUtil
.
toJsonStr
(
signInfoDTO
));
...
...
@@ -283,4 +301,117 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
physicBillHandoverMapper
.
updateById
(
handover
);
return
handover
;
}
@Override
public
void
cancelHandover
(
PhysicBillHandoverCancelReq
req
)
{
Long
currentUserId
=
SpringContextUtils
.
getUserId
();
Long
currentDeptId
=
SpringContextUtils
.
getDeptId
();
PhysicBillHandover
handover
=
physicBillHandoverMapper
.
selectById
(
req
.
getHandoverId
());
if
(
ObjectUtil
.
isEmpty
(
handover
))
{
throw
new
ServiceException
(
"未找到交接单:"
+
req
.
getHandoverId
());
}
if
(!
handover
.
getDeptId
().
equals
(
currentDeptId
))
{
throw
new
ServiceException
(
"交接班只能在同一部门内进行"
);
}
if
(
handover
.
getStatus
().
equals
(
100
))
{
if
(!
handoverCancelProperties
.
getAllowCancelCompleted
())
{
throw
new
ServiceException
(
"已完成交接班不能取消"
);
}
}
if
(
handover
.
getStatus
().
equals
(-
100
))
{
throw
new
ServiceException
(
"交接班已取消,不应重复取消"
);
}
// 验证是否为最新未取消的交接单
PhysicBillHandover
latestHandover
=
physicBillHandoverMapper
.
selectOne
(
Wrappers
.
lambdaQuery
(
PhysicBillHandover
.
class
)
.
eq
(
PhysicBillHandover:
:
getDeptId
,
currentDeptId
)
.
ne
(
PhysicBillHandover:
:
getStatus
,
-
100
)
.
orderByDesc
(
PhysicBillHandover:
:
getId
)
.
last
(
"LIMIT 1"
));
if
(
ObjectUtil
.
isEmpty
(
latestHandover
)
||
!
latestHandover
.
getId
().
equals
(
handover
.
getId
()))
{
throw
new
ServiceException
(
"只允许取消最新一个未取消的交接单"
);
}
// 验证操作权限
validateCancelPermission
(
handover
,
currentUserId
);
// 验证时间限制
validateCancelTimeLimit
(
handover
);
handover
.
setStatus
(-
100
);
physicBillHandoverMapper
.
updateById
(
handover
);
}
/**
* 验证取消操作的权限
*/
private
void
validateCancelPermission
(
PhysicBillHandover
handover
,
Long
currentUserId
)
{
List
<
String
>
msg
=
new
ArrayList
<>(
4
);
// 检查是否为创建人
if
(
handover
.
getCreateBy
()
!=
null
&&
handover
.
getCreateBy
().
equals
(
currentUserId
))
{
return
;
}
else
{
msg
.
add
(
"非创建人"
);
}
// 检查是否为管理员
boolean
isAdmin
=
SpringContextUtils
.
isAdmin
()
||
SpringContextUtils
.
isPlatformAdmin
();
if
(
isAdmin
)
{
return
;
}
else
{
msg
.
add
(
"非管理员"
);
}
// 检查是否允许交班人取消且为交班人
boolean
isTransferor
=
handoverCancelProperties
.
getAllowTransferor
()
&&
handover
.
getYjUser
()
!=
null
;
if
(
isTransferor
)
{
SignInfoDTO
yjUserInfo
=
JSONUtil
.
toBean
(
handover
.
getYjUser
(),
SignInfoDTO
.
class
);
if
(
yjUserInfo
.
getUserId
().
equals
(
currentUserId
))
{
return
;
}
else
{
msg
.
add
(
"非交班人"
);
}
}
// 检查是否允许接班人取消且为接班人
boolean
isReceiver
=
handoverCancelProperties
.
getAllowReceiver
()
&&
handover
.
getJsUser
()
!=
null
;
if
(
isReceiver
)
{
SignInfoDTO
jsUserInfo
=
JSONUtil
.
toBean
(
handover
.
getJsUser
(),
SignInfoDTO
.
class
);
if
(
jsUserInfo
.
getUserId
().
equals
(
currentUserId
))
{
return
;
}
else
{
msg
.
add
(
"非接班人"
);
}
}
// 根据不同的权限配置报告不同的错误消息
throw
new
ServiceException
(
"您没有权限取消此交接单:"
+
String
.
join
(
"、"
,
msg
));
}
/**
* 验证取消时间限制
* 仅对未完成的交接单进行时间限制校验,已完成的交接单不受时间限制
*/
private
void
validateCancelTimeLimit
(
PhysicBillHandover
handover
)
{
// 未完成的交接单不受时间限制
if
(
handover
.
getStatus
().
equals
(-
100
))
{
return
;
}
LocalDateTime
createdTime
=
handover
.
getCreateTime
();
if
(
createdTime
==
null
)
{
throw
new
ServiceException
(
"交接单创建时间异常"
);
}
// 计算创建日期的开始时间(0时)
LocalDateTime
createdDateStart
=
createdTime
.
toLocalDate
().
atStartOfDay
();
// 计算允许取消的最后一天的结束时间
LocalDateTime
cancelDeadline
=
createdDateStart
.
plusDays
(
handoverCancelProperties
.
getDayLimit
());
// 当前时间
LocalDateTime
now
=
LocalDateTime
.
now
();
if
(
now
.
isAfter
(
cancelDeadline
))
{
throw
new
ServiceException
(
"超过"
+
handoverCancelProperties
.
getDayLimit
()
+
"天的交接单不允许取消"
);
}
}
}
\ No newline at end of file
jmai-sys/src/main/java/com/jmai/sys/consts/enums/RoleTypeEum.java
View file @
bc17b2b2
...
...
@@ -23,10 +23,7 @@ public enum RoleTypeEum {
YXBZR
(
101
,
"药学部主任"
),
YWKKZ
(
102
,
"医务科科长"
),
BWKKZ
(
103
,
"保卫科科长"
),
ZGYZ
(
104
,
"主管院长"
),
JBX
(
201
,
"交班人"
),
JBY
(
202
,
"接班人"
),;
ZGYZ
(
104
,
"主管院长"
);
public
long
code
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment