修改调解和解功能

This commit is contained in:
qitz
2024-02-19 11:32:55 +08:00
parent 784f7c0675
commit 962e28c0d8
@@ -1271,7 +1271,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
if(mediaResult!=null){
if(mediaResult.intValue()==1){
Integer isReconci = req.getIsReconci();
//达成调解
if (application.getTemplateId() == null) {
return AjaxResult.error("未找到模板");
@@ -1281,7 +1280,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
req.setTemplateType(TemplateTypeEnum.MEDIATE_BOOK.getCode());
AjaxResult result = generateApplication(req);
if (result != null && result.isSuccess()) {
// todo 生成完调解书需要记录日志
List<MsCaseAttach> caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(req.getId());
if (caseAttachList != null && caseAttachList.size() > 0) {
for (MsCaseAttach caseAttach : caseAttachList) {
@@ -1431,207 +1429,117 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
}
if(isReconci.intValue()==1){
EsignHttpResponse response3 = SignAward.createByFileReconci(sealSignRecord);
JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody());
if (jsonObject3 != null) {
if (jsonObject3.getIntValue("code") == 0) {
//获取签署流程ID
JSONObject data1 = jsonObject3.getJSONObject("data");
String signFlowId = data1.getString("signFlowId");
//保存案件id,文件id,文件名称.流程id到签署用印记录表里
sealSignRecord.setCaseAppliId(application.getId());
sealSignRecord.setSignFlowid(signFlowId);
sealSignRecord.setSignFlowStatus(1);//待签名
MsSealSignRecord msSealSignRecord = new MsSealSignRecord();
BeanUtil.copyProperties(sealSignRecord, msSealSignRecord);
msSealSignRecord.setFileId(sealSignRecord.getFileid());
msSealSignRecord.setFileName(sealSignRecord.getFilename());
msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid());
sealSignRecordMapper.insert(msSealSignRecord);
SealSignRecord sealSignRecordapply = new SealSignRecord();
sealSignRecordapply.setSignFlowid(signFlowId);
String nameAgent = caseAffiliate.getNameAgent();
if(StringUtils.isNotBlank(nameAgent)){
sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent());
}else {
sealSignRecordapply.setPensonAccount(caseAffiliate.getApplicationPhone());
String orgnizeName = sealSignRecord.getOrgnizeName(); //机构名称
String orgnizeNamepsnName = sealSignRecord.getOrgnizeNamepsnName(); //机构经办人姓名
String orgnizeNamePsnAccount = sealSignRecord.getOrgnizeNamePsnAccount(); //机构经办人联系方式
//查询机构信息
DeptIdentify deptIdentify1 = new DeptIdentify();
deptIdentify1.setIdentifyName(orgnizeName);
deptIdentify1.setOperName(orgnizeNamepsnName);
deptIdentify1.setOperPhone(orgnizeNamePsnAccount);
List<DeptIdentify> deptIdentifies = deptIdentifyMapper.selectDeptIdentify(deptIdentify1);
if (deptIdentifies != null && deptIdentifies.size() > 0) {
Long iddeptIdent = deptIdentifies.get(0).getId();
SealManage sealManage = new SealManage();
sealManage.setIdentifyId(iddeptIdent);
List<String> sealIdList = new ArrayList<>();
List<SealManage> selectSealList = sealManageMapper.selectSealList(sealManage);
if (selectSealList != null && selectSealList.size() > 0) {
for (SealManage manage : selectSealList) {
Integer sealStatus = manage.getSealStatus();
Integer isUse = manage.getIsUse();
if (sealStatus == 1 && isUse ==1) {
sealIdList.add(manage.getSealId());
}
EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply);
JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class);
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
String urlapply = signUrlData.get("shortUrl").getAsString();
String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1);
//发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信
SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
request.setTemplateId("2047719");
if(StringUtils.isNotBlank(nameAgent)){
request.setPhone(caseAffiliate.getContactTelphoneAgent());
request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), application.getCaseNum(),urlapplynew});
}else {
request.setPhone(caseAffiliate.getApplicationPhone());
request.setTemplateParamSet(new String[]{caseAffiliate.getApplicationName(), application.getCaseNum(),urlapplynew});
}
Boolean aBoolean = SmsUtils.sendSms(request);
SealSignRecord sealSignRecordRespon = new SealSignRecord();
sealSignRecordRespon.setSignFlowid(signFlowId);
sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone());
EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon);
JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class);
JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data");
String urlRespon = signUrlDataRespon.get("shortUrl").getAsString();
String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1);
SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest();
request1.setTemplateId("2047719");
request1.setPhone(caseAffiliate.getRespondentPhone());
request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), application.getCaseNum(),urlResponnew});
Boolean aBoolean1 = SmsUtils.sendSms(request1);
} else {
throw new ServiceException(jsonObject3.getString("message"));
}
} else {
return AjaxResult.error();
}
EsignHttpResponse response3 = SignAward.createByFileMediation(sealSignRecord, sealIdList);
}else {
/*DeptIdentify deptIdentify1 = new DeptIdentify();
deptIdentify1.setSealStatus(1); // 印章状态为启用
//根据机构名称查询部门id
SysDept sysDept = new SysDept();
sysDept.setDeptName(sealSignRecord.getOrgnizeName());
List<SysDept> sysDepts = deptMapper.selectDeptList(sysDept);
if (sysDepts != null && sysDepts.size() > 0) {
Long deptId = sysDepts.get(0).getDeptId();
deptIdentify1.setDeptId(deptId);
}
List<DeptIdentify> deptIdentifies = deptIdentifyMapper.selectDeptIdentifylistother(deptIdentify1);
List<String> sealIds = new ArrayList<>();
if (deptIdentifies != null && deptIdentifies.size() > 0) {
for (DeptIdentify identify : deptIdentifies) {
String sealId = identify.getSealId();
sealIds.add(sealId);
}
}*/
String orgnizeName = sealSignRecord.getOrgnizeName(); //机构名称
String orgnizeNamepsnName = sealSignRecord.getOrgnizeNamepsnName(); //机构经办人姓名
String orgnizeNamePsnAccount = sealSignRecord.getOrgnizeNamePsnAccount(); //机构经办人联系方式
//查询机构信息
DeptIdentify deptIdentify1 = new DeptIdentify();
deptIdentify1.setIdentifyName(orgnizeName);
deptIdentify1.setOperName(orgnizeNamepsnName);
deptIdentify1.setOperPhone(orgnizeNamePsnAccount);
List<DeptIdentify> deptIdentifies = deptIdentifyMapper.selectDeptIdentify(deptIdentify1);
if (deptIdentifies != null && deptIdentifies.size() > 0) {
Long iddeptIdent = deptIdentifies.get(0).getId();
SealManage sealManage = new SealManage();
sealManage.setIdentifyId(iddeptIdent);
List<String> sealIdList = new ArrayList<>();
List<SealManage> selectSealList = sealManageMapper.selectSealList(sealManage);
if (selectSealList != null && selectSealList.size() > 0) {
for (SealManage manage : selectSealList) {
Integer sealStatus = manage.getSealStatus();
Integer isUse = manage.getIsUse();
if (sealStatus == 1 && isUse ==1) {
sealIdList.add(manage.getSealId());
JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody());
if (jsonObject3 != null) {
if (jsonObject3.getIntValue("code") == 0) {
//获取签署流程ID
JSONObject data1 = jsonObject3.getJSONObject("data");
String signFlowId = data1.getString("signFlowId");
//保存案件id,文件id,文件名称.流程id到签署用印记录表里
sealSignRecord.setCaseAppliId(application.getId());
sealSignRecord.setSignFlowid(signFlowId);
sealSignRecord.setSignFlowStatus(1);//待签名
MsSealSignRecord msSealSignRecord = new MsSealSignRecord();
BeanUtil.copyProperties(sealSignRecord, msSealSignRecord);
msSealSignRecord.setFileId(sealSignRecord.getFileid());
msSealSignRecord.setFileName(sealSignRecord.getFilename());
msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid());
msSealSignRecord.setOrgnNamePsnAcc(sealSignRecord.getOrgnizeNamePsnAccount());
msSealSignRecord.setOrgnNamePsnName(sealSignRecord.getOrgnizeNamepsnName());
sealSignRecordMapper.insert(msSealSignRecord);
SealSignRecord sealSignRecordapply = new SealSignRecord();
sealSignRecordapply.setSignFlowid(signFlowId);
String nameAgent = caseAffiliate.getNameAgent();
if(StringUtils.isNotBlank(nameAgent)){
sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent());
}else {
sealSignRecordapply.setPensonAccount(caseAffiliate.getApplicationPhone());
}
}
EsignHttpResponse response3 = SignAward.createByFileMediation(sealSignRecord, sealIdList);
JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody());
if (jsonObject3 != null) {
if (jsonObject3.getIntValue("code") == 0) {
//获取签署流程ID
JSONObject data1 = jsonObject3.getJSONObject("data");
String signFlowId = data1.getString("signFlowId");
//保存案件id,文件id,文件名称.流程id到签署用印记录表里
sealSignRecord.setCaseAppliId(application.getId());
sealSignRecord.setSignFlowid(signFlowId);
sealSignRecord.setSignFlowStatus(1);//待签名
MsSealSignRecord msSealSignRecord = new MsSealSignRecord();
BeanUtil.copyProperties(sealSignRecord, msSealSignRecord);
msSealSignRecord.setFileId(sealSignRecord.getFileid());
msSealSignRecord.setFileName(sealSignRecord.getFilename());
msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid());
msSealSignRecord.setOrgnNamePsnAcc(sealSignRecord.getOrgnizeNamePsnAccount());
msSealSignRecord.setOrgnNamePsnName(sealSignRecord.getOrgnizeNamepsnName());
sealSignRecordMapper.insert(msSealSignRecord);
EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply);
JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class);
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
String urlapply = signUrlData.get("shortUrl").getAsString();
String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1);
SealSignRecord sealSignRecordapply = new SealSignRecord();
sealSignRecordapply.setSignFlowid(signFlowId);
String nameAgent = caseAffiliate.getNameAgent();
if(StringUtils.isNotBlank(nameAgent)){
sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent());
}else {
sealSignRecordapply.setPensonAccount(caseAffiliate.getApplicationPhone());
}
//发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信
SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
request.setTemplateId("2047719");
EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply);
JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class);
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
String urlapply = signUrlData.get("shortUrl").getAsString();
String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1);
//发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信
SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
request.setTemplateId("2047719");
if(StringUtils.isNotBlank(nameAgent)){
request.setPhone(caseAffiliate.getContactTelphoneAgent());
request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), application.getCaseNum(),urlapplynew});
}else {
request.setPhone(caseAffiliate.getApplicationPhone());
request.setTemplateParamSet(new String[]{caseAffiliate.getApplicationName(), application.getCaseNum(),urlapplynew});
}
Boolean aBoolean = SmsUtils.sendSms(request);
SealSignRecord sealSignRecordRespon = new SealSignRecord();
sealSignRecordRespon.setSignFlowid(signFlowId);
sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone());
EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon);
JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class);
JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data");
String urlRespon = signUrlDataRespon.get("shortUrl").getAsString();
String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1);
SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest();
request1.setTemplateId("2047719");
request1.setPhone(caseAffiliate.getRespondentPhone());
request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), application.getCaseNum(),urlResponnew});
Boolean aBoolean1 = SmsUtils.sendSms(request1);
SealSignRecord sealSignRecordMedi = new SealSignRecord();
sealSignRecordMedi.setSignFlowid(signFlowId);
sealSignRecordMedi.setPensonAccount(sealSignRecord.getPensonAccountMedi());
EsignHttpResponse signUrlResponMedi = SignAward.signUrlMediation(sealSignRecordMedi);
JsonObject signUrlJsonObjectResponMedi = gson.fromJson(signUrlResponMedi.getBody(), JsonObject.class);
JsonObject signUrlDataResponMedi = signUrlJsonObjectResponMedi.getAsJsonObject("data");
String urlResponMedi = signUrlDataResponMedi.get("shortUrl").getAsString();
String urlResponnewMedi = urlResponMedi.substring(urlResponMedi.lastIndexOf("/")+1);
SmsUtils.SendSmsRequest requestMedi = new SmsUtils.SendSmsRequest();
requestMedi.setTemplateId("2047719");
requestMedi.setPhone(sealSignRecord.getPensonAccountMedi());
requestMedi.setTemplateParamSet(new String[]{sealSignRecord.getPensonNameMedi(), application.getCaseNum(),urlResponnewMedi});
Boolean aBooleanMedi = SmsUtils.sendSms(requestMedi);
} else {
throw new ServiceException(jsonObject3.getString("message"));
if(StringUtils.isNotBlank(nameAgent)){
request.setPhone(caseAffiliate.getContactTelphoneAgent());
request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), application.getCaseNum(),urlapplynew});
}else {
request.setPhone(caseAffiliate.getApplicationPhone());
request.setTemplateParamSet(new String[]{caseAffiliate.getApplicationName(), application.getCaseNum(),urlapplynew});
}
Boolean aBoolean = SmsUtils.sendSms(request);
SealSignRecord sealSignRecordRespon = new SealSignRecord();
sealSignRecordRespon.setSignFlowid(signFlowId);
sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone());
EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon);
JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class);
JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data");
String urlRespon = signUrlDataRespon.get("shortUrl").getAsString();
String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1);
SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest();
request1.setTemplateId("2047719");
request1.setPhone(caseAffiliate.getRespondentPhone());
request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), application.getCaseNum(),urlResponnew});
Boolean aBoolean1 = SmsUtils.sendSms(request1);
SealSignRecord sealSignRecordMedi = new SealSignRecord();
sealSignRecordMedi.setSignFlowid(signFlowId);
sealSignRecordMedi.setPensonAccount(sealSignRecord.getPensonAccountMedi());
EsignHttpResponse signUrlResponMedi = SignAward.signUrlMediation(sealSignRecordMedi);
JsonObject signUrlJsonObjectResponMedi = gson.fromJson(signUrlResponMedi.getBody(), JsonObject.class);
JsonObject signUrlDataResponMedi = signUrlJsonObjectResponMedi.getAsJsonObject("data");
String urlResponMedi = signUrlDataResponMedi.get("shortUrl").getAsString();
String urlResponnewMedi = urlResponMedi.substring(urlResponMedi.lastIndexOf("/")+1);
SmsUtils.SendSmsRequest requestMedi = new SmsUtils.SendSmsRequest();
requestMedi.setTemplateId("2047719");
requestMedi.setPhone(sealSignRecord.getPensonAccountMedi());
requestMedi.setTemplateParamSet(new String[]{sealSignRecord.getPensonNameMedi(), application.getCaseNum(),urlResponnewMedi});
Boolean aBooleanMedi = SmsUtils.sendSms(requestMedi);
} else {
return AjaxResult.error();
throw new ServiceException(jsonObject3.getString("message"));
}
} else {
return AjaxResult.error();
}
} else {
return AjaxResult.error();
}
} else {
return AjaxResult.error();
}
// 修改案件状态为待签名
@@ -1641,10 +1549,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
if(caseFlow != null){
application.setCaseFlowId(caseFlow.getId());
application.setCaseStatusName(caseFlow.getCaseStatusName());
msCaseApplicationMapper.updateByPrimaryKey(application);
}
application.setIsReconci(isReconci);
application.setMediaResult(mediaResult);
msCaseApplicationMapper.updateByPrimaryKeySelective(application);
}else{
@@ -1727,7 +1633,230 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
.header("signstr", signStr)
.body(paramsbody)
.execute();
}else if(mediaResult.intValue()==5){
//达成和解
if (application.getTemplateId() == null) {
return AjaxResult.error("未找到模板");
}
String templateId = String.valueOf(application.getTemplateId());
req.setTemplateId(templateId);
req.setTemplateType(TemplateTypeEnum.MEDIATION_AGREEMENT.getCode());
AjaxResult result = generateApplication(req);
if (result != null && result.isSuccess()) {
List<MsCaseAttach> caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(req.getId());
if (caseAttachList != null && caseAttachList.size() > 0) {
for (MsCaseAttach caseAttach : caseAttachList) {
if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) {
String prefix = "/profile";
int startIndex = prefix.length();
String annexPath = caseAttach.getAnnexPath();
String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1);
//获取文件上传地址
EsignHttpResponse response = SaaSAPIFileUtils.getUploadUrl(path);
String body = response.getBody();
if (body != null) {
JSONObject jsonObject = JSONObject.parseObject(body);
String fileId = jsonObject.getJSONObject("data").getString("fileId");
String fileUploadUrl = jsonObject.getJSONObject("data").getString("fileUploadUrl");
//上传文件流
EsignHttpResponse response1 = SaaSAPIFileUtils.uploadFile(fileUploadUrl, path);
JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody());
if (jsonObject1.getIntValue("errCode") == 0) {
//查看文件上传状态
Thread.sleep(1000);
EsignHttpResponse response2 = SaaSAPIFileUtils.getFileStatus(fileId);
JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody());
JSONObject data = jsonObject2.getJSONObject("data");
int fileStatus = data.getIntValue("fileStatus");
if (fileStatus == 2 || fileStatus == 5) {
String fileName = data.getString("fileName");
//上传成功,获取文件签名印章位置
SealSignRecord sealSignRecord = new SealSignRecord();
sealSignRecord.setFileid(fileId);
EsignHttpResponse positions = SignAward.getPositionsMediation(sealSignRecord);
Gson gson = new Gson();
JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class);
JsonObject positionsData = positionsJsonObject.getAsJsonObject("data");
String keywordPositions = positionsData.get("keywordPositions").toString();
//发起签署
sealSignRecord.setFilename(fileName);
Long arbitratorId = application.getMediatorId();
if (arbitratorId!=null) {
SysUser sysUser = sysUserMapper.selectUserById(arbitratorId);
if (sysUser == null) {
return AjaxResult.error();
}
sealSignRecord.setPensonAccountMedi(sysUser.getPhonenumber());
sealSignRecord.setPensonNameMedi(sysUser.getNickName());
}
Integer organizeFlag = caseAffiliate.getOrganizeFlag();
if(organizeFlag!=null){
if(organizeFlag.intValue()==1){
sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent());
sealSignRecord.setPensonName(caseAffiliate.getNameAgent());
}else {
String nameAgent = caseAffiliate.getNameAgent();
if(StringUtils.isNotBlank(nameAgent)){
sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent());
sealSignRecord.setPensonName(caseAffiliate.getNameAgent());
}else {
sealSignRecord.setPensonAccount(caseAffiliate.getApplicationPhone());
sealSignRecord.setPensonName(caseAffiliate.getApplicationName());
}
}
}
sealSignRecord.setPensonAccountRes(caseAffiliate.getRespondentPhone());
sealSignRecord.setPensonNameRes(caseAffiliate.getRespondentName());
// DeptIdentify deptIdentify = new DeptIdentify();
// deptIdentify.setIsUse(1);
// DeptIdentify deptIdentifyselect = new DeptIdentify();
// List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify);
// if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) {
// deptIdentifyselect = deptIdentifysnew.get(0);
// sealSignRecord.setOrgnizeName(deptIdentifyselect.getIdentifyName());
// sealSignRecord.setOrgnizeNamePsnAccount(deptIdentifyselect.getOperPhone());
// sealSignRecord.setOrgnizeNamepsnName(deptIdentifyselect.getOperName());
// } else {
// return AjaxResult.error("没有用印时的机构名称及经办人信息");
// }
//解析文件签名印章位置
JSONArray jsonArray = JSONArray.parseArray(keywordPositions);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject3 = jsonArray.getJSONObject(i);
String keyword = jsonObject3.getString("keyword");
if (keyword.equals("甲方(签字):")) {
//签名
JSONArray positionsArray = jsonObject3.getJSONArray("positions");
// 遍历 positionsArray 中的每个元素
for (int j = 0; j < positionsArray.size(); j++) {
JSONObject positionObj = positionsArray.getJSONObject(j);
int pageNum = positionObj.getIntValue("pageNum");
sealSignRecord.setPositionPagepsn(String.valueOf(pageNum));
JSONArray coordinatesArray = positionObj.getJSONArray("coordinates");
JSONObject coordinateObj = coordinatesArray.getJSONObject(0);
double positionX = coordinateObj.getDoubleValue("positionX");
double positionY = coordinateObj.getDoubleValue("positionY");
sealSignRecord.setPositionXpsn(positionX + 120);
sealSignRecord.setPositionYpsn(positionY);
}
}else if (keyword.equals("乙方(签字):")) {
//签名
JSONArray positionsArray = jsonObject3.getJSONArray("positions");
// 遍历 positionsArray 中的每个元素
for (int j = 0; j < positionsArray.size(); j++) {
JSONObject positionObj = positionsArray.getJSONObject(j);
int pageNum = positionObj.getIntValue("pageNum");
sealSignRecord.setPositionPagepsnRes(String.valueOf(pageNum));
JSONArray coordinatesArray = positionObj.getJSONArray("coordinates");
JSONObject coordinateObj = coordinatesArray.getJSONObject(0);
double positionX = coordinateObj.getDoubleValue("positionX");
double positionY = coordinateObj.getDoubleValue("positionY");
sealSignRecord.setPositionXpsnRes(positionX + 120);
sealSignRecord.setPositionYpsnRes(positionY + 10);
}
}
}
EsignHttpResponse response3 = SignAward.createByFileReconci(sealSignRecord);
JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody());
if (jsonObject3 != null) {
if (jsonObject3.getIntValue("code") == 0) {
//获取签署流程ID
JSONObject data1 = jsonObject3.getJSONObject("data");
String signFlowId = data1.getString("signFlowId");
//保存案件id,文件id,文件名称.流程id到签署用印记录表里
sealSignRecord.setCaseAppliId(application.getId());
sealSignRecord.setSignFlowid(signFlowId);
sealSignRecord.setSignFlowStatus(1);//待签名
MsSealSignRecord msSealSignRecord = new MsSealSignRecord();
BeanUtil.copyProperties(sealSignRecord, msSealSignRecord);
msSealSignRecord.setFileId(sealSignRecord.getFileid());
msSealSignRecord.setFileName(sealSignRecord.getFilename());
msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid());
sealSignRecordMapper.insert(msSealSignRecord);
SealSignRecord sealSignRecordapply = new SealSignRecord();
sealSignRecordapply.setSignFlowid(signFlowId);
String nameAgent = caseAffiliate.getNameAgent();
if(StringUtils.isNotBlank(nameAgent)){
sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent());
}else {
sealSignRecordapply.setPensonAccount(caseAffiliate.getApplicationPhone());
}
EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply);
JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class);
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
String urlapply = signUrlData.get("shortUrl").getAsString();
String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1);
//发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信
SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
request.setTemplateId("2047719");
if(StringUtils.isNotBlank(nameAgent)){
request.setPhone(caseAffiliate.getContactTelphoneAgent());
request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), application.getCaseNum(),urlapplynew});
}else {
request.setPhone(caseAffiliate.getApplicationPhone());
request.setTemplateParamSet(new String[]{caseAffiliate.getApplicationName(), application.getCaseNum(),urlapplynew});
}
Boolean aBoolean = SmsUtils.sendSms(request);
SealSignRecord sealSignRecordRespon = new SealSignRecord();
sealSignRecordRespon.setSignFlowid(signFlowId);
sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone());
EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon);
JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class);
JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data");
String urlRespon = signUrlDataRespon.get("shortUrl").getAsString();
String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1);
SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest();
request1.setTemplateId("2047719");
request1.setPhone(caseAffiliate.getRespondentPhone());
request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), application.getCaseNum(),urlResponnew});
Boolean aBoolean1 = SmsUtils.sendSms(request1);
} else {
throw new ServiceException(jsonObject3.getString("message"));
}
} else {
return AjaxResult.error();
}
// 修改案件状态为待签名
Example flowExample = new Example(MsCaseFlow.class);
flowExample.createCriteria().andEqualTo("caseStatusName", "待签名");
MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample);
if(caseFlow != null){
application.setCaseFlowId(caseFlow.getId());
application.setCaseStatusName(caseFlow.getCaseStatusName());
}
application.setMediaResult(mediaResult);
msCaseApplicationMapper.updateByPrimaryKeySelective(application);
return AjaxResult.success();
}else{
return AjaxResult.error();
}
}else{
return AjaxResult.error();
}
}
break;
}
}
}
}
}
}
} else {
// 线下调解