|
@@ -1,7 +1,10 @@
|
|
|
package org.jeecg.modules.app.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.google.gson.Gson;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
+import com.google.gson.JsonElement;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
@@ -13,11 +16,18 @@ import org.jeecg.modules.app.esign.exception.EsignDemoException;
|
|
|
import org.jeecg.modules.app.esign.fileAndTemplate.FileDemo;
|
|
|
import org.jeecg.modules.app.esign.sign.SignDemo;
|
|
|
import org.jeecg.modules.app.service.IESignService;
|
|
|
+import org.jeecg.modules.system.app.dto.AppContractInfoDTO;
|
|
|
+import org.jeecg.modules.system.app.entity.AppContractInfo;
|
|
|
+import org.jeecg.modules.system.app.mapper.AppContractInfoMapper;
|
|
|
import org.jeecg.modules.system.entity.SysUser;
|
|
|
import org.jeecg.modules.system.mapper.SysUserMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import static com.alibaba.dashscope.utils.JsonUtils.gson;
|
|
|
import static org.jeecg.modules.app.esign.auth.ESignAuth.*;
|
|
@@ -30,6 +40,8 @@ import static org.jeecg.modules.app.esign.sign.SignDemo.createByFile;
|
|
|
public class ESignServiceImpl implements IESignService {
|
|
|
@Resource
|
|
|
private SysUserMapper sysUserMapper;
|
|
|
+ @Resource
|
|
|
+ private AppContractInfoMapper appAccountMapper;
|
|
|
@Override
|
|
|
public boolean getUserIdentityInfo(String phoneNumber) throws EsignDemoException {
|
|
|
EsignHttpResponse getPsnIdentityInfo = getPsnIdentityInfo(phoneNumber);
|
|
@@ -68,14 +80,25 @@ public class ESignServiceImpl implements IESignService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean uploadContractTemplate(String filePath) throws EsignDemoException {
|
|
|
- EsignHttpResponse getUploadUrl = FileDemo.getUploadUrl(filePath);
|
|
|
+ public boolean uploadContractTemplate(AppContractInfoDTO appContractInfoDTO) throws EsignDemoException {
|
|
|
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ EsignHttpResponse getUploadUrl = FileDemo.getUploadUrl(appContractInfoDTO.getFilePath());
|
|
|
JsonObject getUploadUrlJsonObject = gson.fromJson(getUploadUrl.getBody(), JsonObject.class);
|
|
|
JsonObject data = getUploadUrlJsonObject.getAsJsonObject("data");
|
|
|
String fileUploadUrl =data.get("fileUploadUrl").getAsString();
|
|
|
- EsignHttpResponse uploadFileResponse = FileDemo.uploadFile(fileUploadUrl,filePath);
|
|
|
+ EsignHttpResponse uploadFileResponse = FileDemo.uploadFile(fileUploadUrl,appContractInfoDTO.getFilePath());
|
|
|
JsonObject uploadFileResponseJsonObject = gson.fromJson(uploadFileResponse.getBody(), JsonObject.class);
|
|
|
int errCode = uploadFileResponseJsonObject.get("errCode").getAsInt();
|
|
|
+ String fileId =data.get("fileId").getAsString();
|
|
|
+ appAccountMapper.insert(new AppContractInfo()
|
|
|
+ .setOrgCode(user.getOrgCode())
|
|
|
+ .setFileId(fileId)
|
|
|
+ .setContractName(appContractInfoDTO.getContractName())
|
|
|
+ .setRemark(appContractInfoDTO.getRemark())
|
|
|
+ .setCreateBy(user.getId())
|
|
|
+ .setCreateTime(new java.util.Date())
|
|
|
+ .setUpdateTime(new java.util.Date())
|
|
|
+ .setUpdateBy(user.getId()));
|
|
|
return errCode == 0;
|
|
|
}
|
|
|
|
|
@@ -85,7 +108,7 @@ public class ESignServiceImpl implements IESignService {
|
|
|
JSONObject createByFileJsonObject = JSONObject.parseObject(createByFile.getBody());
|
|
|
String signFlowId = createByFileJsonObject.getJSONObject("data").getString("signFlowId");
|
|
|
System.out.println("signFlowId:" + signFlowId);
|
|
|
- return "";
|
|
|
+ return signFlowId;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -105,7 +128,10 @@ public class ESignServiceImpl implements IESignService {
|
|
|
String docTemplateId = getTemplateCreateUrlObject.getAsJsonObject("data").get("docTemplateId").getAsString();
|
|
|
System.err.println("制作合同模板的页面链接:"+docTemplateCreateUrl);
|
|
|
System.err.println("合同模板id:"+docTemplateId);
|
|
|
- return "";
|
|
|
+ AppContractInfo appContractInfo = appAccountMapper.selectOne(Wrappers.<AppContractInfo>lambdaQuery().eq(AppContractInfo::getFileId, fileId));
|
|
|
+ appContractInfo.setDocTemplateId(docTemplateId);
|
|
|
+ appAccountMapper.updateById(appContractInfo);
|
|
|
+ return docTemplateCreateUrl;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -115,7 +141,29 @@ public class ESignServiceImpl implements IESignService {
|
|
|
JsonObject getTemplateEditUrlObject = gson.fromJson(getTemplateEditUrl.getBody(), JsonObject.class);
|
|
|
String docTemplateEditUrl = getTemplateEditUrlObject.getAsJsonObject("data").get("docTemplateEditUrl").getAsString();
|
|
|
System.err.println("编辑合同模板的页面链接:"+docTemplateEditUrl);
|
|
|
- return "";
|
|
|
+ return docTemplateEditUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String,String>> fileDownloadUrl(String signFlowId) throws EsignDemoException {
|
|
|
+ EsignHttpResponse esignHttpResponse = SignDemo.fileDownloadUrl(signFlowId);
|
|
|
+ JsonObject jsonObject = gson.fromJson(esignHttpResponse.getBody(), JsonObject.class);
|
|
|
+ JsonArray fileArray = jsonObject.getAsJsonObject("data").getAsJsonArray("files");
|
|
|
+ List<Map<String, String>> result = new ArrayList<>();
|
|
|
+ for (JsonElement element : fileArray) {
|
|
|
+ JsonObject fileObj = element.getAsJsonObject();
|
|
|
+ Map<String, String> fileMap = new HashMap<>();
|
|
|
+ fileMap.put("fileId", fileObj.get("fileId").getAsString());
|
|
|
+ fileMap.put("fileName", fileObj.get("fileName").getAsString());
|
|
|
+ fileMap.put("downloadUrl", fileObj.get("downloadUrl").getAsString());
|
|
|
+ result.add(fileMap);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<AppContractInfo> queryContractInfo(String contractName) {
|
|
|
+ return appAccountMapper.selectList(Wrappers.<AppContractInfo>lambdaQuery().like(AppContractInfo::getContractName,contractName));
|
|
|
}
|
|
|
}
|
|
|
|