Commit 7d26bbe5 by zhu.zewen

新增云签相关接口

parent 76120359
......@@ -14,10 +14,11 @@ public class SignDataRequest {
private String businessSystemCode;
@ApiModelProperty(value = "业务系统应用ID,业务系统的唯一标识号", required = true)
private String businessSystemAppID;
@ApiModelProperty(value = "业务类型代码", required = true)
private String businessTypeCode;
@ApiModelProperty(value = "加密令牌", required = true)
private String encryptedToken;
@ApiModelProperty(value = "业务类型代码", required = true)
private String businessTypeCode;
@ApiModelProperty(value = "患者ID")
private String patientId;
@ApiModelProperty(value = "业务ID")
......
......@@ -3,11 +3,9 @@ package com.jmai.physic.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jmai.api.exception.ServiceException;
import com.jmai.physic.cloudsign.*;
import com.jmai.physic.config.CloudSignProperties;
import com.jmai.physic.entity.CloudSignToken;
import com.jmai.physic.mapper.CloudSignTokenMapper;
import com.jmai.sys.AbstractService;
import com.jmai.sys.aop.Auth;
......@@ -15,10 +13,8 @@ import com.jmai.sys.aop.AuthSkipped;
import com.jmai.sys.ctx.SpringContextUtils;
import com.jmai.sys.dto.ResponseData;
import com.jmai.sys.dto.UserDto;
import com.jmai.sys.service.BaseService;
import com.jmai.sys.service.UserService;
import java.time.LocalDateTime;
import java.util.Optional;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -40,6 +36,10 @@ public class CloudSignController extends AbstractService {
private CloudsignService cloudsignService;
@Resource
private CloudSignProperties cloudSignProperties;
@Resource
private CloudSignTokenMapper cloudSignTokenMapper;
@PostMapping("/queryStatus")
@ApiOperation(value = "检查云签状态")
......@@ -49,20 +49,7 @@ public class CloudSignController extends AbstractService {
throw new ServiceException("当前用户工号为空");
}
queryStatusRequest.setBusinessOrgCode(cloudSignProperties.getBusinessOrgCode());
queryStatusRequest.setBusinessSystemCode(cloudSignProperties.getBusinessSystemCode());
queryStatusRequest.setBusinessSystemAppID(cloudSignProperties.getBusinessSystemApplD());
if (cloudSignProperties.getTestEnabled()) {
queryStatusRequest.setBusinessOrgCode(cloudSignProperties.getTestBusinessOrgCode());
queryStatusRequest.setBusinessSystemCode(cloudSignProperties.getTestBusinessSystemCode());
queryStatusRequest.setBusinessSystemAppID(cloudSignProperties.getTestBusinessSystemAppID());
} else {
queryStatusRequest.setBusinessOrgCode(cloudSignProperties.getBusinessOrgCode());
queryStatusRequest.setBusinessSystemCode(cloudSignProperties.getBusinessSystemCode());
queryStatusRequest.setBusinessSystemAppID(cloudSignProperties.getBusinessSystemApplD());
}
// 现在业务参数和encryptedToken会在服务层自动填充
QueryStatusResponse queryStatus = cloudsignService.queryStatus(queryStatusRequest);
return ResponseData.ok(queryStatus);
}
......@@ -77,16 +64,8 @@ public class CloudSignController extends AbstractService {
pinLoginRequest.setRelBizNo(workNo);
pinLoginRequest.setUserEncodePin(pinLoginRequest.getUserEncodePin());
if (cloudSignProperties.getTestEnabled()) {
pinLoginRequest.setBusinessOrgCode(cloudSignProperties.getTestBusinessOrgCode());
pinLoginRequest.setBusinessSystemCode(cloudSignProperties.getTestBusinessSystemCode());
pinLoginRequest.setBusinessSystemAppID(cloudSignProperties.getTestBusinessSystemAppID());
} else {
pinLoginRequest.setBusinessOrgCode(cloudSignProperties.getBusinessOrgCode());
pinLoginRequest.setBusinessSystemCode(cloudSignProperties.getBusinessSystemCode());
pinLoginRequest.setBusinessSystemAppID(cloudSignProperties.getBusinessSystemApplD());
}
// 现在业务参数和测试环境配置会在服务层自动处理
GenloginqrcodeRespon pinLogin = cloudsignService.loginByPin(pinLoginRequest);
return ResponseData.ok(pinLogin);
}
......@@ -99,18 +78,10 @@ public class CloudSignController extends AbstractService {
throw new ServiceException("当前用户工号为空");
}
if (cloudSignProperties.getTestEnabled()) {
req.setBusinessOrgCode(cloudSignProperties.getTestBusinessOrgCode());
req.setBusinessSystemCode(cloudSignProperties.getTestBusinessSystemCode());
req.setBusinessSystemAppID(cloudSignProperties.getTestBusinessSystemAppID());
} else {
req.setBusinessOrgCode(cloudSignProperties.getBusinessOrgCode());
req.setBusinessSystemCode(cloudSignProperties.getBusinessSystemCode());
req.setBusinessSystemAppID(cloudSignProperties.getBusinessSystemApplD());
}
req.setNotifyUrl(cloudSignProperties.getCallbackUrl());
req.setImageFormat(1);
// 现在业务参数和测试环境配置会在服务层自动处理
GenloginqrcodeRespon qrCodeLogin = cloudsignService.genLoginQrcode(req);
// 如果二维码生成成功,保存二维码图片到本地
......@@ -189,7 +160,7 @@ public class CloudSignController extends AbstractService {
}
// 保存云签令牌信息
saveCloudSignToken(user, encryptedToken);
cloudsignService.saveCloudSignToken(user, encryptedToken);
log.info("云签登录成功,用户ID: {}, 工号: {}, 用户名: {}", user.getUserId(), user.getWorkNo(), user.getUserName());
......@@ -259,27 +230,7 @@ public class CloudSignController extends AbstractService {
return saveDir + java.io.File.separator + fileName;
}
/**
* 保存云签令牌信息到数据库
*/
private void saveCloudSignToken(UserDto user, String encryptedToken) {
// 创建云签令牌信息并保存到数据库
CloudSignToken cloudSignToken = new CloudSignToken();
cloudSignToken.setUserId(user.getUserId());
cloudSignToken.setWorkNo(user.getWorkNo());
cloudSignToken.setEncryptedToken(encryptedToken);
// 设置令牌过期时间为当前时间加上默认有效期(例如2小时)
cloudSignToken.setExpiryTime(LocalDateTime.now().plusHours(2));
cloudSignToken.setStatus(1); // 设置为有效状态
// 保存到数据库
CloudSignTokenMapper cloudSignTokenMapper = SpringContextUtils.getBean(CloudSignTokenMapper.class);
// 先尝试删除旧的令牌记录(如果有)
cloudSignTokenMapper.delete(Wrappers.<CloudSignToken>lambdaUpdate()
.eq(CloudSignToken::getUserId, user.getUserId()));
// 插入新的令牌记录
cloudSignTokenMapper.insert(cloudSignToken);
}
@PostMapping("/getLoginByQrcodeResult")
@ApiOperation(value = "查询二维码登录结果")
......@@ -289,16 +240,7 @@ public class CloudSignController extends AbstractService {
throw new ServiceException("当前用户工号为空");
}
if (cloudSignProperties.getTestEnabled()) {
getLoginResultRequest.setBusinessOrgCode(cloudSignProperties.getTestBusinessOrgCode());
getLoginResultRequest.setBusinessSystemCode(cloudSignProperties.getTestBusinessSystemCode());
getLoginResultRequest.setBusinessSystemAppID(cloudSignProperties.getTestBusinessSystemAppID());
} else {
getLoginResultRequest.setBusinessOrgCode(cloudSignProperties.getBusinessOrgCode());
getLoginResultRequest.setBusinessSystemCode(cloudSignProperties.getBusinessSystemCode());
getLoginResultRequest.setBusinessSystemAppID(cloudSignProperties.getBusinessSystemApplD());
}
// 现在业务参数和测试环境配置会在服务层自动处理
GetLoginResultResponse getLoginResult = cloudsignService.getLoginByQrcodeResult(getLoginResultRequest);
return ResponseData.ok(getLoginResult);
}
......@@ -311,12 +253,7 @@ public class CloudSignController extends AbstractService {
throw new ServiceException("当前用户工号为空");
}
if (cloudSignProperties.getTestEnabled()) {
getCertInfoRequest.setBusinessOrgCode(cloudSignProperties.getTestBusinessOrgCode());
} else {
getCertInfoRequest.setBusinessOrgCode(cloudSignProperties.getBusinessOrgCode());
}
// 现在业务参数和测试环境配置会在服务层自动处理
GetCertInfoResponse getCertInfo = cloudsignService.getCertInfo(getCertInfoRequest);
return ResponseData.ok(getCertInfo);
}
......@@ -329,12 +266,7 @@ public class CloudSignController extends AbstractService {
throw new ServiceException("当前用户工号为空");
}
if (cloudSignProperties.getTestEnabled()) {
verifyDataRequest.setBusinessOrgCode(cloudSignProperties.getTestBusinessOrgCode());
} else {
verifyDataRequest.setBusinessOrgCode(cloudSignProperties.getBusinessOrgCode());
}
// 现在业务参数和测试环境配置会在服务层自动处理
VerifyDataResponse verifyData = cloudsignService.verifyData(verifyDataRequest);
return ResponseData.ok(verifyData);
}
......
......@@ -154,7 +154,7 @@ public class PhysicAmpouleServiceImpl extends AbstractService implements PhysicA
public PhysicAmpoule sign(PhysicAmpouleSignReq physicAmpouleSignReq) {
Boolean finished = false;
Long userId = SpringContextUtils.getUserId();
String getstamp = cloudsignService.sign(physicAmpouleSignReq.getEncryptedToken(), physicAmpouleSignReq.getRelBizNo(), physicAmpouleSignReq.getBase64SourceData());
String getstamp = cloudsignService.sign(physicAmpouleSignReq.getBase64SourceData());
PhysicAmpoule ampoule = getInfo(physicAmpouleSignReq.getPhysicAmpouleId());
SysUser sysUser = sysUserMapper.selectById(userId);
if(ampoule.getStatus().equals(0)){
......
......@@ -165,7 +165,7 @@ public class PhysicApplyServiceImpl extends AbstractService implements PhysicApp
Boolean finished =false;
Long userId = SpringContextUtils.getUserId();
SysUser sysUser = sysUserMapper.selectById(userId);
String getstamp = cloudsignService.sign(physicApplySignReq.getEncryptedToken(), physicApplySignReq.getRelBizNo(), physicApplySignReq.getBase64SourceData());
String getstamp = cloudsignService.sign(physicApplySignReq.getBase64SourceData());
PhysicApply physicApply = physicApplyMapper.selectById(physicApplySignReq.getPhysicApplyId());
if(physicApply.getStatus().equals(0)){
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.LY)){
......
......@@ -130,7 +130,7 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
public PhysicBill sign(PhysicBillSignReq physicBillSignReq) {
Boolean finished = false;
Long userId = SpringContextUtils.getUserId();
String getstamp = cloudsignService.sign(physicBillSignReq.getEncryptedToken(), physicBillSignReq.getRelBizNo(), physicBillSignReq.getBase64SourceData());
String getstamp = cloudsignService.sign(physicBillSignReq.getBase64SourceData());
PhysicBill bill = physicBillMapper.selectById(physicBillSignReq.getPhysicBillId());
SysUser sysUser = sysUserMapper.selectById(userId);
if (ObjectUtil.equals(bill.getStatus(), 0)) {
......@@ -326,7 +326,7 @@ public class PhysicBillServiceImpl extends AbstractService implements PhysicBill
boolean finished = false;
Long userId = SpringContextUtils.getUserId();
Long currentDeptId = SpringContextUtils.getDeptId();
String getstamp = cloudsignService.sign(req.getEncryptedToken(), req.getRelBizNo(), req.getBase64SourceData());
String getstamp = cloudsignService.sign(req.getBase64SourceData());
PhysicBillHandover handover = physicBillHandoverMapper.selectById(req.getHandoverId());
if (ObjectUtil.isEmpty(handover)) {
throw new ServiceException("未找到交接单:" + req.getHandoverId());
......
......@@ -122,7 +122,7 @@ public class PhysicDestroyCheckServiceImpl extends BaseServiceImpl<PhysicDestroy
boolean finished = false;
Long userId = SpringContextUtils.getUserId();
SysUser sysUser = sysUserMapper.selectById(userId);
String getstamp = cloudsignService.sign(physicDestroyCheckSignReq.getEncryptedToken(), physicDestroyCheckSignReq.getRelBizNo(), physicDestroyCheckSignReq.getBase64SourceData());
String getstamp = cloudsignService.sign(physicDestroyCheckSignReq.getBase64SourceData());
PhysicDestroyCheck physicDestroyCheck = physicDestroyCheckMapper.selectById(physicDestroyCheckSignReq.getPhysicDestroyCheckId());
if(physicDestroyCheck.getStatus().equals(0)){
if(!RoleTypeEum.isPass(sysUser.getRoleAsList(),RoleTypeEum.XH)){
......
......@@ -63,7 +63,7 @@ public class PhysicDestroyServiceImpl extends AbstractService implements PhysicD
public PhysicDestroy sign(PhysicDestroySignReq physicDestroySignReq) {
boolean finished = false;
Long userId = SpringContextUtils.getUserId();
String getstamp = cloudsignService.sign(physicDestroySignReq.getEncryptedToken(), physicDestroySignReq.getRelBizNo(), physicDestroySignReq.getBase64SourceData());
String getstamp = cloudsignService.sign(physicDestroySignReq.getBase64SourceData());
PhysicDestroy physicDestroy = physicDestroyMapper.selectById(physicDestroySignReq.getPhysicDestroyId());
SysUser sysUser = sysUserMapper.selectById(userId);
if(physicDestroy.getStatus().equals(0)){
......
......@@ -153,7 +153,7 @@ public class PhysicRecordServiceImpl extends AbstractService implements PhysicRe
public PhysicRecord sign(PhysicRecordSignReq physicRecordSignReq) {
boolean finished = false;
Long userId = SpringContextUtils.getUserId();
String getstamp = cloudsignService.sign(physicRecordSignReq.getEncryptedToken(), physicRecordSignReq.getRelBizNo(), physicRecordSignReq.getBase64SourceData());
String getstamp = cloudsignService.sign(physicRecordSignReq.getBase64SourceData());
PhysicRecord physicRecord = getInfo(physicRecordSignReq.getPhysicRecordId());
SysUser sysUser = sysUserMapper.selectById(userId);
if (ObjectUtil.equals(physicRecord.getStatus(), 0)) {
......
......@@ -211,7 +211,7 @@ public class PhysicStorageAmpouleServiceImpl extends AbstractService implements
public PhysicStorageAmpoule sign(PhysicStorageAmpouleSignReq physicStorageAmpouleSignReq) {
boolean finished = false;
Long userId = SpringContextUtils.getUserId();
String getstamp = cloudsignService.sign(physicStorageAmpouleSignReq.getEncryptedToken(), physicStorageAmpouleSignReq.getRelBizNo(), physicStorageAmpouleSignReq.getBase64SourceData());
String getstamp = cloudsignService.sign(physicStorageAmpouleSignReq.getBase64SourceData());
PhysicStorageAmpoule ampoule = getInfo(physicStorageAmpouleSignReq.getPhysicStorageAmpouleId());
if(ampoule.getType()==2 && ampoule.getDestroyStatus()==1){
throw new ServiceException("已销毁记录不需要签名");
......
......@@ -91,7 +91,7 @@ public class PhysicWarehouseServiceImpl extends AbstractService implements Phys
public PhysicWarehouseVO sign(PhysicWarehouseSignReq physicWarehouseSignReq) {
boolean finished = false;
Long userId = SpringContextUtils.getUserId();
String getstamp = cloudsignService.sign(physicWarehouseSignReq.getEncryptedToken(), physicWarehouseSignReq.getRelBizNo(), physicWarehouseSignReq.getBase64SourceData());
String getstamp = cloudsignService.sign(physicWarehouseSignReq.getBase64SourceData());
PhysicWarehouse physicWarehouse = physicWarehouseMapper.selectById(physicWarehouseSignReq.getPhysicWarehouseId());
SysUser sysUser = sysUserMapper.selectById(userId);
if(physicWarehouse.getStatus().equals(0)){
......
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