新增了放心签

This commit is contained in:
wucongxing8150 2025-06-28 17:13:12 +08:00
parent 2d06128915
commit aeef91e357
29 changed files with 1428 additions and 81 deletions

View File

@ -15,6 +15,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@ -44,6 +45,7 @@ public class Base {
public String postJson(String url, String jsonData, Map<String, String> headers) {
// 获取token
String tokenKey = "fangxinqian:" + clientId;
redisTemplate.delete(tokenKey);
String token = redisTemplate.opsForValue().get(tokenKey);
if (token == null) {
token = getAccessToken();
@ -104,25 +106,9 @@ public class Base {
}
String tokenKey = "fangxinqian:" + clientId;
redisTemplate.opsForValue().set(tokenKey,accessToken,(expiresIn - 120));
redisTemplate.opsForValue().set(tokenKey,accessToken,(expiresIn - 120), TimeUnit.SECONDS);
return accessToken;
}
}
public class R
{
/** 接口调用状态。200正常其它值调用出错 */
private int code;
/** 结果说明。如果接口调用出错,那么返回错误描述。成功则返回 ok */
private String msg;
/** 接口是否调用成功 */
private boolean success;
/** 错误信息或提示信息 */
private String message;
}
}

View File

@ -1,12 +0,0 @@
package net.lab1024.sa.admin.extend.fangxinqian;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 个人账号
*/
@Slf4j
@Component
public class Personal extends Base {
}

View File

@ -19,16 +19,18 @@ import java.util.Objects;
@Component
public class Company extends Base {
/**
* 添加账号(个人账号未创建)
* 添加账号(个人账号已创建)-企业
*/
public RegisterPResponse registerPResponse(){
public RegisterPResponse registerCResponse(String managerUnionId){
// 处理参数
Map<String, Object> requestData = new HashMap<>();
requestData.put("uid", "duanshuli"); // 接入方系统中用户的标识
requestData.put("mobile", "18601047315");
requestData.put("uid", "bjyykxjsfzxh"); // 接入方系统中用户的标识
requestData.put("managerUnionId", managerUnionId); // 个人唯一性标识
requestData.put("orgName", "北京医药科学技术发展协会");
requestData.put("creditNo", "51110000500308634E");
requestData.put("legalName", "侯新晖");
String url = getClientUrl() + "company/register2p1";
String url = getClientUrl() + "company/register";
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);

View File

@ -12,7 +12,7 @@ public class RegisterPResponse {
private String message;
private List<GetRegisterPData> data;
private GetRegisterPData data;
private String requestId;

View File

@ -0,0 +1,68 @@
package net.lab1024.sa.admin.extend.fangxinqian.personal;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.admin.extend.fangxinqian.Base;
import net.lab1024.sa.common.common.exception.BusinessException;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* 个人账号
*/
@Slf4j
@Component
public class Personal extends Base {
/**
* 添加账号
*/
public RegisterResponse register(RegisterRequest r){
String url = getClientUrl() + "personal/register";
String jsonBody = JSONUtil.toJsonStr(r);
log.info("获取app数据参数:{}",jsonBody);
String response = postJson(url,jsonBody,null);
RegisterResponse result = JSONUtil.toBean(response, RegisterResponse.class);
if (result.getCode() != 10000){
if (result.getCode() == 50005){
return result;
}
if (!Objects.equals(result.getMessage(), "")){
throw new BusinessException(result.getMessage());
}else{
throw new BusinessException("失败");
}
}
return result;
}
/**
* 查询账号
*/
public QueryResponse query(String uid,String mobile){
String url = getClientUrl() + "personal/query";
Map<String, Object> requestData = new HashMap<>();
requestData.put("uid", uid); // 接入方系统中用户的标识
requestData.put("mobile", mobile); // 接入方系统中用户的标识
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);
String response = postJson(url,jsonBody,null);
QueryResponse result = JSONUtil.toBean(response, QueryResponse.class);
if (result.getCode() != 10000){
if (!Objects.equals(result.getMessage(), "")){
throw new BusinessException(result.getMessage());
}else{
throw new BusinessException("失败");
}
}
return result;
}
}

View File

@ -0,0 +1,45 @@
package net.lab1024.sa.admin.extend.fangxinqian.personal;
import lombok.Data;
@Data
public class QueryResponse {
private int code;
private String message;
private queryData data;
private String requestId;
/**
* 根据统一标签列表 - 详细数据
*/
@Data
public static class queryData {
/**
* 实名注册H5链接
*/
private String uid;
/**
* 实名注册PC链接
*/
private String unionId;
/**
* 认证状态认证成功/认证中
*/
private String status;
/**
* 认证状态码
* 0-未认证
* 1-认证中
* 2-已认证
*/
private String statusCode;
}
}

View File

@ -0,0 +1,41 @@
package net.lab1024.sa.admin.extend.fangxinqian.personal;
import lombok.Data;
@Data
public class RegisterRequest {
/**
* 接入方系统中用户的标识需保证在接入方系统内唯一长度为8-20个字符
*/
private String uid;
/**
* 创建账号所用的手机号码
*/
private String mobile;
/**
* 个人实名认证方案默认为1
* 1全网三要素姓名身份证号实名手机号
* 2银行卡四要素姓名身份证号银行卡号银行预留手机号
* -1创建账号时不实名认证平台会在其签署前触发实名认证也可以请求"独立认证页获取"接口来进行实名认证
*/
private String authType = "1";
/**
* 证件号码
*/
private String identNo;
/**
* 真实姓名
*/
private String name;
/**
* 是否允许用户修改认证页代入信息
* 0不允许
* 1允许默认
*/
private String allowModify = "0";
}

View File

@ -0,0 +1,42 @@
package net.lab1024.sa.admin.extend.fangxinqian.personal;
import lombok.Data;
@Data
public class RegisterResponse {
private int code;
private String message;
private GetRegisterData data;
private String requestId;
/**
* 根据统一标签列表 - 详细数据
*/
@Data
public static class GetRegisterData {
/**
* 实名注册H5链接
*/
private String h5Url;
/**
* 实名注册PC链接
*/
private String pcUrl;
/**
* 接入方用户唯一标识
*/
private String uid;
/**
* 个人在放心签平台与接入方关联的唯一性标识
*/
private String unionId;
}
}

View File

@ -0,0 +1,77 @@
package net.lab1024.sa.admin.extend.fangxinqian.task;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class AddTemplateTaskRequest {
/**
* 个人/企业主体在放心签平台与接入方关联的唯一性标识发起方账号
*/
private String unionId;
/**
* 签署模板编号
*/
private String templateNo;
/**
* 签署完成回调推送地址
* 签署任务中的每一位签署方签署成功以后都会推送
*/
private String notifyUrl = "www.baidu.com";
/**
* 签署方列表
*/
private List<signersData> signers;
/**
* 签署任务标题(长度最大值默认为50字符)
*/
private String taskTitle = "合作协议";
/**
* 签署完成后跳转地址不传则停留在放心签的页面
*/
private String redirectUrl = "/pages/index/index";
/**
* 关键词替换
*/
private List<componentsData> components;
/**
* 详细数据-签署方列表
*/
@Data
public static class signersData {
/**
* 参与方别名标识"获取已配置的签署模版"接口返回参数中获取
*/
private String signerNo;
/**
* 个人/企业主体在放心签平台与接入方关联的唯一性标识 签署方账号
*/
private String signerUnionId;
}
/**
* 详细数据-关键词替换
*/
@Data
public static class componentsData {
/**
* 替换参数对应saas平台控件编码
*/
private String fileKey;
/**
* 替换内容
*/
private String fileValue;
}
}

View File

@ -0,0 +1,28 @@
package net.lab1024.sa.admin.extend.fangxinqian.task;
import lombok.Data;
import java.util.List;
@Data
public class AddTemplateTaskResponse {
private int code;
private String message;
private AddTemplateTaskData data;
private String requestId;
/**
* 详细数据
*/
@Data
public static class AddTemplateTaskData {
/**
* 签署任务编号
*/
private String taskNo;
}
}

View File

@ -0,0 +1,88 @@
package net.lab1024.sa.admin.extend.fangxinqian.task;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.admin.extend.fangxinqian.Base;
import net.lab1024.sa.common.common.exception.BusinessException;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Component
public class FxqTask extends Base {
/**
* 获取已配置的签署模版
*/
public GetTemplateListResponse getTemplateList(String unionId){
String url = getClientUrl() + "file/templates";
Map<String, Object> requestData = new HashMap<>();
requestData.put("unionId", unionId); // 个人/企业主体在放心签平台与接入方关联的唯一性标识发起方账号
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);
String response = postJson(url,jsonBody,null);
GetTemplateListResponse result = JSONUtil.toBean(response, GetTemplateListResponse.class);
if (result.getCode() != 10000){
if (!Objects.equals(result.getMessage(), "")){
throw new BusinessException(result.getMessage());
}else{
throw new BusinessException("失败");
}
}
return result;
}
/**
* 获取签署链接
*/
public GetTaskLinkResponse getTaskLink(String taskNo, String unionId){
String url = getClientUrl() + "sign/task/link";
Map<String, Object> requestData = new HashMap<>();
requestData.put("taskNo", taskNo); // 签署任务编号创建签署任务时生成
requestData.put("unionId", unionId); // 个人/企业在放心签平台的唯一性标识签署方账号
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);
String response = postJson(url,jsonBody,null);
GetTaskLinkResponse result = JSONUtil.toBean(response, GetTaskLinkResponse.class);
if (result.getCode() != 10000){
if (!Objects.equals(result.getMessage(), "")){
throw new BusinessException(result.getMessage());
}else{
throw new BusinessException("失败");
}
}
return result;
}
/**
* 模版签署任务创建
*/
public AddTemplateTaskResponse addTemplateTask(AddTemplateTaskRequest r){
String url = getClientUrl() + "sign/template_task/create";
String jsonBody = JSONUtil.toJsonStr(r);
log.info("获取app数据参数:{}",jsonBody);
String response = postJson(url,jsonBody,null);
AddTemplateTaskResponse result = JSONUtil.toBean(response, AddTemplateTaskResponse.class);
if (result.getCode() != 10000){
if (!Objects.equals(result.getMessage(), "")){
throw new BusinessException(result.getMessage());
}else{
throw new BusinessException("失败");
}
}
return result;
}
}

View File

@ -0,0 +1,77 @@
package net.lab1024.sa.admin.extend.fangxinqian.task;
import lombok.Data;
import java.util.List;
@Data
public class GetTaskLinkResponse {
private int code;
private String message;
private GetTaskLinkData data;
private String requestId;
/**
* 详细数据
*/
@Data
public static class GetTaskLinkData {
/**
* 签署详情
*/
private List<taskDetailsData> taskDetails;
/**
* 签署任务编号
*/
private String taskNo;
}
/**
* 详细数据-签署详情
*/
@Data
public static class taskDetailsData {
/**
* 签署链接(H5)
*/
private String signH5Url;
/**
* 签署链接(PC)
*/
private String signPCUrl;
/**
* 签署状态
* 1可签署
* 2已签署
* 3拒绝签署
* 9不可签署用于顺序签
*/
private String signStatus;
/**
* 签署顺序
*/
private String sortNum;
/**
* 签署顺序模式
* 1有序
* 2无序
*/
private String sortType;
/**
* 个人/企业在放心签平台的唯一性标识签署方账号
*/
private String unionId;
}
}

View File

@ -0,0 +1,85 @@
package net.lab1024.sa.admin.extend.fangxinqian.task;
import lombok.Data;
import java.util.List;
@Data
public class GetTemplateListResponse {
private int code;
private String message;
private List<GetTemplateListData> data;
private String requestId;
/**
* 详细数据
*/
@Data
public static class GetTemplateListData {
/**
* 参与方
*/
private List<signersData> signers;
/**
* 签署模板编号
*/
private String templateNo;
/**
* 签署模板标题
*/
private String title;
}
/**
* 详细数据 -参与方
*/
@Data
public static class signersData {
/**
* 编辑顺序
*/
private Integer fillOrder;
/**
* 编辑权限 true or false
*/
private boolean fillRole;
/**
* 参与方别名
*/
private String label;
/**
* 是否平台自动落章 true or false
*/
private boolean platFormSign;
/**
* 签署顺序
*/
private Integer signOrder;
/**
* 签署权限 true or false
*/
private boolean signRole;
/**
* 参与方别名标识
*/
private String signerNo;
/**
* 参与方类型 1-个人2-企业
*/
private Integer type;
}
}

View File

@ -3,20 +3,29 @@ package net.lab1024.sa.admin.module.app.expert.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
import net.lab1024.sa.admin.extend.fangxinqian.task.GetTaskLinkResponse;
import net.lab1024.sa.admin.module.app.expert.admin.*;
import net.lab1024.sa.admin.module.app.expert.dao.FxqExpertTaskDao;
import net.lab1024.sa.admin.module.app.expert.dao.FxqUserDao;
import net.lab1024.sa.admin.module.app.expert.domain.entity.FxqCompanyEntity;
import net.lab1024.sa.admin.module.app.expert.domain.entity.FxqExpertTaskEntity;
import net.lab1024.sa.admin.module.app.expert.domain.entity.FxqTemplateEntity;
import net.lab1024.sa.admin.module.app.expert.domain.entity.FxqUserEntity;
import net.lab1024.sa.admin.module.app.expert.domain.vo.AddFxqVo;
import net.lab1024.sa.admin.module.app.expert.domain.vo.GetExpertSignVo;
import net.lab1024.sa.admin.module.app.expert.service.ExpertFxqService;
import net.lab1024.sa.admin.module.app.expert.service.ExpertService;
import net.lab1024.sa.admin.module.app.expert.service.ExpertWhiteEntityService;
import net.lab1024.sa.admin.module.app.medicalrecord.dao.MedicalRecorDao;
import net.lab1024.sa.admin.module.business.area.domain.vo.ProvVO;
import net.lab1024.sa.admin.module.business.area.service.AreaService;
import net.lab1024.sa.admin.module.business.bankcard.domain.form.CaseplatformBankAddForm;
import net.lab1024.sa.admin.module.business.captcha.service.CaptchaService;
import net.lab1024.sa.admin.module.system.login.service.LoginService;
import net.lab1024.sa.common.common.annoation.NoNeedLogin;
@ -31,8 +40,10 @@ import net.lab1024.sa.common.module.support.config.ConfigService;
import net.lab1024.sa.common.module.support.config.domain.ConfigVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Valid;
@ -40,6 +51,9 @@ import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import com.alibaba.fastjson.JSONObject;
import static net.lab1024.sa.common.common.code.UserErrorCode.*;
@ -50,6 +64,15 @@ public class ExpertFxqController {
@Resource
private FxqExpertTaskDao fxqExpertTaskDao;
@Resource
private ExpertFxqService expertFxqService;
@Resource
private RedisTemplate<String, String> redisTemplate;
@Resource
private FxqUserDao fxqUserDao;
/**
* 获取专家协议签署详情
*/
@ -80,33 +103,29 @@ public class ExpertFxqController {
return ResponseDTO.app_ok(g);
}
// /**
// * 放心签认证
// */
// @ApiOperation(value = "获取专家协议签署详情")
// @GetMapping("/expert/sign")
// public ResponseDTO<GetExpertSignVo> getExpertSign() {
// Long expertId = SmartRequestUtil.getRequestUserId();
// if (expertId == null) {
// return ResponseDTO.error(LOGIN_STATE_INVALID);
// }
//
// GetExpertSignVo g = new GetExpertSignVo();
// g.setTaskStatus(2);
//
// // 获取协议签署情况
// LambdaQueryWrapper<FxqExpertTaskEntity> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(FxqExpertTaskEntity::getExpertId, expertId);
// FxqExpertTaskEntity fxqExpertTask = fxqExpertTaskDao.selectOne(queryWrapper);
// if (fxqExpertTask == null) {
// return ResponseDTO.app_ok(g);
// }
//
// if (fxqExpertTask.getTaskStatus() == 20){
// g.setTaskStatus(1);
// g.setTaskFileUrl(fxqExpertTask.getTaskFileUrl());
// }
//
// return ResponseDTO.app_ok(g);
// }
/**
* 放心签认证
*/
@ApiOperation(value = "放心签认证")
@PostMapping("/expert/fxq")
public ResponseDTO<AddFxqVo> addFxq() {
Long expertId = SmartRequestUtil.getRequestUserId();
if (expertId == null) {
return ResponseDTO.error(LOGIN_STATE_INVALID);
}
// 获取企业放心签实名认证数据
FxqCompanyEntity company = expertFxqService.getCompany();
// 获取个人放心签实名认证数据
FxqUserEntity fxqUser = expertFxqService.getPersonal(expertId);
// 获取签署的模版数据
FxqTemplateEntity fxqTemplate = expertFxqService.getTemplate(company.getId());
// 模版签署任务创建
AddFxqVo fxqExpertTask = expertFxqService.addTemplateTask(company,fxqUser,fxqTemplate);
return ResponseDTO.app_ok(fxqExpertTask);
}
}

View File

@ -0,0 +1,14 @@
package net.lab1024.sa.admin.module.app.expert.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lab1024.sa.admin.module.app.expert.admin.ExpertSignVO;
import net.lab1024.sa.admin.module.app.expert.admin.ExpertWhiteEntity;
import net.lab1024.sa.admin.module.app.expert.domain.entity.FxqCompanyEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
@Mapper
@Component
public interface FxqCompanyDao extends BaseMapper<FxqCompanyEntity> {
}

View File

@ -0,0 +1,13 @@
package net.lab1024.sa.admin.module.app.expert.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lab1024.sa.admin.module.app.expert.domain.entity.FxqCompanyEntity;
import net.lab1024.sa.admin.module.app.expert.domain.entity.FxqTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
@Mapper
@Component
public interface FxqTemplateDao extends BaseMapper<FxqTemplateEntity> {
}

View File

@ -0,0 +1,13 @@
package net.lab1024.sa.admin.module.app.expert.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lab1024.sa.admin.module.app.expert.domain.entity.FxqCompanyEntity;
import net.lab1024.sa.admin.module.app.expert.domain.entity.FxqUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
@Mapper
@Component
public interface FxqUserDao extends BaseMapper<FxqUserEntity> {
}

View File

@ -0,0 +1,52 @@
package net.lab1024.sa.admin.module.app.expert.domain.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 病例-放心签-公司主体实体类
*/
@TableName("`t_caseplatform_fxq_company`")
@Data
public class FxqCompanyEntity {
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 注册名
*/
@TableField("name")
private String name;
/**
* 接入方用户唯一标识
*/
@TableField("uid")
private String uid;
/**
* 企业主体在放心签平台与接入方关联的唯一性标识
*/
@TableField("union_id")
private String unionId;
/**
* 创建时间
*/
@TableField("create_time")
private LocalDateTime createTime;
/**
* 修改时间
*/
@TableField("update_time")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,70 @@
package net.lab1024.sa.admin.module.app.expert.domain.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 病例-放心签-签署模板实体类
*/
@TableName("`t_caseplatform_fxq_template`")
@Data
public class FxqTemplateEntity {
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 公司id
*/
@TableField("company_id")
private Long companyId;
/**
* 签署模板编号
*/
@TableField("template_no")
private String templateNo;
/**
* 签署模板标题
*/
@TableField("title")
private String title;
/**
* 参与方别名标识-企业
*/
@TableField("company_signer_no")
private String companySignerNo;
/**
* 参与方别名标识-个人
*/
@TableField("personal_signer_no")
private String personalSignerNo;
/**
* 模板数据
*/
@TableField("content")
private String content;
/**
* 创建时间
*/
@TableField("create_time")
private LocalDateTime createTime;
/**
* 修改时间
*/
@TableField("update_time")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,58 @@
package net.lab1024.sa.admin.module.app.expert.domain.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 病例-放心签-签署专家主体实体类
*/
@TableName("`t_caseplatform_fxq_user`")
@Data
public class FxqUserEntity {
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 专家id
*/
@TableField("expert_id")
private Long expertId;
/**
* 注册名
*/
@TableField("name")
private String name;
/**
* 接入方用户唯一标识
*/
@TableField("uid")
private String uid;
/**
* 个人在放心签平台与接入方关联的唯一性标识
*/
@TableField("union_id")
private String unionId;
/**
* 创建时间
*/
@TableField("create_time")
private LocalDateTime createTime;
/**
* 修改时间
*/
@TableField("update_time")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,15 @@
package net.lab1024.sa.admin.module.app.expert.domain.form;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class AddFxqForm {
@ApiModelProperty("UUID")
@NotBlank(message = "UUID 不能为空")
private String uuid;
}

View File

@ -0,0 +1,16 @@
package net.lab1024.sa.admin.module.app.expert.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AddFxqVo {
/**
* 签署状态1已签署 2未签署
*/
@ApiModelProperty(value = "签署状态", required = true)
private Integer taskStatus;
@ApiModelProperty(value = "链接地址", required = true)
private String linkUrl;
}

View File

@ -0,0 +1,31 @@
package net.lab1024.sa.admin.module.app.expert.domain.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class FxqCompanyVo {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "注册名")
private String name;
@ApiModelProperty(value = "接入方用户唯一标识")
private String uid;
@ApiModelProperty(value = "企业主体在放心签平台与接入方关联的唯一性标识")
private String unionId;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,40 @@
package net.lab1024.sa.admin.module.app.expert.domain.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class FxqExpertTaskVo {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "专家id")
private Long expertId;
@ApiModelProperty(value = "签署编号")
private String taskNo;
@ApiModelProperty(value = "签署模板id")
private Long templateId;
@ApiModelProperty(value = "签署任务状态:-30已过期-20已撤销-10已拒签0发起签署5待编辑10待签署20已完成")
private Integer taskStatus;
@ApiModelProperty(value = "签署完成时间")
private LocalDateTime signTime;
@ApiModelProperty(value = "签署协议的预览地址(只有签署成功后才存在)")
private String taskFileUrl;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,37 @@
package net.lab1024.sa.admin.module.app.expert.domain.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class FxqTemplateVo {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "公司id")
private Long companyId;
@ApiModelProperty(value = "签署模板编号")
private String templateNo;
@ApiModelProperty(value = "签署模板标题")
private String title;
@ApiModelProperty(value = "参与方别名标识")
private String signerNo;
@ApiModelProperty(value = "模板数据")
private String content;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,33 @@
package net.lab1024.sa.admin.module.app.expert.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class FxqUserVo {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "专家id")
private Long expertId;
@ApiModelProperty(value = "注册名")
private String name;
@ApiModelProperty(value = "接入方用户唯一标识")
private String uid;
@ApiModelProperty(value = "个人在放心签平台与接入方关联的唯一性标识")
private String unionId;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,391 @@
package net.lab1024.sa.admin.module.app.expert.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import net.lab1024.sa.admin.extend.fangxinqian.company.Company;
import net.lab1024.sa.admin.extend.fangxinqian.company.RegisterPResponse;
import net.lab1024.sa.admin.extend.fangxinqian.personal.Personal;
import net.lab1024.sa.admin.extend.fangxinqian.personal.QueryResponse;
import net.lab1024.sa.admin.extend.fangxinqian.personal.RegisterRequest;
import net.lab1024.sa.admin.extend.fangxinqian.personal.RegisterResponse;
import net.lab1024.sa.admin.extend.fangxinqian.task.*;
import net.lab1024.sa.admin.module.app.expert.admin.ExpertEntity;
import net.lab1024.sa.admin.module.app.expert.dao.*;
import net.lab1024.sa.admin.module.app.expert.domain.entity.*;
import net.lab1024.sa.admin.module.app.expert.domain.vo.AddFxqVo;
import net.lab1024.sa.common.common.domain.ResponseDTO;
import net.lab1024.sa.common.common.exception.BusinessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service
public class ExpertFxqService {
@Resource
private FxqCompanyDao fxqCompanyDao;
@Resource
private ExpertDao expertDao;
@Resource
private FxqUserDao fxqUserDao;
@Resource
private Company company;
@Resource
private Personal personal;
@Resource
private CasePlatformBankDao casePlatformBankDao;
@Resource
private FxqTemplateDao fxqTemplateDao;
@Resource
private FxqTask fxqTask;
@Resource
private FxqExpertTaskDao fxqExpertTaskDao;
/**
* 获取企业放心签实名认证数据
*/
@Transactional
public FxqCompanyEntity getCompany(){
try {
// 获取企业实名认证数据-个人
LambdaQueryWrapper<FxqCompanyEntity> personalQueryWrapper = new LambdaQueryWrapper<>();
personalQueryWrapper.eq(FxqCompanyEntity::getUid, "houxinhui");
FxqCompanyEntity personalFxqCompany = fxqCompanyDao.selectOne(personalQueryWrapper);
if (personalFxqCompany == null) {
// 个人实名认证
RegisterRequest r = new RegisterRequest();
r.setUid("houxinhui");
r.setName("侯新晖");
r.setMobile("18610396804");
r.setIdentNo("412901197202131005");
RegisterResponse personalRegister = personal.register(r);
if (personalRegister.getData() == null) {
throw new BusinessException("操作失败");
}
// 添加数据库
FxqCompanyEntity fxqCompanyData = new FxqCompanyEntity();
fxqCompanyData.setName("侯新晖");
fxqCompanyData.setUid("houxinhui");
fxqCompanyData.setUnionId(personalRegister.getData().getUnionId());
fxqCompanyData.setCreateTime(LocalDateTime.now());
int res = fxqCompanyDao.insert(fxqCompanyData);
if (res <= 0){
throw new BusinessException("操作失败");
}
personalFxqCompany = fxqCompanyData;
}
// 获取企业实名认证数据-公司
LambdaQueryWrapper<FxqCompanyEntity> companyQueryWrapper = new LambdaQueryWrapper<>();
companyQueryWrapper.eq(FxqCompanyEntity::getUid, "bjyykxjsfzxh");
FxqCompanyEntity companyFxqCompany = fxqCompanyDao.selectOne(companyQueryWrapper);
if (companyFxqCompany == null) {
RegisterPResponse registerP = company.registerCResponse(personalFxqCompany.getUnionId());
if (registerP.getData() == null) {
throw new BusinessException("操作失败");
}
// 添加数据库
FxqCompanyEntity fxqCompanyData = new FxqCompanyEntity();
fxqCompanyData.setName("北京医药科学技术发展协会");
fxqCompanyData.setUid("bjyykxjsfzxh");
fxqCompanyData.setUnionId(registerP.getData().getUnionId());
fxqCompanyData.setCreateTime(LocalDateTime.now());
int res = fxqCompanyDao.insert(fxqCompanyData);
if (res <= 0){
throw new BusinessException("操作失败");
}
companyFxqCompany = fxqCompanyData;
}
return companyFxqCompany;
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
}
/**
* 获取个人放心签实名认证数据
*/
@Transactional
public FxqUserEntity getPersonal(Long expertId){
try {
// 获取专家信息
ExpertEntity expert = expertDao.getExpert(expertId);
if (expert == null) {
throw new BusinessException("操作失败");
}
// 获取企业实名认证数据-个人
LambdaQueryWrapper<FxqUserEntity> personalQueryWrapper = new LambdaQueryWrapper<>();
personalQueryWrapper.eq(FxqUserEntity::getExpertId, expertId);
FxqUserEntity fxqUser = fxqUserDao.selectOne(personalQueryWrapper);
if (fxqUser == null) {
// 获取个人银行卡信息
LambdaQueryWrapper<CasePlatformBankEntity> bankQueryWrapper = new LambdaQueryWrapper<>();
bankQueryWrapper.eq(CasePlatformBankEntity::getExpertId, expertId);
CasePlatformBankEntity casePlatformBank = casePlatformBankDao.selectOne(bankQueryWrapper);
if (casePlatformBank == null) {
throw new BusinessException("请绑定银行卡后重试");
}
RegisterRequest r = new RegisterRequest();
String uid = String.format("%010d",casePlatformBank.getExpertId());
r.setUid(uid);
r.setName(casePlatformBank.getIdCardName());
r.setMobile(expert.getMobile());
r.setIdentNo(casePlatformBank.getIdCardNo());
RegisterResponse personalRegister = personal.register(r);
String unionId = "";
if (personalRegister.getCode() == 50005){
// 账号在放心签已存在
QueryResponse personalQuery = personal.query(uid,expert.getMobile());
if (personalQuery.getData() == null) {
throw new BusinessException("实名认证失败");
}
unionId = personalQuery.getData().getUnionId();
}else{
if (personalRegister.getData() == null) {
throw new BusinessException("实名认证失败");
}
unionId = personalRegister.getData().getUnionId();
}
// 添加数据库
FxqUserEntity fxqUserData = new FxqUserEntity();
fxqUserData.setExpertId(casePlatformBank.getExpertId());
fxqUserData.setName(casePlatformBank.getIdCardName());
fxqUserData.setUid(uid);
fxqUserData.setUnionId(unionId);
fxqUserData.setCreateTime(LocalDateTime.now());
int res = fxqUserDao.insert(fxqUserData);
if (res <= 0){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return null;
}
fxqUser = fxqUserData;
}
return fxqUser;
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
}
/**
* 获取签署的模版数据
* 这里只会有一个模版获取第一个
*/
@Transactional
public FxqTemplateEntity getTemplate(Long companyId){
try {
// 获取企业实名认证数据-公司
LambdaQueryWrapper<FxqCompanyEntity> companyQueryWrapper = new LambdaQueryWrapper<>();
companyQueryWrapper.eq(FxqCompanyEntity::getUid, "bjyykxjsfzxh");
FxqCompanyEntity companyFxqCompany = fxqCompanyDao.selectOne(companyQueryWrapper);
if (companyFxqCompany == null) {
throw new BusinessException("操作失败");
}
// 获取数据库模版数据
LambdaQueryWrapper<FxqTemplateEntity> templateQueryWrapper = new LambdaQueryWrapper<>();
templateQueryWrapper.eq(FxqTemplateEntity::getCompanyId, companyId);
templateQueryWrapper.eq(FxqTemplateEntity::getId, 1);
FxqTemplateEntity fxqTemplate = fxqTemplateDao.selectOne(templateQueryWrapper);
if (fxqTemplate == null) {
// 获取企业模版数据
GetTemplateListResponse templateList = fxqTask.getTemplateList(companyFxqCompany.getUnionId());
if (templateList.getData() == null || templateList.getData().isEmpty()) {
throw new BusinessException("操作失败");
}
for (GetTemplateListResponse.GetTemplateListData data : templateList.getData()) {
if (data.getSigners() == null || data.getSigners().isEmpty()) {
throw new BusinessException("操作失败");
}
String companySignerNo = "";
String personalSignerNo = "";
// 获取参与方别名标识
for (GetTemplateListResponse.signersData signersData : data.getSigners()) {
if (Objects.equals(signersData.getLabel(), "北京医药科学技术发展协会")){
companySignerNo = signersData.getSignerNo();
}
if (Objects.equals(signersData.getLabel(), "个人")){
personalSignerNo = signersData.getSignerNo();
}
}
if (Objects.equals(companySignerNo, "") || Objects.equals(personalSignerNo, "")){
throw new BusinessException("操作失败");
}
FxqTemplateEntity fxqTemplateData = new FxqTemplateEntity();
fxqTemplateData.setCompanyId(companyId);
fxqTemplateData.setTemplateNo(data.getTemplateNo());
fxqTemplateData.setTitle(data.getTitle());
fxqTemplateData.setCompanySignerNo(companySignerNo);
fxqTemplateData.setPersonalSignerNo(personalSignerNo);
fxqTemplateData.setContent(templateList.getData().toString());
fxqTemplateData.setCreateTime(LocalDateTime.now());
int res = fxqTemplateDao.insert(fxqTemplateData);
if (res <= 0){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return null;
}
// 把第一条数据赋值出去
if (fxqTemplate == null) {
fxqTemplate = fxqTemplateData;
}
}
}
return fxqTemplate;
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
}
/**
* 获取签署链接
*/
public GetTaskLinkResponse.taskDetailsData getTaskLink(String taskNo, String unionId){
GetTaskLinkResponse taskLink = fxqTask.getTaskLink(taskNo,unionId);
if (taskLink.getData() == null) {
throw new BusinessException("操作失败");
}
if (taskLink.getData().getTaskDetails() == null || taskLink.getData().getTaskDetails().isEmpty()) {
throw new BusinessException("操作失败");
}
return taskLink.getData().getTaskDetails().get(0);
}
/**
* 模版签署任务创建
*/
@Transactional
public AddFxqVo addTemplateTask(FxqCompanyEntity company, FxqUserEntity fxqUser, FxqTemplateEntity fxqTemplate){
try {
AddFxqVo g = new AddFxqVo();
// 签署编号
String taskNo = "";
LambdaQueryWrapper<FxqExpertTaskEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(FxqExpertTaskEntity::getExpertId, fxqUser.getExpertId());
queryWrapper.in(FxqExpertTaskEntity::getTaskStatus, 0,10,20);
FxqExpertTaskEntity fxqExpertTask = fxqExpertTaskDao.selectOne(queryWrapper);
if (fxqExpertTask != null) {
// 已完成
if (fxqExpertTask.getTaskStatus() == 20) {
g.setTaskStatus(1);
return g;
}
if (fxqExpertTask.getTaskStatus() == 10 || fxqExpertTask.getTaskStatus() == 0){
taskNo = fxqExpertTask.getTaskNo();
}
}
if (Objects.equals(taskNo, "")){
AddTemplateTaskRequest r = new AddTemplateTaskRequest();
r.setUnionId(company.getUnionId());
r.setTemplateNo(fxqTemplate.getTemplateNo());
// 初始化 signers 列表
List<AddTemplateTaskRequest.signersData> signersList = new ArrayList<>();
AddTemplateTaskRequest.signersData signer = new AddTemplateTaskRequest.signersData();
signer.setSignerNo(fxqTemplate.getCompanySignerNo());
signer.setSignerUnionId(company.getUnionId());
signersList.add(signer);
signer = new AddTemplateTaskRequest.signersData();
signer.setSignerNo(fxqTemplate.getPersonalSignerNo());
signer.setSignerUnionId(fxqUser.getUnionId());
signersList.add(signer);
r.setSigners(signersList);
// 初始化 components 列表
List<AddTemplateTaskRequest.componentsData> componentsList = new ArrayList<>();
AddTemplateTaskRequest.componentsData components = new AddTemplateTaskRequest.componentsData();
components.setFileKey("doctorName");
components.setFileValue(fxqUser.getName());
componentsList.add(components);
r.setComponents(componentsList);
AddTemplateTaskResponse templateTask = fxqTask.addTemplateTask(r);
if (templateTask.getData() == null) {
throw new BusinessException("操作失败");
}
if (templateTask.getData().getTaskNo() == null || templateTask.getData().getTaskNo().isEmpty()) {
throw new BusinessException("操作失败");
}
// 添加数据库
FxqExpertTaskEntity fxqExpertTaskData = new FxqExpertTaskEntity();
fxqExpertTaskData.setExpertId(fxqUser.getExpertId());
fxqExpertTaskData.setTaskNo(templateTask.getData().getTaskNo());
fxqExpertTaskData.setTemplateId(fxqTemplate.getId());
fxqExpertTaskData.setTaskStatus(0);
fxqExpertTaskData.setCreateTime(LocalDateTime.now());
int res = fxqExpertTaskDao.insert(fxqExpertTaskData);
if (res <= 0){
throw new BusinessException("操作失败");
}
taskNo = templateTask.getData().getTaskNo();
}
if (Objects.equals(taskNo, "")){
throw new BusinessException("操作失败");
}
// 获取签署链接
GetTaskLinkResponse.taskDetailsData fxqLink = getTaskLink(taskNo,fxqUser.getUnionId());
if (fxqLink == null) {
throw new BusinessException("操作失败");
}
// 已签署
if (Objects.equals(fxqLink.getSignStatus(), "2")){
g.setTaskStatus(1);
return g;
} else if (Objects.equals(fxqLink.getSignStatus(), "1")) {
// 可签署
g.setTaskStatus(1);
g.setLinkUrl(fxqLink.getSignH5Url());
return g;
} else{
throw new BusinessException("签署状态错误");
}
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
}
}

View File

@ -1,16 +1,24 @@
package net.lab1024.sa.common.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import javax.annotation.Resource;
/**
* redis配置
*
@ -20,20 +28,29 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
* @Email lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net
*/
//@Configuration
@Configuration
public class RedisConfig {
@Autowired
@Resource
private RedisConnectionFactory factory;
@Bean
public RedisTemplate<String, Object> redisTemplate() {
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
ObjectMapper om = new ObjectMapper();
om.registerModule(new JavaTimeModule())
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
// enableDefaultTyping 官方已弃用 所以改为 activateDefaultTyping
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(jackson2JsonRedisSerializer);
@ -69,4 +86,5 @@ public class RedisConfig {
return redisTemplate.opsForZSet();
}
}

View File

@ -26,18 +26,18 @@ spring:
matching-strategy: ant_path_matcher
# redis 连接池配置信息
# redis:
# database: 1
# host: 127.0.0.1
# lettuce:
# pool:
# max-active: 5
# min-idle: 1
# max-idle: 3
# max-wait: 30000ms
# port: 6379
# timeout: 10000ms
# password:
redis:
database: 11
host: '139.155.127.177'
lettuce:
pool:
max-active: 5
min-idle: 1
max-idle: 3
max-wait: 30000ms
port: 30002
timeout: 3000
password: gdxz2022&dj.
# 上传文件大小配置
servlet: