Commit 5645ad17 authored by huyuchen's avatar huyuchen

huyc 项目档案代码提交

parent 9c1f2c44
...@@ -19,11 +19,18 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller; ...@@ -19,11 +19,18 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fadada.api.bean.rsp.sign.SignUrlRsp;
import com.fadada.api.exception.ApiException; import com.fadada.api.exception.ApiException;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractAttachInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.FddContractAttachInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.service.FddContractInfoService; import com.yifu.cloud.plus.v1.yifu.archives.service.FddContractInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.utils.FddUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
...@@ -32,6 +39,11 @@ import lombok.RequiredArgsConstructor; ...@@ -32,6 +39,11 @@ import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/** /**
* 法大大合同与员工合同信息 * 法大大合同与员工合同信息
...@@ -48,6 +60,8 @@ public class FddContractInfoController { ...@@ -48,6 +60,8 @@ public class FddContractInfoController {
private final FddContractInfoService fddContractInfoService; private final FddContractInfoService fddContractInfoService;
private final FddContractAttachInfoService fddContractAttachInfoService;
/** /**
* 分页查询 * 分页查询
* @param page 分页对象 * @param page 分页对象
...@@ -123,6 +137,133 @@ public class FddContractInfoController { ...@@ -123,6 +137,133 @@ public class FddContractInfoController {
@SysLog("发送法大大电子合同定稿任务" ) @SysLog("发送法大大电子合同定稿任务" )
@PostMapping("/send") @PostMapping("/send")
public R<String> send(FddContractInfo fddContractInfo) throws ApiException { public R<String> send(FddContractInfo fddContractInfo) throws ApiException {
return fddContractInfoService.saveEmpContract(fddContractInfo); FddContractAttachInfo fddContractAttachInfo = fddContractAttachInfoService.getById(fddContractInfo.getId());
return fddContractInfoService.saveEmpContract(fddContractAttachInfo);
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description:作废重签
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "作废重签", description = "作废重签")
@PostMapping("/invalidAndsend")
public R<String> invalidAndsend(FddContractInfo fddContractInfo) throws ApiException {
return fddContractInfoService.invalidAndsend(fddContractInfo);
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description:公司获取在线定稿地址
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "公司获取在线定稿地址", description = "公司获取在线定稿地址")
@PostMapping("/getCompanyFillFileUrl")
public R<String> getCompanyFillFileUrl(FddContractInfo fddContractInfo) throws ApiException {
return fddContractInfoService.getFillFileUrl(fddContractInfo, FddUtil.COMPANY);
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 员工获取在线定稿地址
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "员工获取在线定稿地址", description = "员工获取在线定稿地址")
@PostMapping("/getPersonFillFileUrl")
public R<String> getPersonFillFileUrl(FddContractInfo fddContractInfo) throws ApiException {
return fddContractInfoService.getFillFileUrl(fddContractInfo, FddUtil.PERSON);
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 引用模板创建签署任务
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "引用模板创建签署任务", description = "引用模板创建签署任务")
@PostMapping("/createTaskByDraftId")
public R<String> createTaskByDraftId(FddContractInfo fddContractInfo) throws ApiException {
//获取法大大电子合同
FddContractInfo entity = fddContractInfoService.getById(fddContractInfo.getId());
if (entity == null) {
return R.failed("未查询到相关记录");
}
YifuUser user = SecurityUtils.getUser();
FddContractAttachInfo fddContractAttachInfo = fddContractAttachInfoService.getOne(Wrappers.<FddContractAttachInfo>query().lambda()
.eq(FddContractAttachInfo::getContractId,entity.getContractId()));
if (!user.getId().equals(fddContractAttachInfo.getCreateBy())) {
return R.failed("当前用户不是电子合同导入用户,不能操作");
}
R<String> returnR = fddContractInfoService.createTaskByDraftId(entity);
if (returnR != null) {
//记录返回信息
if(returnR.getCode()== CommonConstants.SUCCESS){
fddContractInfo.setRemark("成功");
}else {
fddContractInfo.setRemark(returnR.getMsg());
}
}
fddContractInfoService.updateById(fddContractInfo);
return returnR;
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 获取签署链接
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "获取签署链接", description = "获取签署链接")
@PostMapping("/getSignUrl")
public R<Map<String, List<SignUrlRsp>>> getSignUrl(FddContractInfo fddContractInfo) throws ApiException {
return fddContractInfoService.getSignUrl(fddContractInfo);
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 获取签署文件预览地址
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "获取签署文件预览地址", description = "获取签署文件预览地址")
@PostMapping("/getSignPreviewUrl")
public R<String> getSignPreviewUrl(FddContractInfo fddContractInfo) throws ApiException {
return fddContractInfoService.getSignPreviewUrl(fddContractInfo);
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 签署文件下载
**/
@Operation(summary = "签署文件下载", description = "签署文件下载")
@PostMapping("/getBySignFileId")
public void getBySignFileId(FddContractInfo fddContractInfo, HttpServletResponse response) throws ApiException, IOException {
fddContractInfoService.getBySignFileId(fddContractInfo, response);
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 签署文件转移为合同附件
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Operation(summary = "签署文件转移为合同附件", description = "签署文件转移为合同附件")
@PostMapping("/moveFileToEmpConcat")
public R<String> moveFileToEmpConcat(FddContractInfo fddContractInfo, HttpServletResponse response) throws ApiException, IOException {
return fddContractInfoService.moveFileToEmpConcat(fddContractInfo, response);
} }
} }
...@@ -17,12 +17,18 @@ ...@@ -17,12 +17,18 @@
package com.yifu.cloud.plus.v1.yifu.archives.service; package com.yifu.cloud.plus.v1.yifu.archives.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.fadada.api.bean.rsp.sign.SignUrlRsp;
import com.fadada.api.exception.ApiException; import com.fadada.api.exception.ApiException;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractAttachInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/** /**
* 法大大合同与员工合同信息 * 法大大合同与员工合同信息
* *
...@@ -31,5 +37,77 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R; ...@@ -31,5 +37,77 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
*/ */
public interface FddContractInfoService extends IService<FddContractInfo> { public interface FddContractInfoService extends IService<FddContractInfo> {
R<String> saveEmpContract(FddContractInfo fddContractInfo) throws ApiException; /**
* 发送法大大电子合同定稿任务
* @param fddContractInfo 法大大合同信息表
* @Author: huyc
* @Date: 2022/6/30
* @return R
*/
R<String> saveEmpContract(FddContractAttachInfo fddContractInfo) throws ApiException;
/**
* 作废重签
* @param fddContractInfo 法大大合同信息表
* @Author: huyc
* @Date: 2022/6/30
* @return R
*/
R<String> invalidAndsend(FddContractInfo fddContractInfo) throws ApiException;
/**
* 获取在线定稿地址
* @param fddContractInfo
* @param roleName
* @Author: huyc
* @Date: 2022/6/30
* @return R
*/
R<String> getFillFileUrl(FddContractInfo fddContractInfo,String roleName) throws ApiException;
/**
* 引用模板创建签署任务
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @return R
*/
R<String> createTaskByDraftId(FddContractInfo fddContractInfo) throws ApiException;
/**
* 获取签署链接
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @return R
*/
R<Map<String, List<SignUrlRsp>>> getSignUrl(FddContractInfo fddContractInfo) throws ApiException;
/**
* 获取签署链接
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @return R
*/
R<String> getSignPreviewUrl(FddContractInfo fddContractInfo) throws ApiException;
/**
* 获取签署链接
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @return: void
*/
void getBySignFileId(FddContractInfo fddContractInfo, HttpServletResponse response) throws ApiException, IOException;
/**
* 签署文件转移为合同附件
* @param fddContractInfo
* @param response
* @Author: huyc
* @Date: 2022/6/30
* @return: R
**/
R<String> moveFileToEmpConcat(FddContractInfo fddContractInfo, HttpServletResponse response) throws ApiException, IOException;
} }
...@@ -24,16 +24,36 @@ import com.alibaba.fastjson.JSONObject; ...@@ -24,16 +24,36 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fadada.api.bean.req.account.NoticeReq; import com.fadada.api.bean.req.account.NoticeReq;
import com.fadada.api.bean.req.document.GetBySignFileIdReq;
import com.fadada.api.bean.req.revise.CancelReviseTaskReq;
import com.fadada.api.bean.req.revise.CreateReviseTaskReq; import com.fadada.api.bean.req.revise.CreateReviseTaskReq;
import com.fadada.api.bean.req.revise.GetFillFileUrlReq;
import com.fadada.api.bean.req.revise.ReviseTaskDetailReq;
import com.fadada.api.bean.req.sign.CancelSignTaskReq;
import com.fadada.api.bean.req.sign.GetSignPreviewUrlReq;
import com.fadada.api.bean.req.sign.GetSignUrlReq;
import com.fadada.api.bean.req.sign.TaskSenderReq;
import com.fadada.api.bean.req.sign.draft.CreateTaskByDraftIdReq;
import com.fadada.api.bean.rsp.BaseRsp; import com.fadada.api.bean.rsp.BaseRsp;
import com.fadada.api.bean.rsp.document.DownLoadFileRsp;
import com.fadada.api.bean.rsp.revise.CreateReviseTaskRsp; import com.fadada.api.bean.rsp.revise.CreateReviseTaskRsp;
import com.fadada.api.bean.rsp.revise.GetFillFileUrlRsp;
import com.fadada.api.bean.rsp.revise.ReviseTaskDetailRsp;
import com.fadada.api.bean.rsp.sign.CreateTaskByDraftIdRsp;
import com.fadada.api.bean.rsp.sign.GetSignPreviewUrlRsp;
import com.fadada.api.bean.rsp.sign.GetSignUrlRsp;
import com.fadada.api.bean.rsp.sign.SignUrlRsp;
import com.fadada.api.client.DocumentClient;
import com.fadada.api.client.ReviseTaskClient; import com.fadada.api.client.ReviseTaskClient;
import com.fadada.api.client.SignTaskClient;
import com.fadada.api.exception.ApiException; import com.fadada.api.exception.ApiException;
import com.google.common.collect.Maps;
import com.yifu.cloud.plus.v1.yifu.archives.entity.*; import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.FddContractInfoMapper; import com.yifu.cloud.plus.v1.yifu.archives.mapper.FddContractInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.*; import com.yifu.cloud.plus.v1.yifu.archives.service.*;
import com.yifu.cloud.plus.v1.yifu.archives.utils.FddUtil; import com.yifu.cloud.plus.v1.yifu.archives.utils.FddUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.LocalDateTimeUtils; import com.yifu.cloud.plus.v1.yifu.common.core.util.LocalDateTimeUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil; import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil;
...@@ -46,6 +66,10 @@ import org.apache.commons.lang3.StringUtils; ...@@ -46,6 +66,10 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
...@@ -54,7 +78,6 @@ import java.util.stream.Collectors; ...@@ -54,7 +78,6 @@ import java.util.stream.Collectors;
/** /**
* 法大大合同与员工合同信息 * 法大大合同与员工合同信息
*
* @author fxj * @author fxj
* @date 2022-06-29 16:21:51 * @date 2022-06-29 16:21:51
*/ */
...@@ -85,8 +108,8 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe ...@@ -85,8 +108,8 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
private FddContractAttachInfoService fddContractAttachInfoService; private FddContractAttachInfoService fddContractAttachInfoService;
// @Autowired // @Autowired
// private TEmployeeContractInfoService employeeContractInfoService; // private TEmployeeContractInfoService employeeContractInfoService;
@Autowired // @Autowired
private TEmployeeInfoService employeeInfoService; // private TEmployeeInfoService employeeInfoService;
@Autowired @Autowired
private FddTemplateFieldInfoService fieldInfoService; private FddTemplateFieldInfoService fieldInfoService;
// 阿里云文件上传服务 // 阿里云文件上传服务
...@@ -102,8 +125,7 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe ...@@ -102,8 +125,7 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
private TSettleDomainService tSettleDomainService; private TSettleDomainService tSettleDomainService;
@Override @Override
public R<String> saveEmpContract(FddContractInfo fddContractInfo) throws ApiException { public R<String> saveEmpContract(FddContractAttachInfo fddContractAttachInfo) throws ApiException {
FddContractAttachInfo fddContractAttachInfo = fddContractAttachInfoService.getById(fddContractInfo.getId());
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
if (!user.getId().equals(fddContractAttachInfo.getCreateBy())) { if (!user.getId().equals(fddContractAttachInfo.getCreateBy())) {
return R.failed("当前用户不是电子合同导入用户,不能操作"); return R.failed("当前用户不是电子合同导入用户,不能操作");
...@@ -166,8 +188,6 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe ...@@ -166,8 +188,6 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
CreateReviseTaskReq.FillTemplateFileInfo fileInfo = new CreateReviseTaskReq.FillTemplateFileInfo(); CreateReviseTaskReq.FillTemplateFileInfo fileInfo = new CreateReviseTaskReq.FillTemplateFileInfo();
fileInfo.setFileId(fddContractTemplateFile.getFddFileId()); fileInfo.setFileId(fddContractTemplateFile.getFddFileId());
//员工填充数据 //员工填充数据
//FddEmployeeContractFillVo fddEmployeeContractFillVo = new FddEmployeeContractFillVo();
//fileInfo.setFormFields(JSON.toJSONString(fddEmployeeContractFillVo));
List<FddTemplateFieldInfo> personFields = fieldInfoService.getFddFields(fddContractTemplate.getFddTemplateId(),CommonConstants.ZERO_STRING); List<FddTemplateFieldInfo> personFields = fieldInfoService.getFddFields(fddContractTemplate.getFddTemplateId(),CommonConstants.ZERO_STRING);
if (Common.isNotNull(personFields)){ if (Common.isNotNull(personFields)){
initPersonFields(fddContractAttachInfo,personFields); initPersonFields(fddContractAttachInfo,personFields);
...@@ -244,6 +264,348 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe ...@@ -244,6 +264,348 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
} }
} }
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 作废重签
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
* 1.去法大大撤销合同:已签署的撤销签署流程、再撤销定稿流程;未签署的撤销定稿流程
* 2.先复制一份合同、然后删除之前合同
* 3.新增一条合同
**/
@Override
public R<String> invalidAndsend(FddContractInfo fddContractInfo) throws ApiException {
FddContractInfo entity = this.getById(fddContractInfo.getId());
if (StringUtils.equals(entity.getDeleteFlag(), CommonConstants.ONE_STRING)) {
return R.failed("电子合同已作废");
}
if(StringUtils.equals(CommonConstants.TWO_STRING,entity.getSignStatus())){
return R.failed("合同签署任务已完成,不能作废重签");
}
YifuUser user = SecurityUtils.getUser();
FddContractAttachInfo fddContractAttachInfo = fddContractAttachInfoService.getOne(Wrappers.<FddContractAttachInfo>query().lambda()
.eq(FddContractAttachInfo::getContractId,entity.getContractId()));
if (!user.getId().equals(fddContractAttachInfo.getCreateBy())) {
return R.failed("当前用户不是电子合同导入用户,不能操作");
}
if (StringUtils.isNotEmpty(entity.getSignTaskId())) {
//发送撤销签署
CancelSignTaskReq req = new CancelSignTaskReq();
req.setToken(fddUtil.getToken());
req.setTaskId(entity.getSignTaskId());
req.setRemark("签署撤销");
SignTaskClient client = new SignTaskClient(fddUtil.getFadadaApiClient());
BaseRsp<GetSignUrlRsp> rsp = client.cancelSignTask(req);
reqLogService.saveLog(this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), req, rsp);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
//更新签署任务为空
baseMapper.cancleSignTask(entity.getId());
return cancleReviSeTask(entity);
} else {
return R.failed(rsp.getMsg());
}
} else if (StringUtils.isNotEmpty(entity.getTaskId())) {
return cancleReviSeTask(entity);
} else {
return R.failed("当前电子合同未发送");
}
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 获取在线定稿地址
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Override
public R<String> getFillFileUrl(FddContractInfo fddContractInfo, String roleName) throws ApiException {
//获取法大大电子合同
FddContractInfo entity = this.getById(fddContractInfo.getId());
if (entity == null) {
return R.failed("未查询到相关记录");
}
if (StringUtils.isEmpty(entity.getTaskId())) {
return R.failed(FILL_FILE_ID_NULL);
}
//发送请求
GetFillFileUrlReq req = new GetFillFileUrlReq();
req.setToken(fddUtil.getToken());
req.setTaskId(entity.getTaskId());
req.setRoleName(roleName);
ReviseTaskClient client = new ReviseTaskClient(fddUtil.getFadadaApiClient());
BaseRsp<GetFillFileUrlRsp> rsp = client.getFillFileUrl(req);
reqLogService.saveLog(this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), req, rsp);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
return new R<>(rsp.getData().getFillUrl());
} else {
return R.failed(rsp.getMsg());
}
}
/**
* @param
* @Author: huyc
* @Date: 2022/6/30
* @Description: 引用模板创建签署任务
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Override
public R<String> createTaskByDraftId(FddContractInfo entity) throws ApiException {
if (StringUtils.isEmpty(entity.getTaskId())) {
return R.failed(FILL_FILE_ID_NULL);
}
if (StringUtils.isEmpty(entity.getDraftId())) {
return R.failed("草稿id为空");
}
FddPersonAccount fddCompanyPersonAccount = fddPersonAccountService.getOne(Wrappers.<FddPersonAccount>query().lambda().eq(FddPersonAccount::getId, entity.getFddPersonAccountSendId()));
if (fddCompanyPersonAccount == null) {
return R.failed(NOT_FOUND_FDD_USER);
}
//获取用户章
List<FddSealPersonAuth> fddSealPersonAuth = fddSealPersonAuthService.list(Wrappers.<FddSealPersonAuth>query().lambda().eq(FddSealPersonAuth::getFddPersonAccountId, fddCompanyPersonAccount.getId())
.eq(FddSealPersonAuth::getStatus, CommonConstants.ONE_STRING));
if (fddSealPersonAuth == null) {
return R.failed("当前用户未授权系统章");
}
//获取员工法大大用户id
FddPersonAccount fddEmpAccount = fddPersonAccountService.getOne(Wrappers.<FddPersonAccount>query().lambda().eq(FddPersonAccount::getId, entity.getFddPersonAccountReceiveId()));
if (fddEmpAccount == null) {
return R.failed(NOT_FOUND_FDD_USER);
}
FddContractTemplate fddContractTemplate = fddContractTemplateService.getOne(Wrappers.<FddContractTemplate>query().lambda().eq(FddContractTemplate::getId, entity.getFddTemplateId()));
//获取法大大组织
FddCompanyInfo fddCompanyInfo = fddCompanyInfoService.getOne(Wrappers.<FddCompanyInfo>query().lambda().eq(FddCompanyInfo::getCompanyName, fddContractTemplate.getSignerName()));
if (fddCompanyInfo == null) {
return R.failed("未获取到对应法大大组织");
}
CreateTaskByDraftIdReq req = new CreateTaskByDraftIdReq();
req.setDraftId(entity.getDraftId());
req.setTaskSubject("合同签署");
req.setStatus("sent");
req.setSort(1);
//发起方对象
TaskSenderReq taskSenderReq = new TaskSenderReq();
taskSenderReq.setUnionId(fddCompanyInfo.getCompanyUnionId());
req.setSender(taskSenderReq);
//templateRoleName.模板角色名称
List<CreateTaskByDraftIdReq.CreateTaskSignerInfo> signers = new ArrayList<>();
//组装person signers---------------start
CreateTaskByDraftIdReq.CreateTaskSignerInfo signerInfo = new CreateTaskByDraftIdReq.CreateTaskSignerInfo();
signerInfo.setSignOrder(1);
signers.add(signerInfo);
signerInfo.setTemplateRoleName(FddUtil.PERSON);
//externalSigner
//signer
CreateTaskByDraftIdReq.SignatoryInfo signatory = new CreateTaskByDraftIdReq.SignatoryInfo();
signatory.setSignerId(fddEmpAccount.getUnionid());
CreateTaskByDraftIdReq.SignerInfo signer = new CreateTaskByDraftIdReq.SignerInfo();
signer.setSignatory(signatory);
com.fadada.api.bean.req.sign.NoticeReq perSionNotice = new com.fadada.api.bean.req.sign.NoticeReq();
perSionNotice.setNotifyWay(1);
perSionNotice.setNotifyAddress(fddEmpAccount.getMoblie());
signer.setNotice(perSionNotice);
signerInfo.setSigner(signer);
//组装person signers---------------end
//组装company signers---------------start
CreateTaskByDraftIdReq.CreateTaskSignerInfo companySignerInfo = new CreateTaskByDraftIdReq.CreateTaskSignerInfo();
companySignerInfo.setSignOrder(2);
signers.add(companySignerInfo);
companySignerInfo.setTemplateRoleName(FddUtil.COMPANY);
//externalSigner
//signer
CreateTaskByDraftIdReq.SignerInfo companySigner = new CreateTaskByDraftIdReq.SignerInfo();
CreateTaskByDraftIdReq.SignatoryInfo companySignatory = new CreateTaskByDraftIdReq.SignatoryInfo();
companySignatory.setSignerId(fddCompanyPersonAccount.getUnionid());
companySigner.setSignatory(companySignatory);
CreateTaskByDraftIdReq.CorpInfo corp = new CreateTaskByDraftIdReq.CorpInfo();
corp.setCorpId(fddCompanyInfo.getCompanyUnionId());
companySigner.setCorp(corp);
com.fadada.api.bean.req.sign.NoticeReq notice = new com.fadada.api.bean.req.sign.NoticeReq();
notice.setNotifyWay(1);
notice.setNotifyAddress(fddCompanyPersonAccount.getMoblie());
companySigner.setNotice(notice);
companySignerInfo.setSigner(companySigner);
//组装company signers---------------end
req.setSigners(signers);
//发送请求
//设置token
req.setToken(fddUtil.getToken());
SignTaskClient signTaskClient = new SignTaskClient(fddUtil.getFadadaApiClient());
BaseRsp<CreateTaskByDraftIdRsp> rsp = signTaskClient.createTaskByDraftId(req);
reqLogService.saveLog(this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), req, rsp);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
entity.setSignTaskId(rsp.getData().getTaskId());
this.updateById(entity);
return new R<>("成功");
} else {
return R.failed(rsp.getMsg());
}
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 获取签署链接
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Override
public R<Map<String, List<SignUrlRsp>>> getSignUrl(FddContractInfo fddContractInfo) throws ApiException {
//获取法大大电子合同
FddContractInfo entity = this.getById(fddContractInfo.getId());
if (entity == null) {
return R.failed("未查询到相关记录");
}
if (StringUtils.isEmpty(entity.getTaskId())) {
return R.failed(FILL_FILE_ID_NULL);
}
//发送请求
GetSignUrlReq req = new GetSignUrlReq();
req.setToken(fddUtil.getToken());
req.setTaskId(entity.getSignTaskId());
req.setUnionId(entity.getSendUnionid());
SignTaskClient client = new SignTaskClient(fddUtil.getFadadaApiClient());
BaseRsp<GetSignUrlRsp> rsp = client.getSignUrl(req);
reqLogService.saveLog(this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), req, rsp);
HashMap<String, List<SignUrlRsp>> hashMap = Maps.newHashMap();
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
hashMap.put(FddUtil.COMPANY, rsp.getData().getSignUrls());
}
req.setUnionId(entity.getSendUnionid());
rsp = client.getSignUrl(req);
reqLogService.saveLog(this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), req, rsp);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
hashMap.put(FddUtil.PERSON, rsp.getData().getSignUrls());
}
return new R<>(hashMap);
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 获取签署文件预览地址
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Override
public R<String> getSignPreviewUrl(FddContractInfo fddContractInfo) throws ApiException {
FddContractInfo entity = this.getById(fddContractInfo.getId());
if (entity == null || entity.getSignTaskId() == null) {
throw new CheckedException("未获取到对应签署任务");
}
//发送请求
GetSignPreviewUrlReq req = new GetSignPreviewUrlReq();
req.setToken(fddUtil.getToken());
req.setTaskId(entity.getSignTaskId());
SignTaskClient client = new SignTaskClient(fddUtil.getFadadaApiClient());
BaseRsp<GetSignPreviewUrlRsp> rsp = client.getSignPreviewUrl(req);
reqLogService.saveLog(this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), req, rsp);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
return new R<>(rsp.getData().getSignPreviewUrl());
}
return R.failed(rsp.getMsg());
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 签署文件下载
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
@Override
public void getBySignFileId(FddContractInfo fddContractInfo, HttpServletResponse response) throws ApiException, IOException {
FddContractInfo entity = this.getById(fddContractInfo.getId());
if (entity == null || entity.getSignTaskId() == null) {
throw new CheckedException("未获取到对应签署任务");
}
//发送请求
GetBySignFileIdReq req = new GetBySignFileIdReq();
req.setToken(fddUtil.getToken());
req.setTaskId(entity.getSignTaskId());
DocumentClient client = new DocumentClient(fddUtil.getFadadaApiClient());
BaseRsp<DownLoadFileRsp> rsp = client.getBySignFileId(req);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
DownLoadFileRsp rspData = rsp.getData();
BufferedOutputStream fos = new BufferedOutputStream(response.getOutputStream());
response.reset();
response.setContentType("application/zip;");
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode("合同.zip", CommonConstants.UTF8));
fos.write(rspData.getFileBytes());
}
}
/**
* @param fddContractInfo
* @param response
* @Description: 签署文件转移为合同附件
* @Author: huyc
* @Date: 2022/6/30
* @return: R
**/
@Override
public R<String> moveFileToEmpConcat(FddContractInfo fddContractInfo, HttpServletResponse response) throws ApiException, IOException {
// FddContractInfo entity = this.getById(fddContractInfo.getId());
// if (entity == null || entity.getSignTaskId() == null) {
// throw new CheckedException("未获取到对应签署任务");
// }
// TEmployeeContractInfo employeeContractInfo = employeeContractInfoService.getById(entity.getContractId());
// if (employeeContractInfo != null) {
// //发送请求
// GetBySignFileIdReq req = new GetBySignFileIdReq();
// req.setToken(fddUtil.getToken());
// req.setTaskId(entity.getSignTaskId());
// DocumentClient client = new DocumentClient(fddUtil.getFadadaApiClient());
// BaseRsp<DownLoadFileRsp> rsp = client.getBySignFileId(req);
// //校验参数
// if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
// DownLoadFileRsp rspData = rsp.getData();
// if (rspData != null) {
// InputStream bis = null;
// try {
// bis = new ByteArrayInputStream(rspData.getFileBytes());
// String name = System.currentTimeMillis() + "法大大电子签附件";
// String key = name + ".zip";
// ossUtil.uploadFileByStream(bis, key, null);
// // 1:保存为
//// TEmpAtta empAtta = BasicServiceUtil.initTEmpAttaForInsert(name, key, (long) rspData.getFileBytes().length);
//// empAttaService.save(empAtta);
//// MEmpContractAtta contractAtta = new MEmpContractAtta();
//// contractAtta.setAttaId(empAtta.getId());
//// contractAtta.setContractId(employeeContractInfo.getId());
//// mempContractAttaService.save(contractAtta);
// FddContractAttachInfo fddContractAttachInfo = fddContractAttachInfoService.getOne(Wrappers.<FddContractAttachInfo>query().lambda()
// .eq(FddContractAttachInfo::getContractId,entity.getContractId()).last(CommonConstants.LAST_ONE_SQL));
// if (fddContractAttachInfo != null) {
// fddContractAttachInfo.setIsMove(CommonConstants.ONE_INT);
// fddContractAttachInfoService.updateById(fddContractAttachInfo);
// }
// return R.ok();
// } finally {
// if (bis != null) {
// bis.close();
// }
// }
// }
// }
// }
return R.failed("转移失败");
}
public R<String> generalEmployeeParamNew(FddContractAttachInfo attachInfo, public R<String> generalEmployeeParamNew(FddContractAttachInfo attachInfo,
Map<String, String> companyFieldMap) { Map<String, String> companyFieldMap) {
JSONObject paramter = new JSONObject(); JSONObject paramter = new JSONObject();
...@@ -413,4 +775,64 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe ...@@ -413,4 +775,64 @@ public class FddContractInfoServiceImpl extends ServiceImpl<FddContractInfoMappe
ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault()); ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
return Date.from(zonedDateTime.toInstant()); return Date.from(zonedDateTime.toInstant());
} }
/**
* @param entity
* @Author: huyc
* @Date: 2022/6/30
* @Description: 撤销定稿任务
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
private R<String> cancleReviSeTask(FddContractInfo entity) throws ApiException {
//定稿任务状态:0 待发起 、1定稿中、2已定稿、3已撤销、4已过期
R<Integer> reviseTaskDetailR = reviseTaskDetail(entity);
if (reviseTaskDetailR.getCode() != CommonConstants.SUCCESS) {
return R.failed(reviseTaskDetailR.getMsg());
}
FddContractAttachInfo attachInfo = fddContractAttachInfoService.getOne(Wrappers.<FddContractAttachInfo>query().lambda().eq(FddContractAttachInfo::getContractId, entity.getContractId()));
int status = reviseTaskDetailR.getData();
CancelReviseTaskReq req = new CancelReviseTaskReq();
if (status == CommonConstants.ZERO_INT || status == CommonConstants.ONE_INT) {
//发送请求
req.setToken(fddUtil.getToken());
req.setTaskId(entity.getTaskId());
ReviseTaskClient client = new ReviseTaskClient(fddUtil.getFadadaApiClient());
BaseRsp<GetFillFileUrlRsp> rsp = client.cancelReviseTask(req);
reqLogService.saveLog(this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName(), req, rsp);
}
//.先复制一份合同、然后删除之前合同
entity.setDeleteFlag(CommonConstants.ONE_STRING);
this.updateById(entity);
// TEmployeeContractInfo employeeContractInfo = employeeContractInfoService.getById(entity.getContractId());
// TEmployeeInfo employeeInfo = employeeInfoService.getById(employeeContractInfo.getEmpId());
R<String> saveEmpContractR = saveEmpContract(attachInfo);
if (saveEmpContractR.getCode() != CommonConstants.SUCCESS) {
throw new CheckedException(saveEmpContractR.getMsg());
}
return R.ok();
}
/**
* @param fddContractInfo
* @Author: huyc
* @Date: 2022/6/30
* @Description: 获取定稿任务详情
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
public R<Integer> reviseTaskDetail(FddContractInfo fddContractInfo) throws ApiException {
//发送撤销签署
ReviseTaskDetailReq req = new ReviseTaskDetailReq();
req.setToken(fddUtil.getToken());
req.setTaskId(fddContractInfo.getTaskId());
ReviseTaskClient client = new ReviseTaskClient(fddUtil.getFadadaApiClient());
BaseRsp<ReviseTaskDetailRsp> rsp = client.reviseTaskDetail(req);
//校验参数
if (StringUtils.equals(rsp.getCode(), FddUtil.SUCCESS)) {
log.error("请求数据:{}",JSON.toJSONString(req));
log.error("返回数据:{}",JSON.toJSONString(rsp));
return new R<>(rsp.getData().getTaskStatus());
} else {
return R.failed(rsp.getMsg());
}
}
} }
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 to comment