Commit 0498b8c9 by zhu.zewen

新增交接班相关接口

parent 41b39a0f
package com.jmai.physic.controller; package com.jmai.physic.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jmai.physic.dto.*; import com.jmai.physic.dto.*;
import com.jmai.physic.entity.PhysicBill; import com.jmai.physic.entity.PhysicBill;
import com.jmai.physic.entity.PhysicBillHandover;
import com.jmai.physic.service.PhysicBillService; import com.jmai.physic.service.PhysicBillService;
import com.jmai.physic.vo.BillInfoVO; import com.jmai.physic.vo.BillInfoVO;
import com.jmai.physic.vo.BillQueryVO; import com.jmai.physic.vo.BillQueryVO;
...@@ -19,7 +17,6 @@ import lombok.extern.slf4j.Slf4j; ...@@ -19,7 +17,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
...@@ -52,32 +49,4 @@ public class PhysicBillController { ...@@ -52,32 +49,4 @@ public class PhysicBillController {
PhysicBill bill = physicBillService.sign(physicBillSignReq); PhysicBill bill = physicBillService.sign(physicBillSignReq);
return ResponseData.ok(bill); return ResponseData.ok(bill);
} }
@PostMapping("/createHandover")
@ApiOperation(value = "交接单-新建")
public ResponseData<PhysicBillHandover> createHandover(@RequestBody @Valid PhysicBillHandoverCreateReq req) {
PhysicBillHandover handover = physicBillService.handover(req);
return ResponseData.ok(handover);
}
@PostMapping("/listHandoverPage")
@ApiOperation(value = "交接单-分页查询")
public ResponseData<IPage<PhysicBillHandover>> listHandoverPage(@RequestBody @Valid PhysicBillHandoverQueryReq req) {
IPage<PhysicBillHandover> page = physicBillService.listHandoverPage(req);
return ResponseData.ok(page);
}
@PostMapping("/getHandoverPhysicBills")
@ApiOperation(value = "交接单-获取已交接的专账列表")
public ResponseData<List<PhysicBill>> getHandoverBills(@RequestParam("handoverId") Long handoverId) {
List<PhysicBill> bills = physicBillService.getHandoverPhysicBills(handoverId);
return ResponseData.ok(bills);
}
@PostMapping("/getPendingHandoverBills")
@ApiOperation(value = "交接单-获取待交接的专账列表")
public ResponseData<List<PhysicBill>> getPendingHandoverBills() {
List<PhysicBill> bills = physicBillService.getPendingHandoverPhysicBills();
return ResponseData.ok(bills);
}
} }
\ No newline at end of file
package com.jmai.physic.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jmai.physic.dto.PhysicBillHandoverCreateReq;
import com.jmai.physic.dto.PhysicBillHandoverQueryReq;
import com.jmai.physic.dto.PhysicBillHandoverSignReq;
import com.jmai.physic.entity.PhysicBill;
import com.jmai.physic.entity.PhysicBillHandover;
import com.jmai.physic.service.PhysicBillService;
import com.jmai.sys.aop.Auth;
import com.jmai.sys.ctx.SpringContextUtils;
import com.jmai.sys.dto.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@Slf4j
@Auth
@RestController
@RequestMapping("/physicBillHandover")
@Api(tags = "专账交接单")
@ApiImplicitParams({@ApiImplicitParam(paramType = "header", name = "Access-Token", value = "凭证", required = true, dataType = "string")})
public class PhysicBillHandoverController {
@Resource
private PhysicBillService physicBillService;
@PostMapping("/createHandover")
@ApiOperation(value = "交接单-新建")
public ResponseData<PhysicBillHandover> createHandover(@RequestBody @Valid PhysicBillHandoverCreateReq req) {
PhysicBillHandover handover = physicBillService.handover(req);
return ResponseData.ok(handover);
}
@PostMapping("/listHandoverPage")
@ApiOperation(value = "交接单-分页查询")
public ResponseData<IPage<PhysicBillHandover>> listHandoverPage(@RequestBody @Valid PhysicBillHandoverQueryReq req) {
IPage<PhysicBillHandover> page = physicBillService.listHandoverPage(req);
return ResponseData.ok(page);
}
@PostMapping("/getHandoverPhysicBills")
@ApiOperation(value = "交接单-获取已交接的专账列表")
public ResponseData<List<PhysicBill>> getHandoverBills(@RequestParam("handoverId") Long handoverId) {
List<PhysicBill> bills = physicBillService.getHandoverPhysicBills(handoverId);
return ResponseData.ok(bills);
}
@PostMapping("/getPendingHandoverBills")
@ApiOperation(value = "交接单-获取待交接的专账列表")
public ResponseData<List<PhysicBill>> getPendingHandoverBills() {
List<PhysicBill> bills = physicBillService.getPendingHandoverPhysicBills(SpringContextUtils.getDeptId());
return ResponseData.ok(bills);
}
@PostMapping("/signHandover")
@ApiOperation(value = "交接单-签名")
public ResponseData<PhysicBillHandover> signHandover(@RequestBody @Valid PhysicBillHandoverSignReq req) {
PhysicBillHandover handover = physicBillService.signHandover(req);
return ResponseData.ok(handover);
}
}
\ No newline at end of file
...@@ -9,4 +9,7 @@ import lombok.Data; ...@@ -9,4 +9,7 @@ import lombok.Data;
public class PhysicBillHandoverCreateReq { public class PhysicBillHandoverCreateReq {
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remark; private String remark;
@ApiModelProperty(value = "签名")
private SignReq sign;
} }
\ No newline at end of file
package com.jmai.physic.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PhysicBillHandoverSignReq extends SignReq {
@ApiModelProperty(value = "交接单id")
private Long handoverId;
}
package com.jmai.physic.dto; package com.jmai.physic.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
@Data @Data
@ApiModel(value = "SignReq", description = "签名请求参数")
public class SignReq { public class SignReq {
@NotBlank(message = "签名token(encryptedToken)不能为空") @NotBlank(message = "签名token(encryptedToken)不能为空")
@ApiModelProperty(value = "签名token") @ApiModelProperty(value = "签名token")
......
...@@ -22,9 +22,9 @@ public class PhysicBillHandover extends BaseVersionEntity { ...@@ -22,9 +22,9 @@ public class PhysicBillHandover extends BaseVersionEntity {
@ApiModelProperty(value = "状态:0-待移交、1-待接收、100-已完成(0-99审核中)") @ApiModelProperty(value = "状态:0-待移交、1-待接收、100-已完成(0-99审核中)")
private Integer status; private Integer status;
@ApiModelProperty(value = "移交人签名(transferor)") @ApiModelProperty(value = "交班人/移交人签名(transferor)")
private String yjUser; private String yjUser;
@ApiModelProperty(value = "接收人签名(receiver)") @ApiModelProperty(value = "接班人/接收人签名(receiver)")
private String jsUser; private String jsUser;
@ApiModelProperty(value = "完成时间") @ApiModelProperty(value = "完成时间")
private LocalDateTime finishTime; private LocalDateTime finishTime;
......
...@@ -20,6 +20,7 @@ public interface PhysicBillService { ...@@ -20,6 +20,7 @@ public interface PhysicBillService {
// 交接单 // 交接单
IPage<PhysicBillHandover> listHandoverPage(PhysicBillHandoverQueryReq req); IPage<PhysicBillHandover> listHandoverPage(PhysicBillHandoverQueryReq req);
List<PhysicBill> getHandoverPhysicBills(Long handoverId); List<PhysicBill> getHandoverPhysicBills(Long handoverId);
List<PhysicBill> getPendingHandoverPhysicBills(); List<PhysicBill> getPendingHandoverPhysicBills(Long deptId);
PhysicBillHandover handover(PhysicBillHandoverCreateReq req); PhysicBillHandover handover(PhysicBillHandoverCreateReq req);
PhysicBillHandover signHandover(PhysicBillHandoverSignReq req);
} }
...@@ -91,15 +91,15 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill ...@@ -91,15 +91,15 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
String getstamp = cloudsignService.sign(physicBillSignReq.getEncryptedToken(), physicBillSignReq.getRelBizNo(), physicBillSignReq.getBase64SourceData()); String getstamp = cloudsignService.sign(physicBillSignReq.getEncryptedToken(), physicBillSignReq.getRelBizNo(), physicBillSignReq.getBase64SourceData());
PhysicBill bill = physicBillMapper.selectById(physicBillSignReq.getPhysicBillId()); PhysicBill bill = physicBillMapper.selectById(physicBillSignReq.getPhysicBillId());
SysUser sysUser = sysUserMapper.selectById(userId); SysUser sysUser = sysUserMapper.selectById(userId);
if(bill.getStatus().equals(0)){ if (bill.getStatus().equals(0)) {
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.LY)){ if (!RoleTypeEum.isPass(sysUser.getRoleAsList(), RoleTypeEum.LY)) {
throw new ServiceException("需要领药人权限才可进行签名"); throw new ServiceException("需要领药人权限才可进行签名");
} }
bill.setStatus(1); bill.setStatus(1);
SignInfoDTO signInfoDTO = new SignInfoDTO(getstamp, LocalDateTime.now(),userId); SignInfoDTO signInfoDTO = new SignInfoDTO(getstamp, LocalDateTime.now(), userId);
bill.setLyUser(JSONUtil.toJsonStr(signInfoDTO)); bill.setLyUser(JSONUtil.toJsonStr(signInfoDTO));
}else if(bill.getStatus().equals(1)) { } else if (bill.getStatus().equals(1)) {
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.FH)){ if (!RoleTypeEum.isPass(sysUser.getRoleAsList(), RoleTypeEum.FH)) {
throw new ServiceException("需要复核人权限才可进行签名"); throw new ServiceException("需要复核人权限才可进行签名");
} }
bill.setStatus(100); bill.setStatus(100);
...@@ -145,11 +145,15 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill ...@@ -145,11 +145,15 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
* 获取待交接的专账 * 获取待交接的专账
*/ */
@Override @Override
public List<PhysicBill> getPendingHandoverPhysicBills() { public List<PhysicBill> getPendingHandoverPhysicBills(Long deptId) {
if (ObjectUtil.isEmpty(deptId)) {
throw new ServiceException("部门ID不能为空");
}
Long lastHandoverBillId = 0L; Long lastHandoverBillId = 0L;
// 获取最新的交接单 // 获取最新的交接单
PhysicBillHandover lastHandover = physicBillHandoverMapper.selectOne(Wrappers.lambdaQuery(PhysicBillHandover.class) PhysicBillHandover lastHandover = physicBillHandoverMapper.selectOne(Wrappers.lambdaQuery(PhysicBillHandover.class)
.eq(PhysicBillHandover::getDeptId, deptId)
.orderByDesc(PhysicBillHandover::getId)); .orderByDesc(PhysicBillHandover::getId));
if (ObjectUtil.isNotEmpty(lastHandover)) { if (ObjectUtil.isNotEmpty(lastHandover)) {
if (ObjectUtil.isEmpty(lastHandover.getFinishTime())) { if (ObjectUtil.isEmpty(lastHandover.getFinishTime())) {
...@@ -168,8 +172,9 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill ...@@ -168,8 +172,9 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
/** /**
* 获取最新已交接单 * 获取最新已交接单
*/ */
public Optional<PhysicBillHandover> getLastHandover() { private Optional<PhysicBillHandover> getLastHandover(Long deptId) {
PhysicBillHandover lastHandover = physicBillHandoverMapper.selectOne(Wrappers.lambdaQuery(PhysicBillHandover.class) PhysicBillHandover lastHandover = physicBillHandoverMapper.selectOne(Wrappers.lambdaQuery(PhysicBillHandover.class)
.eq(PhysicBillHandover::getDeptId, deptId)
.orderByDesc(PhysicBillHandover::getId)); .orderByDesc(PhysicBillHandover::getId));
if (ObjectUtil.isEmpty(lastHandover)) { if (ObjectUtil.isEmpty(lastHandover)) {
return Optional.empty(); return Optional.empty();
...@@ -184,9 +189,10 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill ...@@ -184,9 +189,10 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
/** /**
* 获取最新已交接单的专账 * 获取最新已交接单的专账
*/ */
private List<PhysicBill> getLastHandoverPhysicBills() { private List<PhysicBill> getLastHandoverPhysicBills(Long deptId) {
// 获取最新的交接单 // 获取最新的交接单
PhysicBillHandover lastHandover = physicBillHandoverMapper.selectOne(Wrappers.lambdaQuery(PhysicBillHandover.class) PhysicBillHandover lastHandover = physicBillHandoverMapper.selectOne(Wrappers.lambdaQuery(PhysicBillHandover.class)
.eq(PhysicBillHandover::getDeptId, deptId)
.orderByDesc(PhysicBillHandover::getId)); .orderByDesc(PhysicBillHandover::getId));
if (ObjectUtil.isEmpty(lastHandover)) { if (ObjectUtil.isEmpty(lastHandover)) {
return Collections.emptyList(); return Collections.emptyList();
...@@ -196,6 +202,7 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill ...@@ -196,6 +202,7 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
} }
List<PhysicBill> billList = physicBillMapper.selectList(Wrappers.<PhysicBill>lambdaQuery() List<PhysicBill> billList = physicBillMapper.selectList(Wrappers.<PhysicBill>lambdaQuery()
.eq(PhysicBill::getDeptId, deptId)
.gt(PhysicBill::getId, lastHandover.getStartBillId()) .gt(PhysicBill::getId, lastHandover.getStartBillId())
.le(PhysicBill::getId, lastHandover.getEndBillId()) .le(PhysicBill::getId, lastHandover.getEndBillId())
.orderByAsc(PhysicBill::getId)); .orderByAsc(PhysicBill::getId));
...@@ -204,24 +211,76 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill ...@@ -204,24 +211,76 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
@Override @Override
public PhysicBillHandover handover(PhysicBillHandoverCreateReq req) { public PhysicBillHandover handover(PhysicBillHandoverCreateReq req) {
Optional<PhysicBillHandover> lastHandover = getLastHandover(); Long deptId = SpringContextUtils.getDeptId();
assert deptId != null : "部门ID不能为空";
Optional<PhysicBillHandover> lastHandover = getLastHandover(deptId);
Long startBillId = lastHandover.map(PhysicBillHandover::getEndBillId).orElse(0L); Long startBillId = lastHandover.map(PhysicBillHandover::getEndBillId).orElse(0L);
Long endBillId = startBillId; Long endBillId = startBillId;
List<PhysicBill> billList = getPendingHandoverPhysicBills(); List<PhysicBill> billList = getPendingHandoverPhysicBills(deptId);
if (ObjectUtil.isNotEmpty(billList)) { if (ObjectUtil.isNotEmpty(billList)) {
endBillId = billList.get(billList.size() - 1).getId(); endBillId = billList.get(billList.size() - 1).getId();
} }
PhysicBillHandover billHandover = new PhysicBillHandover(); PhysicBillHandover billHandover = new PhysicBillHandover();
billHandover.setDeptId(SpringContextUtils.getDeptId()); billHandover.setDeptId(deptId);
billHandover.setStartBillId(startBillId); billHandover.setStartBillId(startBillId);
billHandover.setEndBillId(endBillId); billHandover.setEndBillId(endBillId);
billHandover.setStatus(0); billHandover.setStatus(0);
billHandover.setYjUser(null);
billHandover.setJsUser(null);
billHandover.setRemark(req.getRemark()); billHandover.setRemark(req.getRemark());
physicBillHandoverMapper.insert(billHandover); physicBillHandoverMapper.insert(billHandover);
if (ObjectUtil.isEmpty(req.getSign())) {
// 交接人签名
PhysicBillHandoverSignReq signReq = new PhysicBillHandoverSignReq();
copyTo(req.getSign(), signReq);
signReq.setHandoverId(billHandover.getId());
signHandover(signReq);
}
return billHandover; return billHandover;
} }
@Override
public PhysicBillHandover signHandover(PhysicBillHandoverSignReq req) {
boolean finished = false;
Long userId = SpringContextUtils.getUserId();
Long currentDeptId = SpringContextUtils.getDeptId();
String getstamp = cloudsignService.sign(req.getEncryptedToken(), req.getRelBizNo(), req.getBase64SourceData());
PhysicBillHandover handover = physicBillHandoverMapper.selectById(req.getHandoverId());
if (ObjectUtil.isEmpty(handover)) {
throw new ServiceException("未找到交接单:" + req.getHandoverId());
}
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));
handover.setFinishTime(LocalDateTime.now());
finished = true;
} else {
throw new ServiceException("当前交接单状态不支持签名");
}
physicBillHandoverMapper.updateById(handover);
return handover;
}
} }
\ No newline at end of file
...@@ -19,10 +19,14 @@ public enum RoleTypeEum { ...@@ -19,10 +19,14 @@ public enum RoleTypeEum {
CZ(10,"操作人"), CZ(10,"操作人"),
XH(11,"销毁人"), XH(11,"销毁人"),
JD(12,"监督人"), JD(12,"监督人"),
YXBZR(13,"药学部主任"),
YWKKZ(14,"医务科科长"), YXBZR(101,"药学部主任"),
BWKKZ(15,"保卫科科长"), YWKKZ(102,"医务科科长"),
ZGYZ(16,"主管院长"); BWKKZ(103,"保卫科科长"),
ZGYZ(104,"主管院长"),
JBX(201,"交班人"),
JBY(202,"接班人"),;
public long code; public long code;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment