Browse Source

feat(app): 新增合同管理功能

- 添加合同信息实体类 AppContractInfo 和对应的 Mapper
- 新增合同入参 DTO 类 AppContractInfoDTO
- 在 ESignApi 中添加合同相关接口,包括上传合同模板、制作模板、编辑合同、发起签署、下载已签署文件和合同列表查询
- 在 ESignServiceImpl 中实现合同相关接口的业务逻辑
- 更新 IESignService 接口,添加新的合同管理方法
SheepHy 2 days ago
parent
commit
da409a406f

+ 73 - 7
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/ESignApi.java

@@ -7,12 +7,13 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.app.esign.exception.EsignDemoException;
 import org.jeecg.modules.app.service.IESignService;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.jeecg.modules.system.app.dto.AppContractInfoDTO;
+import org.jeecg.modules.system.app.entity.AppContractInfo;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
 
 @Slf4j
 @Tag(name = "E签宝相关接口")
@@ -82,10 +83,10 @@ public class ESignApi {
      * @Param
      * @return
      **/
-    @GetMapping("/uploadContractTemplate")
+    @PostMapping("/uploadContractTemplate")
     @Operation(summary = "上传合同底稿-PC")
-    public Result<Boolean> uploadContractTemplate(@RequestParam("filePath") @Schema(description="上传文件路径")String filePath) throws EsignDemoException{
-        return Result.OK(iESignService.uploadContractTemplate(filePath));
+    public Result<Boolean> uploadContractTemplate(@RequestBody AppContractInfoDTO appContractInfoDTO) throws EsignDemoException{
+        return Result.OK(iESignService.uploadContractTemplate(appContractInfoDTO));
     }
 
     /**
@@ -100,4 +101,69 @@ public class ESignApi {
     public Result<String> getSignUrl(@RequestParam("signFlowId") @Schema(description="文件标识")String signFlowId) throws EsignDemoException{
         return Result.OK(iESignService.getSignUrl(signFlowId));
     }
+
+    /**
+     * @Author SheepHy
+     * @Description 制作模板
+     * @Date 14:47 2025/7/21
+     * @Param
+     * @return
+     **/
+    @GetMapping("/createTemplate")
+    @Operation(summary = "制作模板-PC")
+    public Result<String> createTemplate(@RequestParam("fileId") @Schema(description="文件标识")String fileId) throws EsignDemoException{
+        return Result.OK(iESignService.createTemplate(fileId));
+    }
+
+    /**
+     * @Author SheepHy
+     * @Description 编辑合同
+     * @Date 15:01 2025/7/21
+     * @Param
+     * @return
+     **/
+    @GetMapping("/editContract")
+    @Operation(summary = "编辑合同-PC")
+    public Result<String> editContract(@RequestParam("docTemplateId") @Schema(description="模板ID")String docTemplateId) throws EsignDemoException{
+        return Result.OK(iESignService.editContract(docTemplateId));
+    }
+
+    /**
+     * @Author SheepHy
+     * @Description 发起签署
+     * @Date 10:10 2025/7/21
+     * @Param
+     * @return
+     **/
+    @GetMapping("/createSign")
+    @Operation(summary = "发起签署-PC")
+    public Result<String> createSign(@RequestParam("fileId") @Schema(description="文件标识")String fileId) throws EsignDemoException{
+        return Result.OK(iESignService.createSign(fileId));
+    }
+
+    /**
+     * @Author SheepHy
+     * @Description 下载已签署文件及附属材料
+     * @Date 14:05 2025/7/28
+     * @Param
+     * @return
+     **/
+    @GetMapping("/fileDownloadUrl")
+    @Operation(summary = "下载已签署文件及附属材料-PC")
+    public Result<List<Map<String,String>>> fileDownloadUrl(@RequestParam("signFlowId") @Schema(description="文件标识")String signFlowId) throws EsignDemoException{
+        return Result.OK(iESignService.fileDownloadUrl(signFlowId));
+    }
+
+    /**
+     * @Author SheepHy
+     * @Description 合同列表查询
+     * @Date 15:09 2025/7/28
+     * @Param
+     * @return
+     **/
+    @GetMapping("/queryContractInfo")
+    @Operation(summary = "合同列表查询-PC")
+    public Result<List<AppContractInfo>> queryContractInfo(@RequestParam("contractName") @Schema(description="合同名称")String contractName){
+        return Result.OK(iESignService.queryContractInfo(contractName));
+    }
 }

+ 24 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/IESignService.java

@@ -1,6 +1,11 @@
 package org.jeecg.modules.app.service;
 
 import org.jeecg.modules.app.esign.exception.EsignDemoException;
+import org.jeecg.modules.system.app.dto.AppContractInfoDTO;
+import org.jeecg.modules.system.app.entity.AppContractInfo;
+
+import java.util.List;
+import java.util.Map;
 
 public interface IESignService {
     /**
@@ -47,7 +52,7 @@ public interface IESignService {
      * @Param
      * @return
      **/
-    boolean uploadContractTemplate(String filePath) throws EsignDemoException;
+    boolean uploadContractTemplate(AppContractInfoDTO appContractInfoDTO) throws EsignDemoException;
 
 
     /**
@@ -86,4 +91,22 @@ public interface IESignService {
      * @return
      **/
     String editContract(String docTemplateId) throws EsignDemoException;
+
+    /**
+     * @Author SheepHy
+     * @Description 下载已签署文件及附属材料
+     * @Date 14:05 2025/7/28
+     * @Param
+     * @return
+     **/
+    List<Map<String,String>> fileDownloadUrl(String signFlowId) throws EsignDemoException;
+
+    /**
+     * @Author SheepHy
+     * @Description 合同列表查询
+     * @Date 15:09 2025/7/28
+     * @Param
+     * @return
+     **/
+    List<AppContractInfo> queryContractInfo(String contractName);
 }

+ 54 - 6
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/ESignServiceImpl.java

@@ -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));
     }
 }
 

+ 23 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/dto/AppContractInfoDTO.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.system.app.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@AllArgsConstructor
+@NoArgsConstructor
+@Schema(description="合同入参DTO")
+public class AppContractInfoDTO {
+    @Schema(description = "备注")
+    private String remark;
+    @Schema(description = "合同名称")
+    private String contractName;
+    @Schema(description="上传文件路径")
+    private String filePath;
+}

+ 64 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppContractInfo.java

@@ -0,0 +1,64 @@
+package org.jeecg.modules.system.app.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+@Data
+@TableName("nm_contract_info")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description="合同信息")
+public class AppContractInfo {
+    /**id*/
+    @TableId(type = IdType.ASSIGN_ID)
+    @Schema(description = "id")
+    private String id;
+    @Schema(description = "部门编号")
+    private String orgCode;
+    @Schema(description = "第三方文件ID(E签宝)")
+    private String fileId;
+    @Schema(description = "回调页面")
+    private String redirectUrl;
+    @Schema(description = "备注")
+    private String remark;
+    @Schema(description = "合同名称")
+    private String contractName;
+    @Schema(description = "第三方模板ID(E签宝)")
+    private String docTemplateId;
+    /**创建人;创建人*/
+    @Schema(description = "创建人;创建人")
+    private String createBy;
+    /**创建时间;创建时间*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @Schema(description = "创建时间;创建时间")
+    private Date createTime;
+    /**更新人;更新人*/
+    @Schema(description = "更新人;更新人")
+    private String updateBy;
+    /**更新时间;更新时间*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @Schema(description = "更新时间;更新时间")
+    private Date updateTime;
+    /**系统状态;状态(0-正常,1-冻结)*/
+    @Excel(name = "系统状态;状态(0-正常,1-冻结)", width = 15)
+    @Schema(description = "系统状态;状态(0-正常,1-冻结)")
+    private Integer status;
+    /**删除标志;删除状态(0-正常,1-已删除)*/
+    @Excel(name = "删除标志;删除状态(0-正常,1-已删除)", width = 15)
+    @Schema(description = "删除标志;删除状态(0-正常,1-已删除)")
+    @TableLogic
+    private Integer delFlag;
+}

+ 7 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/AppContractInfoMapper.java

@@ -0,0 +1,7 @@
+package org.jeecg.modules.system.app.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.system.app.entity.AppContractInfo;
+
+public interface AppContractInfoMapper extends BaseMapper<AppContractInfo> {
+}