保密协议签署完成,保密协议附件添加和删除

dev
IT-xiaoXiong 2021-12-03 15:46:56 +08:00
parent cad7706a17
commit 86e95aad7b
5 changed files with 248 additions and 108 deletions

View File

@ -22,6 +22,7 @@ public class UfContractInfoDTO {
private String workflowRequestId; private String workflowRequestId;
private String workflowDetailTable; private String workflowDetailTable;
private String signedType; private String signedType;
private String userInfo;
private int mainId; private int mainId;
public void setId(int id) { public void setId(int id) {
@ -176,6 +177,14 @@ public class UfContractInfoDTO {
this.signedType = signedType; this.signedType = signedType;
} }
public String getUserInfo() {
return userInfo;
}
public void setUserInfo(String userInfo) {
this.userInfo = userInfo;
}
@Override @Override
public String toString() { public String toString() {
return "UfContractInfoDTO{" + return "UfContractInfoDTO{" +
@ -197,6 +206,7 @@ public class UfContractInfoDTO {
", workflowRequestId='" + workflowRequestId + '\'' + ", workflowRequestId='" + workflowRequestId + '\'' +
", workflowDetailTable='" + workflowDetailTable + '\'' + ", workflowDetailTable='" + workflowDetailTable + '\'' +
", signedType='" + signedType + '\'' + ", signedType='" + signedType + '\'' +
", userInfo='" + userInfo + '\'' +
", mainId=" + mainId + ", mainId=" + mainId +
'}'; '}';
} }

View File

@ -8,6 +8,7 @@ import aiyh.utils.mapUtil.ParaMap;
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl; import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
import aiyh.utils.zwl.common.ToolUtil; import aiyh.utils.zwl.common.ToolUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.api.aiyh_pcn.fadada.dao.FaDDContractMapping; import com.api.aiyh_pcn.fadada.dao.FaDDContractMapping;
import com.api.aiyh_pcn.fadada.entity.FaDaDaConfigDTO; import com.api.aiyh_pcn.fadada.entity.FaDaDaConfigDTO;
import com.api.aiyh_pcn.fadada.entity.UfContractInfoDTO; import com.api.aiyh_pcn.fadada.entity.UfContractInfoDTO;
@ -22,12 +23,9 @@ import weaver.hrm.User;
import weaver.soa.workflow.FileProcessor; import weaver.soa.workflow.FileProcessor;
import weaver.workflow.workflow.WorkflowVersion; import weaver.workflow.workflow.WorkflowVersion;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.StreamingOutput; import javax.ws.rs.core.StreamingOutput;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -315,8 +313,10 @@ public class FaDDContractService {
if (ufContractInfoDTO.getSingleSignedNum() + 1 == ufContractInfoDTO.getSingleContractFileNum()) { if (ufContractInfoDTO.getSingleSignedNum() + 1 == ufContractInfoDTO.getSingleContractFileNum()) {
update.put("signed_num", ufContractInfoDTO.getSignedNum() + 1); update.put("signed_num", ufContractInfoDTO.getSignedNum() + 1);
// 查询下一位合同方并发起签署 // 查询下一位合同方并发起签署
if (ufContractInfoDTO.getSignedNum() + 1 < ufContractInfoDTO.getShouldSignedNum()) {
nextContractSigned(ufContractInfoDTO); nextContractSigned(ufContractInfoDTO);
} }
}
// 如果合同已签数量和应签数量相同,则状态为本方待签 // 如果合同已签数量和应签数量相同,则状态为本方待签
if (ufContractInfoDTO.getSignedNum() + 1 == ufContractInfoDTO.getShouldSignedNum()) { if (ufContractInfoDTO.getSignedNum() + 1 == ufContractInfoDTO.getShouldSignedNum()) {
update.put("contract_status", 3); update.put("contract_status", 3);
@ -326,6 +326,45 @@ public class FaDDContractService {
} }
if ("2".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) { if ("2".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) {
update.put("contract_status", 4); update.put("contract_status", 4);
// TODO 仅对方签署完成后,添加用户信息
// 获取配置表信息
FaDaDaConfigDTO faDaDaConfigDTO = faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 4);
RecordSet rs = new RecordSet();
String userInfo = ufContractInfoDTO.getUserInfo();
User user = JSON.parseObject(userInfo, new TypeReference<User>() {
});
// 获取流程中的合同字段的文档目录id
rs.executeQuery("select formid from workflow_base where id = ?", ufContractInfoDTO.getWorkflowType());
String formId = Util.recordeSet2Entity(rs, String.class);
String query = "select doccategory from workflow_fileupload where fieldid = (select id from workflow_billfield where fieldname = ? and billid = ?)";
rs.executeQuery(query, faDaDaConfigDTO.getContractDoc(), formId);
String docCategorys = Util.null2String(Util.recordeSet2Entity(rs, String.class));
if (StringUtils.isNullOrEmpty(docCategorys)) {
query = "select doccategory from workflow_base where id = ?";
rs.executeQuery(query, ufContractInfoDTO.getWorkflowType());
rs.next();
docCategorys = Util.null2String(rs.getString(1));
}
if (StringUtils.isNullOrEmpty(docCategorys)) {
docCategorys = ",,1";
}
// String[] docSplit = docCategorys.split(",");
// String category = docSplit[docSplit.length - 1];
// 下载合同到文件服务器中
String docIds = "";
try {
docIds = downloadContract2FileSystem(ufContractInfoDTO, docCategorys, user);
} catch (Exception e) {
toolUtil.writeErrorLog("创建文档发生错误:" + e);
}
toolUtil.writeDebuggerLog("生成的文档的id" + docIds);
// 将id保存到流程字段中
PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql(ufContractInfoDTO.getWorkflowMainTable(),
ParaMap.create().put(faDaDaConfigDTO.getContractDoc(), docIds),
Util.createPrepWhereImpl().whereAnd("id").whereEqual(ufContractInfoDTO.getMainId()));
toolUtil.writeDebuggerLog(sqlResult.getSqlStr() + ",参数:" + sqlResult.getArgs());
rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs());
} }
} }
} else { } else {
@ -341,6 +380,44 @@ public class FaDDContractService {
} }
if ("2".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) { if ("2".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) {
update.put("contract_status", 4); update.put("contract_status", 4);
// TODO 仅对方签署完成后,添加用户信息
// 获取配置表信息
FaDaDaConfigDTO faDaDaConfigDTO = faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 4);
RecordSet rs = new RecordSet();
String userInfo = ufContractInfoDTO.getUserInfo();
User user = JSON.parseObject(userInfo, new TypeReference<User>() {
});
// 获取流程中的合同字段的文档目录id
rs.executeQuery("select formid from workflow_base where id = ?", ufContractInfoDTO.getWorkflowType());
String formId = Util.recordeSet2Entity(rs, String.class);
String query = "select doccategory from workflow_fileupload where fieldid = (select id from workflow_billfield where fieldname = ? and billid = ?)";
rs.executeQuery(query, faDaDaConfigDTO.getContractDoc(), formId);
String docCategorys = Util.null2String(Util.recordeSet2Entity(rs, String.class));
if (StringUtils.isNullOrEmpty(docCategorys)) {
query = "select doccategory from workflow_base where id = ?";
rs.executeQuery(query, ufContractInfoDTO.getWorkflowType());
rs.next();
docCategorys = Util.null2String(rs.getString(1));
}
if (StringUtils.isNullOrEmpty(docCategorys)) {
docCategorys = ",,1";
}
// String[] docSplit = docCategorys.split(",");
// String category = docSplit[docSplit.length - 1];
// 下载合同到文件服务器中
String docIds = "";
try {
docIds = downloadContract2FileSystem(ufContractInfoDTO, docCategorys, user);
} catch (Exception e) {
toolUtil.writeErrorLog("创建文档发生错误:" + e);
}
toolUtil.writeDebuggerLog("生成的文档的id" + docIds);
// 将id保存到流程字段中
PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql(ufContractInfoDTO.getWorkflowMainTable(),
ParaMap.create().put(faDaDaConfigDTO.getContractDoc(), docIds),
Util.createPrepWhereImpl().whereAnd("id").whereEqual(ufContractInfoDTO.getMainId()));
toolUtil.writeDebuggerLog(sqlResult.getSqlStr() + ",参数:" + sqlResult.getArgs());
rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs());
} }
} }
} }
@ -662,6 +739,7 @@ public class FaDDContractService {
/** /**
* *
*
* @param ufContractInfoDTO * @param ufContractInfoDTO
* @return * @return
*/ */

View File

@ -35,6 +35,9 @@ public class CopyAttachmentSecretAction extends ToolUtil implements Action {
private String firstAddValue; private String firstAddValue;
// 第一次添加成功后的回写值 // 第一次添加成功后的回写值
private String addSuccessValue; private String addSuccessValue;
// 安全协议单独id字段
private String secretField;
@Override @Override
public String execute(RequestInfo requestInfo) { public String execute(RequestInfo requestInfo) {
ToolUtil toolUtil = new ToolUtil(); ToolUtil toolUtil = new ToolUtil();
@ -52,9 +55,11 @@ public class CopyAttachmentSecretAction extends ToolUtil implements Action {
Map<String, Object> requestData = Util.recordSet2Map(rs_1); Map<String, Object> requestData = Util.recordSet2Map(rs_1);
toolUtil.writeDebuggerLog(requestData.toString()); toolUtil.writeDebuggerLog(requestData.toString());
// 如果不是第一次添加,则直接返回 TODO 隐藏bug如果用户第一次选择添加后面被退回后将附件清空了重新上传然后又需要安全协议但是已经不是第一次添加了所以并不会生效 // 如果不是第一次添加,则直接返回 TODO 隐藏bug如果用户第一次选择添加后面被退回后将附件清空了重新上传然后又需要安全协议但是已经不是第一次添加了所以并不会生效
if (StringUtils.isNullOrEmpty(secretField)) {
if (requestData.get(firstAddField) != null && !Util.null2String(firstAddValue).equals(String.valueOf(requestData.get(firstAddField)))) { if (requestData.get(firstAddField) != null && !Util.null2String(firstAddValue).equals(String.valueOf(requestData.get(firstAddField)))) {
return Action.SUCCESS; return Action.SUCCESS;
} }
}
// 查询配置表,获取配置数据 // 查询配置表,获取配置数据
String querySql = "select ufta.id,ufta.workflow_type,wftva.fieldname as template_field, " + String querySql = "select ufta.id,ufta.workflow_type,wftva.fieldname as template_field, " +
"wftvb.fieldname as attachment_field,wftv.fieldname as show_field, wftvb.id as attachment_field_id, " + "wftvb.fieldname as attachment_field,wftv.fieldname as show_field, wftvb.id as attachment_field_id, " +
@ -119,6 +124,27 @@ public class CopyAttachmentSecretAction extends ToolUtil implements Action {
.attachmentTableName(attachmentTableName) .attachmentTableName(attachmentTableName)
.attachmentFieldId(attachmentFieldId) .attachmentFieldId(attachmentFieldId)
.builder(); .builder();
if (!StringUtils.isNullOrEmpty(secretField)) {
// 原字段的文件id
String fileIds = Util.null2String(rs_1.getString(configEmpty.getAttachmentField()));
String[] split = fileIds.split(",");
// 转为list
List<String> list = Arrays.stream(split).collect(Collectors.toList());
// 如果配置了secretField字段
if (!StringUtils.isNullOrEmpty(secretField)) {
String secretIds = Util.null2String(rs_1.getString(secretField));
String[] secretIdArr = secretIds.split(",");
List<String> secretFieldList = Arrays.stream(secretIdArr).collect(Collectors.toList());
list.removeAll(secretFieldList);
}
Map<String, Object> data = ParaMap.create().put(configEmpty.getAttachmentField(), String.join(",", list));
// 修改流程数据将保密协议的docid更新到流程中
PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql(billTableName,
data,
Util.createPrepWhereImpl().whereAnd("requestid").whereEqual(requestId));
toolUtil.writeDebuggerLog("sql " + sqlResult.getSqlStr() + " 参数: ---> " + sqlResult.getArgs());
rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs());
}
toolUtil.writeDebuggerLog("保密协议数据:" + configEmpty.toString()); toolUtil.writeDebuggerLog("保密协议数据:" + configEmpty.toString());
// 如果不控制是否使用模板,那就默认不添加保密协议 // 如果不控制是否使用模板,那就默认不添加保密协议
if ("1".equals(isTemplateShow)) { if ("1".equals(isTemplateShow)) {
@ -143,16 +169,29 @@ public class CopyAttachmentSecretAction extends ToolUtil implements Action {
requestInfo.getRequestManager().setMessagecontent(aiyh.utils.Util.getHtmlLabelName(-87783, user.getLanguage(), "保密协议复制失败,未能正确复制保密协议!")); requestInfo.getRequestManager().setMessagecontent(aiyh.utils.Util.getHtmlLabelName(-87783, user.getLanguage(), "保密协议复制失败,未能正确复制保密协议!"));
return Action.FAILURE_AND_CONTINUE; return Action.FAILURE_AND_CONTINUE;
} }
// 原字段的文件id
String fileIds = Util.null2String(rs_1.getString(configEmpty.getAttachmentField())); String fileIds = Util.null2String(rs_1.getString(configEmpty.getAttachmentField()));
String[] split = fileIds.split(","); String[] split = fileIds.split(",");
// 转为list
List<String> list = Arrays.stream(split).collect(Collectors.toList()); List<String> list = Arrays.stream(split).collect(Collectors.toList());
String[] split1 = docIds.split(","); // 如果配置了secretField字段
list.addAll(Arrays.stream(split1).collect(Collectors.toList())); if (!StringUtils.isNullOrEmpty(secretField)) {
String secretIds = Util.null2String(rs_1.getString(secretField));
String[] secretIdArr = secretIds.split(",");
List<String> secretFieldList = Arrays.stream(secretIdArr).collect(Collectors.toList());
list.removeAll(secretFieldList);
}
String[] docList = docIds.split(",");
list.addAll(Arrays.stream(docList).collect(Collectors.toList()));
Map<String, Object> data = ParaMap.create().put(configEmpty.getAttachmentField(), String.join(",", list));
if (!StringUtils.isNullOrEmpty(secretField)) {
data.put(secretField, docIds);
} else {
data.put(firstAddField, addSuccessValue);
}
// 修改流程数据将保密协议的docid更新到流程中 // 修改流程数据将保密协议的docid更新到流程中
PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql(billTableName, PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql(billTableName,
ParaMap.create().put(configEmpty.getAttachmentField(), String.join(",", list)) data,
.put(firstAddField,addSuccessValue),
Util.createPrepWhereImpl().whereAnd("requestid").whereEqual(requestId)); Util.createPrepWhereImpl().whereAnd("requestid").whereEqual(requestId));
toolUtil.writeDebuggerLog("sql " + sqlResult.getSqlStr() + " 参数: ---> " + sqlResult.getArgs()); toolUtil.writeDebuggerLog("sql " + sqlResult.getSqlStr() + " 参数: ---> " + sqlResult.getArgs());
rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs());
@ -237,6 +276,14 @@ public class CopyAttachmentSecretAction extends ToolUtil implements Action {
this.firstAddValue = firstAddValue; this.firstAddValue = firstAddValue;
} }
public String getSecretField() {
return secretField;
}
public void setSecretField(String secretField) {
this.secretField = secretField;
}
public String getAddSuccessValue() { public String getAddSuccessValue() {
return addSuccessValue; return addSuccessValue;
} }

View File

@ -9,7 +9,6 @@ import weaver.aiyh_pcn.fadada.util.FaddContractUtil;
import weaver.hrm.User; import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action; import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo; import weaver.soa.workflow.request.RequestInfo;
import weaver.systeminfo.SystemEnv;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -67,7 +66,7 @@ public class FaDDContractAction extends ToolUtil implements Action {
List<Map<String, Object>> detailMaps = faDDContractMapping.queryDetailMaps(mainId, tableName); List<Map<String, Object>> detailMaps = faDDContractMapping.queryDetailMaps(mainId, tableName);
// 开始签署合同 // 开始签署合同
FaddContractUtil faddContractUtil = new FaddContractUtil(workflowId, requestId, mainTableName, tableName, FaddContractUtil faddContractUtil = new FaddContractUtil(workflowId, requestId, mainTableName, tableName,
customerNo, customerNoField, contractField, queueSigned, detailMaps, mainMap); customerNo, customerNoField, contractField, queueSigned, detailMaps, mainMap, user);
try { try {
faddContractUtil.createContract(mainMap); faddContractUtil.createContract(mainMap);
} catch (Exception e) { } catch (Exception e) {

View File

@ -6,6 +6,7 @@ import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.mapUtil.ParaMap; import aiyh.utils.mapUtil.ParaMap;
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl; import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
import aiyh.utils.zwl.common.ToolUtil; import aiyh.utils.zwl.common.ToolUtil;
import com.alibaba.fastjson.JSON;
import com.api.aiyh_pcn.fadada.dao.FaDDContractMapping; import com.api.aiyh_pcn.fadada.dao.FaDDContractMapping;
import com.api.aiyh_pcn.fadada.entity.FaDaDaConfigDTO; import com.api.aiyh_pcn.fadada.entity.FaDaDaConfigDTO;
import com.api.aiyh_pcn.fadada.service.impl.FaDDContractService; import com.api.aiyh_pcn.fadada.service.impl.FaDDContractService;
@ -18,6 +19,7 @@ import weaver.conn.RecordSet;
import weaver.file.ImageFileManager; import weaver.file.ImageFileManager;
import weaver.formmode.data.ModeDataIdUpdate; import weaver.formmode.data.ModeDataIdUpdate;
import weaver.formmode.setup.ModeRightInfo; import weaver.formmode.setup.ModeRightInfo;
import weaver.hrm.User;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -47,12 +49,14 @@ public class FaddContractUtil {
private FaDDContractMapping faDDContractMapping = new FaDDContractMapping(); private FaDDContractMapping faDDContractMapping = new FaDDContractMapping();
private FaDDContractService faDDContractService = new FaDDContractService(); private FaDDContractService faDDContractService = new FaDDContractService();
private final ToolUtil toolUtil = new ToolUtil(); private final ToolUtil toolUtil = new ToolUtil();
private User user;
public FaddContractUtil() { public FaddContractUtil() {
} }
public FaddContractUtil(String workflowId, String requestId, String mainTableName, String tableName, String customerNo, public FaddContractUtil(String workflowId, String requestId, String mainTableName, String tableName, String customerNo,
String customerNoField, String contractField, String queueSigned, List<Map<String, Object>> detailMaps, Map<String, Object> mainMap) { String customerNoField, String contractField, String queueSigned, List<Map<String, Object>> detailMaps, Map<String, Object> mainMap,
User user) {
this.workflowId = workflowId; this.workflowId = workflowId;
this.requestId = requestId; this.requestId = requestId;
this.mainTableName = mainTableName; this.mainTableName = mainTableName;
@ -63,6 +67,7 @@ public class FaddContractUtil {
this.queueSigned = queueSigned; this.queueSigned = queueSigned;
this.detailMaps = detailMaps; this.detailMaps = detailMaps;
this.mainMap = mainMap; this.mainMap = mainMap;
this.user = user;
} }
/** /**
@ -122,6 +127,7 @@ public class FaddContractUtil {
updateMap.put("workflow_request_id", requestId); updateMap.put("workflow_request_id", requestId);
updateMap.put("workflow_main_table", mainTableName); updateMap.put("workflow_main_table", mainTableName);
updateMap.put("workflow_detail_table", tableName); updateMap.put("workflow_detail_table", tableName);
updateMap.put("user_info", JSON.toJSONString(user));
// 1表示创建 2表示等待对方签署3表示等待本方签署4表示完成 // 1表示创建 2表示等待对方签署3表示等待本方签署4表示完成
updateMap.put("contract_status", 1); updateMap.put("contract_status", 1);
// 对方应该签署的数量 // 对方应该签署的数量