Explorar o código

会计,验证章、执业章签章功能添加批量导出,自动带入上一阶段已签章文件
添加人员与契约锁系统人员关联功能

徐滕 hai 45 minutos
pai
achega
6104db1153
Modificáronse 24 ficheiros con 1258 adicións e 9 borrados
  1. 6 0
      docs/features/finance/报告执业签章.md
  2. 16 4
      docs/features/finance/报告验证章.md
  3. 7 4
      docs/features/finance/报告验证章_开发文档.md
  4. 45 0
      docs/sql/addsql/20261127__ddl_sys_office_qys_sync_flag.sql
  5. 5 0
      jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/factory/WorkAttachmentApiFallbackFactory.java
  6. 11 0
      jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/feign/IWorkAttachmentApi.java
  7. 38 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/dto/QysEmployeeSyncDTO.java
  8. 36 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/QysEmployeeApiFallbackFactory.java
  9. 35 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IQysEmployeeApi.java
  10. 5 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/domain/Office.java
  11. 5 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/service/dto/OfficeDTO.java
  12. 15 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/practiceSignature/controller/CwPracticeSignatureController.java
  13. 291 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/practiceSignature/service/CwPracticeSignatureService.java
  14. 21 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/practiceSignature/service/dto/CwPracticeSignatureBatchDownloadDTO.java
  15. 16 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/controller/CwReportVerificationSealController.java
  16. 52 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/controller/QiyuesuoEmployeeController.java
  17. 300 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/service/CwReportVerificationSealService.java
  18. 115 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/service/QiyuesuoEmployeeService.java
  19. 64 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/service/QiyuesuoVerificationPayloadBuilder.java
  20. 21 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/service/dto/CwReportVerificationSealBatchDownloadDTO.java
  21. 4 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/feign/WorkAttachmentApiImpl.java
  22. 1 1
      jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/feign/UserApiImpl.java
  23. 2 0
      jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/xml/OfficeMapper.xml
  24. 147 0
      jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/service/UserService.java

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 6 - 0
docs/features/finance/报告执业签章.md


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 16 - 4
docs/features/finance/报告验证章.md


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 4
docs/features/finance/报告验证章_开发文档.md


+ 45 - 0
docs/sql/addsql/20261127__ddl_sys_office_qys_sync_flag.sql

@@ -0,0 +1,45 @@
+-- ============================================================================
+-- 报告验证章 · 人员同步契约锁 · sys_office 新增「同步契约锁人员」标记列
+-- 用途:在机构(部门)上打标,勾选后该机构及其所有下级机构的人员,在人员保存
+--       且允许登录时自动同步为契约锁内部企业员工;禁止登录/删除用户时移出企业。
+--       只应勾选「江苏兴光会计师事务所有限责任公司」(会计主体 tenant 10003)下的机构,
+--       勾到评估/中审机构会把人员加到会计事务所的契约锁主体下。
+-- 取值:'0'=不同步(默认)/'1'=同步;字典沿用 yes_no,不新建字典类型。
+-- 幂等:ALTER TABLE ADD COLUMN 本身不幂等,这里先用 information_schema 判断列是否
+--       存在,已存在就跳过、不报错,可整段重复执行。
+-- 存量:ADD COLUMN ... DEFAULT '0' 会把已有行一并填成 '0';存量人员不批量补建,
+--       下一次保存/启停登录时自动补建(2026-11-27 用户拍板)。
+-- 风险:sys_office 行数约百级,MySQL 8.0 走 INSTANT DDL、秒级完成;5.7 为 INPLACE
+--       且不锁读,低峰期执行即可。
+-- 回滚:本脚本不含 DROP COLUMN / TRUNCATE / DELETE。要回滚请人工确认后单独执行
+--       ALTER TABLE sys_office DROP COLUMN qys_sync_flag;(会丢标记数据)。
+-- 关联:docs/features/finance/报告验证章.md 11.2;列必须先于代码上线。
+-- author: 徐滕  2026-11-27
+-- ============================================================================
+
+SET NAMES utf8mb4;
+
+SET @db := DATABASE();
+
+SELECT COUNT(*) INTO @col_exists
+  FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = @db
+   AND TABLE_NAME   = 'sys_office'
+   AND COLUMN_NAME  = 'qys_sync_flag';
+
+SET @ddl := IF(
+    @col_exists = 0,
+    'ALTER TABLE sys_office ADD COLUMN qys_sync_flag char(1) DEFAULT ''0'' COMMENT ''是否同步契约锁人员(0:否,1:是;勾选机构含下级)''',
+    'SELECT ''qys_sync_flag 已存在,本次跳过'' AS msg'
+);
+
+PREPARE stmt FROM @ddl;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+-- 执行后自检:应输出 1 行,COLUMN_DEFAULT = 0
+SELECT COLUMN_NAME, COLUMN_TYPE, COLUMN_DEFAULT, COLUMN_COMMENT
+  FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = DATABASE()
+   AND TABLE_NAME   = 'sys_office'
+   AND COLUMN_NAME  = 'qys_sync_flag';

+ 5 - 0
jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/factory/WorkAttachmentApiFallbackFactory.java

@@ -150,6 +150,11 @@ public class WorkAttachmentApiFallbackFactory implements FallbackFactory <IWorkA
                 return null;
             }
 
+            @Override
+            public String getTemporaryUrl(String url) {
+                return null;
+            }
+
         };
     }
 }

+ 11 - 0
jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/feign/IWorkAttachmentApi.java

@@ -234,6 +234,17 @@ public interface IWorkAttachmentApi {
      */
     @PostMapping("/oss/file/getByAttachmentIdListAndFlag")
     List<WorkAttachmentInfo> getByAttachmentIdListAndFlag(@RequestParam(value = "ids")List<String> ids);
+
+    /**
+     * 根据url获取临时文件地址
+     *
+     * 批量下载用:跨服务只返回临时签名地址字符串,文件流由调用方直接 HTTP 拉 OSS,
+     * 不走 downBytesByStream / downloadFolderFromOss 这类跨服务返回文件流的老接口。
+     * @param url 相对路径(不含域名),如 file/xxx/xxx.zip
+     * @return 临时签名地址
+     */
+    @GetMapping("/oss/file/getTemporaryUrl")
+    String getTemporaryUrl(@RequestParam(value = "url")String url);
 }
 
 

+ 38 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/dto/QysEmployeeSyncDTO.java

@@ -0,0 +1,38 @@
+package com.jeeplus.flowable.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 契约锁员工同步参数(system 服务内部 Feign 调 finance 用)
+ *
+ * @author: 徐滕
+ * @version: 2026-11-27 10:00
+ */
+@Data
+public class QysEmployeeSyncDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 系统用户id,仅用于日志定位,不参与契约锁调用
+     */
+    private String userId;
+
+    /**
+     * 姓名
+     */
+    private String name;
+
+    /**
+     * 手机号,契约锁按此定位个人账号、建内部员工
+     */
+    private String mobile;
+
+    /**
+     * 租户id,仅用于日志定位
+     */
+    private String tenantId;
+
+}

+ 36 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/QysEmployeeApiFallbackFactory.java

@@ -0,0 +1,36 @@
+package com.jeeplus.flowable.factory;
+
+import com.jeeplus.flowable.dto.QysEmployeeSyncDTO;
+import com.jeeplus.flowable.feign.IQysEmployeeApi;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * 契约锁员工同步服务降级处理:外部同步失败不影响人员保存,等下一次保存/启停自动重试
+ *
+ * @author: 徐滕
+ * @version: 2026-11-27 10:00
+ */
+@Slf4j
+@Component
+public class QysEmployeeApiFallbackFactory implements FallbackFactory<IQysEmployeeApi> {
+
+    @Override
+    public IQysEmployeeApi create(Throwable cause) {
+        log.error("契约锁员工同步服务调用失败:{}", cause.getMessage());
+        return new IQysEmployeeApi() {
+
+            @Override
+            public void ensureEmployee(QysEmployeeSyncDTO dto) {
+
+            }
+
+            @Override
+            public void removeEmployee(QysEmployeeSyncDTO dto) {
+
+            }
+
+        };
+    }
+}

+ 35 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IQysEmployeeApi.java

@@ -0,0 +1,35 @@
+package com.jeeplus.flowable.feign;
+
+import com.jeeplus.common.constant.AppNameConstants;
+import com.jeeplus.flowable.dto.QysEmployeeSyncDTO;
+import com.jeeplus.flowable.factory.QysEmployeeApiFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * 契约锁员工同步(system -> finance)
+ *
+ * @author: 徐滕
+ * @version: 2026-11-27 10:00
+ */
+@FeignClient(contextId = "qysEmployeeApi", name = AppNameConstants.APP_FINANCE_MODULES, fallbackFactory = QysEmployeeApiFallbackFactory.class)
+public interface IQysEmployeeApi {
+
+    /**
+     * 确保人员在契约锁企业内(已是企业员工则跳过)
+     *
+     * @param dto 同步参数
+     */
+    @PostMapping(value = "/qiyuesuoEmployee/ensure")
+    void ensureEmployee(@RequestBody QysEmployeeSyncDTO dto);
+
+    /**
+     * 将人员移出契约锁企业(个人账号保留)
+     *
+     * @param dto 同步参数
+     */
+    @PostMapping(value = "/qiyuesuoEmployee/remove")
+    void removeEmployee(@RequestBody QysEmployeeSyncDTO dto);
+
+}

+ 5 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/domain/Office.java

@@ -82,6 +82,11 @@ public class Office extends TreeEntity <Office> {
     private String useable;
 
     /**
+     * 是否同步契约锁人员(0:否,1:是),勾选后该机构及下级机构的人员随保存/启停登录同步
+     */
+    private String qysSyncFlag;
+
+    /**
      * 备注
      */
     private String remarks;

+ 5 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/sys/service/dto/OfficeDTO.java

@@ -92,6 +92,11 @@ public class OfficeDTO extends TreeDTO <OfficeDTO> {
     private String useable;
 
     /**
+     * 是否同步契约锁人员(0:否,1:是),勾选后该机构及下级机构的人员随保存/启停登录同步
+     */
+    private String qysSyncFlag;
+
+    /**
      * 备注
      */
     private String remarks;

+ 15 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/practiceSignature/controller/CwPracticeSignatureController.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jeeplus.common.utils.ResponseUtil;
 import com.jeeplus.finance.practiceSignature.service.CwPracticeSignatureService;
 import com.jeeplus.finance.practiceSignature.service.dto.CwPracticeSignStatusDTO;
+import com.jeeplus.finance.practiceSignature.service.dto.CwPracticeSignatureBatchDownloadDTO;
 import com.jeeplus.finance.practiceSignature.service.dto.CwPracticeSignatureDTO;
 import com.jeeplus.finance.practiceSignature.service.dto.CwPracticeSignatureReportDTO;
 import com.jeeplus.finance.practiceSignature.service.dto.CwPracticeSignatureSealedFileDTO;
@@ -246,4 +247,18 @@ public class CwPracticeSignatureController {
         cwPracticeSignatureService.downloadSignedFiles(id, response);
     }
 
+    /**
+     * 批量下载已盖章件:只打包完成(状态5)且有已盖章件的单,单次上限 20 单
+     * 全部不可打包时回 JSON 错误体;部分跳过时把原因写进 zip 内《下载说明.txt》
+     * @param dto 选中的申请id集合
+     * @param response 响应(zip 流)
+     * @throws Exception 异常
+     */
+    @ApiLog(value = "批量下载报告执业签章已盖章件", type = LogTypeEnum.EXPORT)
+    // @PreAuthorize("hasAnyAuthority('cw:practiceSignature:signed')")
+    @PostMapping("downloadSignedFilesBatch")
+    public void downloadSignedFilesBatch(@RequestBody CwPracticeSignatureBatchDownloadDTO dto, HttpServletResponse response) throws Exception {
+        cwPracticeSignatureService.downloadSignedFilesBatch(dto, response);
+    }
+
 }

+ 291 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/practiceSignature/service/CwPracticeSignatureService.java

@@ -24,6 +24,7 @@ import com.jeeplus.finance.practiceSignature.mapper.CwPracticeSignatureFileMappe
 import com.jeeplus.finance.practiceSignature.mapper.CwPracticeSignatureMapper;
 import com.jeeplus.finance.practiceSignature.mapper.CwPracticeSignatureReportMapper;
 import com.jeeplus.finance.practiceSignature.mapper.CwPracticeSignatureSignerMapper;
+import com.jeeplus.finance.practiceSignature.service.dto.CwPracticeSignatureBatchDownloadDTO;
 import com.jeeplus.finance.practiceSignature.service.dto.CwPracticeSignatureDTO;
 import com.jeeplus.finance.practiceSignature.service.dto.CwPracticeSignStatusDTO;
 import com.jeeplus.finance.practiceSignature.service.dto.CwPracticeSignatureReportDTO;
@@ -48,6 +49,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletResponse;
@@ -60,13 +62,16 @@ import java.util.zip.ZipOutputStream;
 
 import javax.annotation.Resource;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -77,6 +82,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 /**
  * 报告执业签章service
@@ -203,6 +209,11 @@ public class CwPracticeSignatureService extends ServiceImpl<CwPracticeSignatureM
     private static final String STATUS_SIGNING = "6";
 
     /**
+     * 批量下载单次上限:防止一次勾全量把服务器临时目录和带宽打满,超出让前端分批
+     */
+    private static final int BATCH_DOWNLOAD_MAX = 20;
+
+    /**
      * 契约锁合同详情回退查询的节流窗口(秒)。
      *
      * 主判据是"读库"(回调写的本人签署结果),详情查询只是库里没结论时的回退,
@@ -2321,6 +2332,286 @@ public class CwPracticeSignatureService extends ServiceImpl<CwPracticeSignatureM
     }
 
     /**
+     * 批量下载已盖章件(列表页多选,只打包完成(5)且有件的单)
+     *
+     * 只打包 signed_zip_url 这一份"下载件":单文件时它就是已盖章件本身,多文件时是回调打好的整包 zip,
+     * 跟列表页逐个【下载】拿到的内容完全一致,不含原件。
+     *
+     * 跨服务只取临时签名地址(字符串),文件字节由本进程 HTTP 直拉 OSS,
+     * 不走 downBytesByStream / downloadFolderFromOss 这类跨服务返回文件流的老接口(历史上出过问题)。
+     * 先把每个件拉到本地临时目录再统一打包:单个失败不中断整包,跳过原因写进 zip 内《下载说明.txt》,
+     * 全部失败则回 JSON 错误体,前端按 blob 解析提示。
+     *
+     * @param dto 选中的申请id集合
+     * @param response 响应(zip 流或 JSON 错误体)
+     * @throws Exception IO 或调用异常
+     */
+    // 只读且要边下载边写响应,可能持续几十秒:挂起类级事务,避免整个下载期间占用数据库连接
+    @Transactional(propagation = Propagation.NOT_SUPPORTED)
+    public void downloadSignedFilesBatch(CwPracticeSignatureBatchDownloadDTO dto, HttpServletResponse response) throws Exception {
+        List<String> ids = dto == null || dto.getIds() == null ? new ArrayList<>()
+                : dto.getIds().stream().filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
+        if (ids.isEmpty()) {
+            writeBatchDownloadError(response, "请选择需要下载的申请");
+            return;
+        }
+        if (ids.size() > BATCH_DOWNLOAD_MAX) {
+            writeBatchDownloadError(response, "单次批量下载不能超过 " + BATCH_DOWNLOAD_MAX + " 条,请分批下载");
+            return;
+        }
+        Map<String, CwPracticeSignature> mainMap = new HashMap<>();
+        for (CwPracticeSignature main : this.listByIds(ids)) {
+            mainMap.put(main.getId(), main);
+        }
+        List<String> failures = new ArrayList<>();
+        int missing = 0;
+        List<CwPracticeSignature> packable = new ArrayList<>();
+        for (String id : ids) {
+            CwPracticeSignature main = mainMap.get(id);
+            if (main == null) {
+                missing++;
+                continue;
+            }
+            if (!STATUS_FINISHED.equals(main.getStatus())) {
+                failures.add(batchDownloadLabel(main) + ":未到完成状态,已跳过");
+                continue;
+            }
+            if (StringUtils.isBlank(main.getSignedZipUrl())) {
+                failures.add(batchDownloadLabel(main) + ":已盖章文件还在生成中,请稍后重试");
+                continue;
+            }
+            packable.add(main);
+        }
+        if (missing > 0) {
+            failures.add("另有 " + missing + " 条申请不存在或已被删除,已跳过");
+        }
+        if (packable.isEmpty()) {
+            writeBatchDownloadError(response, "选中的申请都没有可下载的已盖章件:" + String.join(";", failures));
+            return;
+        }
+
+        File tempDir = new File(localTempDir() + "practice_signature_batch");
+        if (!tempDir.exists() && !tempDir.mkdirs()) {
+            writeBatchDownloadError(response, "服务器临时目录创建失败,请稍后重试");
+            return;
+        }
+        List<CwPracticeSignature> ready = new ArrayList<>();
+        Map<String, File> unitFiles = new LinkedHashMap<>();
+        try {
+            for (CwPracticeSignature main : packable) {
+                File target = new File(tempDir, main.getId() + ".download");
+                try {
+                    String temporaryUrl = SpringUtil.getBean(IWorkAttachmentApi.class).getTemporaryUrl(main.getSignedZipUrl());
+                    if (StringUtils.isBlank(temporaryUrl)) {
+                        failures.add(batchDownloadLabel(main) + ":取下载地址失败");
+                        continue;
+                    }
+                    long size = downloadToLocalFile(temporaryUrl, target);
+                    if (size <= 0) {
+                        failures.add(batchDownloadLabel(main) + ":文件内容为空");
+                        continue;
+                    }
+                    ready.add(main);
+                    unitFiles.put(main.getId(), target);
+                } catch (Exception e) {
+                    log.error("报告执业签章批量下载:拉取已盖章件失败,id={}", main.getId(), e);
+                    failures.add(batchDownloadLabel(main) + ":文件拉取失败,请单独重试");
+                }
+            }
+            if (ready.isEmpty()) {
+                writeBatchDownloadError(response, "选中的申请都没有可下载的已盖章件:" + String.join(";", failures));
+                return;
+            }
+
+            String zipName = "报告执业签章已盖章件_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip";
+            String encodedName = URLEncoder.encode(zipName, "UTF-8").replace("+", "%20");
+            response.reset();
+            response.setContentType("application/zip");
+            response.setCharacterEncoding("UTF-8");
+            response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedName + "\"; filename*=UTF-8''" + encodedName);
+
+            Map<String, Integer> usedNames = new HashMap<>();
+            ZipOutputStream zos = new ZipOutputStream(response.getOutputStream(), StandardCharsets.UTF_8);
+            try {
+                for (CwPracticeSignature main : ready) {
+                    writeFileToZip(zos, unitFiles.get(main.getId()), buildBatchEntryName(main, usedNames));
+                }
+                if (!failures.isEmpty()) {
+                    writeTextToZip(zos, "下载说明.txt", buildBatchDownloadNote(failures));
+                }
+                zos.finish();
+                zos.flush();
+            } finally {
+                zos.close();
+            }
+            log.info("报告执业签章批量下载完成:打包 {} 单,跳过 {} 条", ready.size(), failures.size());
+        } finally {
+            for (File file : unitFiles.values()) {
+                deleteLocalFile(file.getPath());
+            }
+        }
+    }
+
+    /**
+     * HTTP 直拉 OSS 临时签名地址到本地临时文件(不跨服务传文件流)
+     *
+     * @param url 临时签名地址
+     * @param target 本地临时文件
+     * @return 写入字节数
+     * @throws Exception 网络或 IO 异常
+     */
+    private long downloadToLocalFile(String url, File target) throws Exception {
+        HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
+        connection.setConnectTimeout(10000);
+        connection.setReadTimeout(120000);
+        connection.setRequestMethod("GET");
+        try {
+            int code = connection.getResponseCode();
+            if (code != HttpURLConnection.HTTP_OK) {
+                throw new IOException("下载已盖章件返回 HTTP " + code);
+            }
+            InputStream in = connection.getInputStream();
+            try {
+                OutputStream out = new FileOutputStream(target);
+                try {
+                    byte[] buffer = new byte[8192];
+                    long total = 0L;
+                    int len;
+                    while ((len = in.read(buffer)) != -1) {
+                        out.write(buffer, 0, len);
+                        total += len;
+                    }
+                    return total;
+                } finally {
+                    out.close();
+                }
+            } finally {
+                in.close();
+            }
+        } finally {
+            connection.disconnect();
+        }
+    }
+
+    /**
+     * 把一个本地临时文件写进 zip 的一个条目
+     *
+     * @param zos zip 流
+     * @param file 本地文件
+     * @param entryName 条目名
+     * @throws Exception IO 异常
+     */
+    private void writeFileToZip(ZipOutputStream zos, File file, String entryName) throws Exception {
+        zos.putNextEntry(new ZipEntry(entryName));
+        InputStream in = new FileInputStream(file);
+        try {
+            byte[] buffer = new byte[8192];
+            int len;
+            while ((len = in.read(buffer)) != -1) {
+                zos.write(buffer, 0, len);
+            }
+        } finally {
+            in.close();
+            zos.closeEntry();
+        }
+    }
+
+    /**
+     * 把文本内容写进 zip 的一个条目(条目内容统一 UTF-8)
+     *
+     * @param zos zip 流
+     * @param entryName 条目名
+     * @param content 文本内容
+     * @throws Exception IO 异常
+     */
+    private void writeTextToZip(ZipOutputStream zos, String entryName, String content) throws Exception {
+        zos.putNextEntry(new ZipEntry(entryName));
+        try {
+            zos.write(content.getBytes(StandardCharsets.UTF_8));
+        } finally {
+            zos.closeEntry();
+        }
+    }
+
+    /**
+     * 批量下载时给人看的单元名:报告号 + 项目名,不出现 id
+     *
+     * @param main 单据
+     * @return 展示名
+     */
+    private String batchDownloadLabel(CwPracticeSignature main) {
+        return StringUtils.defaultIfBlank(main.getReportNo(), "(无报告号)")
+                + " " + StringUtils.defaultIfBlank(main.getProjectName(), "(无项目名)");
+    }
+
+    /**
+     * 拼批量下载 zip 内的单元文件名"报告号_项目名.扩展名":去掉文件系统非法字符,扩展名取自下载件地址,重名补序号
+     *
+     * @param main 单据
+     * @param usedNames 已用文件名计数
+     * @return 条目名
+     */
+    private String buildBatchEntryName(CwPracticeSignature main, Map<String, Integer> usedNames) {
+        String extension = "";
+        String url = StringUtils.defaultIfBlank(main.getSignedZipUrl(), "");
+        String segment = url.substring(url.lastIndexOf('/') + 1);
+        int dot = segment.lastIndexOf('.');
+        if (dot >= 0) {
+            String raw = segment.substring(dot + 1);
+            if (raw.matches("[A-Za-z0-9]{1,10}")) {
+                extension = "." + raw.toLowerCase();
+            }
+        }
+        String base = StringUtils.defaultIfBlank(main.getReportNo(), "") + "_" + StringUtils.defaultIfBlank(main.getProjectName(), "");
+        base = base.replaceAll("[\\\\/:*?\"<>|\\r\\n]", "_").replaceAll("^_+|_+$", "");
+        if (StringUtils.isBlank(base)) {
+            base = "报告执业签章";
+        }
+        if (base.length() > 80) {
+            base = base.substring(0, 80);
+        }
+        Integer count = usedNames.get(base);
+        usedNames.put(base, count == null ? 1 : count + 1);
+        return count == null ? base + extension : base + "(" + (count + 1) + ")" + extension;
+    }
+
+    /**
+     * 批量下载跳过清单,写进 zip 内的《下载说明.txt》
+     *
+     * @param failures 跳过原因
+     * @return 说明文本
+     */
+    private String buildBatchDownloadNote(List<String> failures) {
+        StringBuilder note = new StringBuilder("以下申请未打包进本压缩包,请核对后单独下载:\r\n");
+        for (String failure : failures) {
+            note.append("- ").append(failure).append("\r\n");
+        }
+        return note.toString();
+    }
+
+    /**
+     * 批量下载的 JSON 错误体(前端以 blob 接收,按 400 解析出 message 提示)
+     *
+     * @param response 响应
+     * @param message 提示文案
+     * @throws IOException 写响应异常
+     */
+    private void writeBatchDownloadError(HttpServletResponse response, String message) throws IOException {
+        if (response.isCommitted()) {
+            log.warn("报告执业签章批量下载:响应已提交,无法回写错误提示,message={}", message);
+            return;
+        }
+        response.reset();
+        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+        response.setContentType("application/json;charset=utf-8");
+        Map<String, Object> body = new HashMap<>();
+        body.put("code", 400);
+        body.put("message", message);
+        response.getWriter().write(JSON.toJSONString(body));
+        response.getWriter().flush();
+    }
+
+    /**
      * 根据文件名推断 MIME 类型(下载单文件时用来设置 Content-Type,让浏览器能直接预览 PDF 等)
      */
     private String getContentTypeByFileName(String fileName) {

+ 21 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/practiceSignature/service/dto/CwPracticeSignatureBatchDownloadDTO.java

@@ -0,0 +1,21 @@
+package com.jeeplus.finance.practiceSignature.service.dto;
+
+import com.jeeplus.core.service.dto.BaseDTO;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 报告执业签章批量下载入参
+ * @author: 徐滕
+ * @version: 2026-11-27 10:30
+ */
+@Data
+public class CwPracticeSignatureBatchDownloadDTO extends BaseDTO {
+
+    private static final long serialVersionUID = 1L;
+
+    /** 选中的申请id集合(列表页多选,只打包完成且有已盖章件的单) */
+    private List<String> ids;
+
+}

+ 16 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/controller/CwReportVerificationSealController.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jeeplus.common.utils.ResponseUtil;
 import com.jeeplus.finance.reportVerificationSeal.service.CwReportVerificationSealService;
+import com.jeeplus.finance.reportVerificationSeal.service.dto.CwReportVerificationSealBatchDownloadDTO;
 import com.jeeplus.finance.reportVerificationSeal.service.dto.CwReportVerificationSealCarriedFilesDTO;
 import com.jeeplus.finance.reportVerificationSeal.service.dto.CwReportVerificationSealDTO;
 import com.jeeplus.finance.reportVerificationSeal.service.dto.CwReportVerificationSealReportCheckDTO;
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
 /**
@@ -202,6 +204,20 @@ public class CwReportVerificationSealController {
     }
 
     /**
+     * 批量下载选中申请的已盖章件:只打包完成(状态5)且有件的单,单次上限 20 单
+     * 全部不可打包时回 JSON 错误体;部分跳过时把原因写进 zip 内《下载说明.txt》
+     * @param dto 选中的申请id集合
+     * @param response 响应(zip 流)
+     * @throws Exception 异常
+     */
+    @ApiLog(value = "批量下载报告验证章已盖章件", type = LogTypeEnum.EXPORT)
+    // @PreAuthorize("hasAuthority('cw:reportVerificationSeal:download')")
+    @PostMapping("downloadSignedFilesBatch")
+    public void downloadSignedFilesBatch(@RequestBody CwReportVerificationSealBatchDownloadDTO dto, HttpServletResponse response) throws Exception {
+        cwReportVerificationSealService.downloadSignedFilesBatch(dto, response);
+    }
+
+    /**
      * 逻辑删除本人暂存或已撤回的申请(del_flag 置 1,列表不再展示),文件同步逻辑删除
      * @param ids 逗号分隔的申请id
      * @return 删除结果

+ 52 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/controller/QiyuesuoEmployeeController.java

@@ -0,0 +1,52 @@
+package com.jeeplus.finance.reportVerificationSeal.controller;
+
+import com.jeeplus.flowable.dto.QysEmployeeSyncDTO;
+import com.jeeplus.finance.reportVerificationSeal.service.QiyuesuoEmployeeService;
+import io.swagger.annotations.Api;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * 契约锁员工同步controller(system 服务内部 Feign 调用,不在前端暴露)
+ *
+ * @author: 徐滕
+ * @version: 2026-11-27 10:00
+ */
+@RestController
+@Api("契约锁员工同步")
+@RequestMapping(value = "/qiyuesuoEmployee")
+public class QiyuesuoEmployeeController {
+
+    @Resource
+    private QiyuesuoEmployeeService qiyuesuoEmployeeService;
+
+    /**
+     * 确保人员在契约锁企业内(标记部门且允许登录时调用)
+     *
+     * @param dto 同步参数
+     * @return 操作结果
+     */
+    @PostMapping("ensure")
+    public ResponseEntity ensure(@RequestBody QysEmployeeSyncDTO dto) {
+        qiyuesuoEmployeeService.ensureEmployee(dto);
+        return ResponseEntity.ok("操作成功");
+    }
+
+    /**
+     * 将人员移出契约锁企业(禁止登录或删除用户时调用)
+     *
+     * @param dto 同步参数
+     * @return 操作结果
+     */
+    @PostMapping("remove")
+    public ResponseEntity remove(@RequestBody QysEmployeeSyncDTO dto) {
+        qiyuesuoEmployeeService.removeEmployee(dto);
+        return ResponseEntity.ok("操作成功");
+    }
+
+}

+ 300 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/service/CwReportVerificationSealService.java

@@ -17,6 +17,7 @@ import com.jeeplus.finance.reportVerificationSeal.domain.CwReportVerificationSea
 import com.jeeplus.finance.reportVerificationSeal.domain.CwReportVerificationSealFile;
 import com.jeeplus.finance.reportVerificationSeal.mapper.CwReportVerificationSealFileMapper;
 import com.jeeplus.finance.reportVerificationSeal.mapper.CwReportVerificationSealMapper;
+import com.jeeplus.finance.reportVerificationSeal.service.dto.CwReportVerificationSealBatchDownloadDTO;
 import com.jeeplus.finance.reportVerificationSeal.service.dto.CwReportVerificationSealCarriedFilesDTO;
 import com.jeeplus.finance.reportVerificationSeal.service.dto.CwReportVerificationSealDTO;
 import com.jeeplus.finance.reportVerificationSeal.service.dto.CwReportVerificationSealFileDTO;
@@ -40,15 +41,30 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
 
 /**
  * 报告验证章service
@@ -162,6 +178,9 @@ public class CwReportVerificationSealService extends ServiceImpl<CwReportVerific
      */
     private static final List<String> DELETABLE_STATUS = Arrays.asList(STATUS_DRAFT, STATUS_WITHDRAWN);
 
+    /** 批量下载单次上限(整包偏大,一次 20 单;数电票批量下载是 25) */
+    private static final int BATCH_DOWNLOAD_MAX = 20;
+
     @Resource
     private CwReportVerificationSealMapper cwReportVerificationSealMapper;
 
@@ -691,6 +710,287 @@ public class CwReportVerificationSealService extends ServiceImpl<CwReportVerific
     }
 
     /**
+     * 批量下载已盖章件(列表页多选,只打包完成(5)且有件的单)
+     *
+     * 只打包 signed_zip_url 这一份"下载件":单文件时它就是已盖章件本身,多文件时是回调打好的整包 zip,
+     * 内层统一按"报告号_项目名.zip"命名直接嵌套,跟列表页逐个【下载】拿到的内容完全一致,不含原件。
+     *
+     * 跨服务只取临时签名地址(字符串),文件字节由本进程 HTTP 直拉 OSS,
+     * 不走 downBytesByStream / downloadFolderFromOss 这类跨服务返回文件流的老接口(历史上出过问题)。
+     * 先把每个件拉到本地临时目录再统一打包:单个失败不中断整包,跳过原因写进 zip 内《下载说明.txt》,
+     * 全部失败则回 JSON 错误体,前端按 blob 解析提示。
+     *
+     * @param dto 选中的申请id集合
+     * @param response 响应(zip 流或 JSON 错误体)
+     * @throws Exception IO 或调用异常
+     */
+    // 只读且要边下载边写响应,可能持续几十秒:挂起类级事务,避免整个下载期间占用数据库连接
+    @Transactional(propagation = Propagation.NOT_SUPPORTED)
+    public void downloadSignedFilesBatch(CwReportVerificationSealBatchDownloadDTO dto, HttpServletResponse response) throws Exception {
+        List<String> ids = dto == null || dto.getIds() == null ? new ArrayList<>()
+                : dto.getIds().stream().filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
+        if (ids.isEmpty()) {
+            writeBatchDownloadError(response, "请选择需要下载的申请");
+            return;
+        }
+        if (ids.size() > BATCH_DOWNLOAD_MAX) {
+            writeBatchDownloadError(response, "单次批量下载不能超过 " + BATCH_DOWNLOAD_MAX + " 条,请分批下载");
+            return;
+        }
+        Map<String, CwReportVerificationSeal> mainMap = new HashMap<>();
+        for (CwReportVerificationSeal main : this.listByIds(ids)) {
+            mainMap.put(main.getId(), main);
+        }
+        List<String> failures = new ArrayList<>();
+        int missing = 0;
+        List<CwReportVerificationSeal> packable = new ArrayList<>();
+        for (String id : ids) {
+            CwReportVerificationSeal main = mainMap.get(id);
+            if (main == null) {
+                missing++;
+                continue;
+            }
+            if (!STATUS_REVIEW_PASSED.equals(main.getStatus())) {
+                failures.add(batchDownloadLabel(main) + ":未到完成状态,已跳过");
+                continue;
+            }
+            if (StringUtils.isBlank(main.getSignedZipUrl())) {
+                failures.add(batchDownloadLabel(main) + ":已盖章文件还在生成中,请稍后重试");
+                continue;
+            }
+            packable.add(main);
+        }
+        if (missing > 0) {
+            failures.add("另有 " + missing + " 条申请不存在或已被删除,已跳过");
+        }
+        if (packable.isEmpty()) {
+            writeBatchDownloadError(response, "选中的申请都没有可下载的已盖章件:" + String.join(";", failures));
+            return;
+        }
+
+        File tempDir = new File(localTempDir() + "report_verification_seal_batch");
+        if (!tempDir.exists() && !tempDir.mkdirs()) {
+            writeBatchDownloadError(response, "服务器临时目录创建失败,请稍后重试");
+            return;
+        }
+        List<CwReportVerificationSeal> ready = new ArrayList<>();
+        Map<String, File> unitFiles = new LinkedHashMap<>();
+        try {
+            for (CwReportVerificationSeal main : packable) {
+                File target = new File(tempDir, main.getId() + ".download");
+                try {
+                    String temporaryUrl = SpringUtil.getBean(IWorkAttachmentApi.class).getTemporaryUrl(main.getSignedZipUrl());
+                    if (StringUtils.isBlank(temporaryUrl)) {
+                        failures.add(batchDownloadLabel(main) + ":取下载地址失败");
+                        continue;
+                    }
+                    long size = downloadToLocalFile(temporaryUrl, target);
+                    if (size <= 0) {
+                        failures.add(batchDownloadLabel(main) + ":文件内容为空");
+                        continue;
+                    }
+                    ready.add(main);
+                    unitFiles.put(main.getId(), target);
+                } catch (Exception e) {
+                    log.error("报告验证章批量下载:拉取已盖章件失败,id={}", main.getId(), e);
+                    failures.add(batchDownloadLabel(main) + ":文件拉取失败,请单独重试");
+                }
+            }
+            if (ready.isEmpty()) {
+                writeBatchDownloadError(response, "选中的申请都没有可下载的已盖章件:" + String.join(";", failures));
+                return;
+            }
+
+            String zipName = "报告验证章已盖章件_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip";
+            String encodedName = URLEncoder.encode(zipName, "UTF-8").replace("+", "%20");
+            response.reset();
+            response.setContentType("application/zip");
+            response.setCharacterEncoding("UTF-8");
+            response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedName + "\"; filename*=UTF-8''" + encodedName);
+
+            Map<String, Integer> usedNames = new HashMap<>();
+            ZipOutputStream zos = new ZipOutputStream(response.getOutputStream(), StandardCharsets.UTF_8);
+            try {
+                for (CwReportVerificationSeal main : ready) {
+                    writeFileToZip(zos, unitFiles.get(main.getId()), buildBatchEntryName(main, usedNames));
+                }
+                if (!failures.isEmpty()) {
+                    writeTextToZip(zos, "下载说明.txt", buildBatchDownloadNote(failures));
+                }
+                zos.finish();
+                zos.flush();
+            } finally {
+                zos.close();
+            }
+            log.info("报告验证章批量下载完成:打包 {} 单,跳过 {} 条", ready.size(), failures.size());
+        } finally {
+            for (File file : unitFiles.values()) {
+                deleteLocalFile(file.getPath());
+            }
+        }
+    }
+
+    /**
+     * HTTP 直拉 OSS 临时签名地址到本地临时文件(不跨服务传文件流)
+     *
+     * @param url 临时签名地址
+     * @param target 本地临时文件
+     * @return 写入字节数
+     * @throws Exception 网络或 IO 异常
+     */
+    private long downloadToLocalFile(String url, File target) throws Exception {
+        HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
+        connection.setConnectTimeout(10000);
+        connection.setReadTimeout(120000);
+        connection.setRequestMethod("GET");
+        try {
+            int code = connection.getResponseCode();
+            if (code != HttpURLConnection.HTTP_OK) {
+                throw new IOException("下载已盖章件返回 HTTP " + code);
+            }
+            InputStream in = connection.getInputStream();
+            try {
+                OutputStream out = new FileOutputStream(target);
+                try {
+                    byte[] buffer = new byte[8192];
+                    long total = 0L;
+                    int len;
+                    while ((len = in.read(buffer)) != -1) {
+                        out.write(buffer, 0, len);
+                        total += len;
+                    }
+                    return total;
+                } finally {
+                    out.close();
+                }
+            } finally {
+                in.close();
+            }
+        } finally {
+            connection.disconnect();
+        }
+    }
+
+    /**
+     * 把一个本地临时文件写进 zip 的一个条目
+     *
+     * @param zos zip 流
+     * @param file 本地文件
+     * @param entryName 条目名
+     * @throws Exception IO 异常
+     */
+    private void writeFileToZip(ZipOutputStream zos, File file, String entryName) throws Exception {
+        zos.putNextEntry(new ZipEntry(entryName));
+        InputStream in = new FileInputStream(file);
+        try {
+            byte[] buffer = new byte[8192];
+            int len;
+            while ((len = in.read(buffer)) != -1) {
+                zos.write(buffer, 0, len);
+            }
+        } finally {
+            in.close();
+            zos.closeEntry();
+        }
+    }
+
+    /**
+     * 把文本内容写进 zip 的一个条目(条目内容统一 UTF-8)
+     *
+     * @param zos zip 流
+     * @param entryName 条目名
+     * @param content 文本内容
+     * @throws Exception IO 异常
+     */
+    private void writeTextToZip(ZipOutputStream zos, String entryName, String content) throws Exception {
+        zos.putNextEntry(new ZipEntry(entryName));
+        try {
+            zos.write(content.getBytes(StandardCharsets.UTF_8));
+        } finally {
+            zos.closeEntry();
+        }
+    }
+
+    /**
+     * 批量下载时给人看的单元名:报告号 + 项目名,不出现 id
+     *
+     * @param main 单据
+     * @return 展示名
+     */
+    private String batchDownloadLabel(CwReportVerificationSeal main) {
+        return StringUtils.defaultIfBlank(main.getReportNo(), "(无报告号)")
+                + " " + StringUtils.defaultIfBlank(main.getProjectName(), "(无项目名)");
+    }
+
+    /**
+     * 拼批量下载 zip 内的单元文件名"报告号_项目名.扩展名":去掉文件系统非法字符,
+     * 扩展名取自 signed_zip_url(单文件直出时它就是原件扩展名,多文件时是 .zip),重名补序号
+     *
+     * @param main 单据
+     * @param usedNames 已用文件名计数
+     * @return 条目名
+     */
+    private String buildBatchEntryName(CwReportVerificationSeal main, Map<String, Integer> usedNames) {
+        String extension = "";
+        String url = StringUtils.defaultIfBlank(main.getSignedZipUrl(), "");
+        String segment = url.substring(url.lastIndexOf('/') + 1);
+        int dot = segment.lastIndexOf('.');
+        if (dot >= 0) {
+            String raw = segment.substring(dot + 1);
+            if (raw.matches("[A-Za-z0-9]{1,10}")) {
+                extension = "." + raw.toLowerCase();
+            }
+        }
+        String base = StringUtils.defaultIfBlank(main.getReportNo(), "") + "_" + StringUtils.defaultIfBlank(main.getProjectName(), "");
+        base = base.replaceAll("[\\\\/:*?\"<>|\\r\\n]", "_").replaceAll("^_+|_+$", "");
+        if (StringUtils.isBlank(base)) {
+            base = "报告验证章";
+        }
+        if (base.length() > 80) {
+            base = base.substring(0, 80);
+        }
+        Integer count = usedNames.get(base);
+        usedNames.put(base, count == null ? 1 : count + 1);
+        return count == null ? base + extension : base + "(" + (count + 1) + ")" + extension;
+    }
+
+    /**
+     * 批量下载跳过清单,写进 zip 内的《下载说明.txt》
+     *
+     * @param failures 跳过原因
+     * @return 说明文本
+     */
+    private String buildBatchDownloadNote(List<String> failures) {
+        StringBuilder note = new StringBuilder("以下申请未打包进本压缩包,请核对后单独下载:\r\n");
+        for (String failure : failures) {
+            note.append("- ").append(failure).append("\r\n");
+        }
+        return note.toString();
+    }
+
+    /**
+     * 批量下载的 JSON 错误体(前端以 blob 接收,按 400 解析出 message 提示)
+     *
+     * @param response 响应
+     * @param message 提示文案
+     * @throws IOException 写响应异常
+     */
+    private void writeBatchDownloadError(HttpServletResponse response, String message) throws IOException {
+        if (response.isCommitted()) {
+            log.warn("报告验证章批量下载:响应已提交,无法回写错误提示,message={}", message);
+            return;
+        }
+        response.reset();
+        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+        response.setContentType("application/json;charset=utf-8");
+        Map<String, Object> body = new HashMap<>();
+        body.put("code", 400);
+        body.put("message", message);
+        response.getWriter().write(JSON.toJSONString(body));
+        response.getWriter().flush();
+    }
+
+    /**
      * 契约锁签署完成回调落库(由回调 Controller 调用,线程无登录态)
      *
      * 处理形态与个人执业章逐字对齐:下载整包 → 解压 → 每一份已盖章件都传 OSS、落 work_attachment、

+ 115 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/service/QiyuesuoEmployeeService.java

@@ -0,0 +1,115 @@
+package com.jeeplus.finance.reportVerificationSeal.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.jeeplus.flowable.dto.QysEmployeeSyncDTO;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * 契约锁员工同步:标记部门内的人员在契约锁企业里确保有员工身份,禁止登录/删除用户时移出企业
+ *
+ * 只做外部接口调用、不访问数据库,故不加事务;失败只记日志,由 system 侧下一次保存/启停自动重试。
+ * 日志只打 userId,不打姓名、手机号。
+ *
+ * @author: 徐滕
+ * @version: 2026-11-27 10:00
+ */
+@Service
+public class QiyuesuoEmployeeService {
+
+    private static Logger log = LoggerFactory.getLogger(QiyuesuoEmployeeService.class);
+
+    /**
+     * 确保人员在契约锁企业内(已是本企业员工则直接返回,不重复创建)
+     *
+     * @param dto 同步参数
+     */
+    public void ensureEmployee(QysEmployeeSyncDTO dto) {
+        String configMissing = QiyuesuoVerificationPayloadBuilder.employeeConfigMissingMessage();
+        if (StringUtils.isNotBlank(configMissing)) {
+            log.error("契约锁人员同步未执行:{}", configMissing);
+            return;
+        }
+        if (dto == null || StringUtils.isBlank(dto.getName()) || StringUtils.isBlank(dto.getMobile())) {
+            log.warn("契约锁人员同步未执行:姓名或手机号为空,userId={}", dto == null ? null : dto.getUserId());
+            return;
+        }
+        JSONObject userResponse = QiyuesuoVerificationPayloadBuilder.getUserByMobile(dto.getMobile());
+        if (!QiyuesuoVerificationPayloadBuilder.isSuccess(userResponse)) {
+            // 查询失败时不能断定"不存在",继续建员工可能重复建号,故直接放弃,等下次保存/启停重试
+            log.error("契约锁人员查询失败,userId={},code={},message={}", dto.getUserId(),
+                    userResponse == null ? null : userResponse.getString("code"),
+                    QiyuesuoVerificationPayloadBuilder.message(userResponse, "契约锁无响应"));
+            return;
+        } else if (isEmployeeOfTenant(userResponse)) {
+            return;
+        }
+        JSONObject createResponse = QiyuesuoVerificationPayloadBuilder.createEmployee(dto.getName(), dto.getMobile());
+        if (!QiyuesuoVerificationPayloadBuilder.isSuccess(createResponse)) {
+            log.error("契约锁员工创建失败,userId={},code={},message={}", dto.getUserId(),
+                    createResponse == null ? null : createResponse.getString("code"),
+                    QiyuesuoVerificationPayloadBuilder.message(createResponse, "契约锁无响应"));
+            return;
+        }
+        log.info("契约锁员工创建成功,userId={}", dto.getUserId());
+    }
+
+    /**
+     * 将人员移出契约锁企业(个人账号保留)
+     *
+     * 人员本来就不在该企业时平台会回业务错误,这里按 warn 记录,不影响业务。
+     *
+     * @param dto 同步参数
+     */
+    public void removeEmployee(QysEmployeeSyncDTO dto) {
+        String configMissing = QiyuesuoVerificationPayloadBuilder.employeeConfigMissingMessage();
+        if (StringUtils.isNotBlank(configMissing)) {
+            log.error("契约锁人员同步未执行:{}", configMissing);
+            return;
+        }
+        if (dto == null || StringUtils.isBlank(dto.getMobile())) {
+            log.warn("契约锁人员移出未执行:手机号为空,userId={}", dto == null ? null : dto.getUserId());
+            return;
+        }
+        JSONObject response = QiyuesuoVerificationPayloadBuilder.removeEmployee(dto.getMobile());
+        if (!QiyuesuoVerificationPayloadBuilder.isSuccess(response)) {
+            log.warn("契约锁员工移出未成功,userId={},code={},message={}", dto.getUserId(),
+                    response == null ? null : response.getString("code"),
+                    QiyuesuoVerificationPayloadBuilder.message(response, "契约锁无响应"));
+            return;
+        }
+        log.info("契约锁员工移出成功,userId={}", dto.getUserId());
+    }
+
+    /**
+     * 查询结果里是否包含本企业员工关系
+     *
+     * 用户不存在时结果是没有 id 的骨架对象;存在个人账号但不在本企业时 companies 里没有本企业,
+     * 两种情况都要继续走建员工。
+     *
+     * @param userResponse /user 查询响应
+     * @return 是否已是本企业员工
+     */
+    private boolean isEmployeeOfTenant(JSONObject userResponse) {
+        JSONObject result = userResponse.getJSONObject("result");
+        if (result == null || StringUtils.isBlank(result.getString("id"))) {
+            return false;
+        }
+        JSONArray companies = result.getJSONArray("companies");
+        if (companies == null || companies.isEmpty()) {
+            return false;
+        }
+        String tenantName = QiyuesuoVerificationPayloadBuilder.tenantName();
+        for (int i = 0; i < companies.size(); i++) {
+            JSONObject company = companies.getJSONObject(i);
+            if (company != null && StringUtils.equals(tenantName, company.getString("name"))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+}

+ 64 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/service/QiyuesuoVerificationPayloadBuilder.java

@@ -251,6 +251,70 @@ public class QiyuesuoVerificationPayloadBuilder {
     }
 
     /**
+     * 人员同步所需的配置是否齐备(复用主体名与执业章应用凭据,不依赖验证章分类id)
+     *
+     * @return 空串表示可用
+     */
+    public static String employeeConfigMissingMessage() {
+        if (StringUtils.isBlank(SIGN_HTTP_TOP)) {
+            return "未配置契约锁服务地址(signature_http_top),无法同步人员";
+        }
+        if (StringUtils.isBlank(TENANT_NAME)) {
+            return "未配置契约锁企业名称(practice_signature_tenant_name),无法同步人员";
+        }
+        if (StringUtils.isBlank(APPTOKEN) || StringUtils.isBlank(SIGNATURE)) {
+            return "未配置契约锁应用凭据(practice_signature_apptoken / practice_signature_signature),无法同步人员";
+        }
+        return "";
+    }
+
+    /**
+     * 按手机号查询契约锁个人用户
+     *
+     * 查不到时平台会返回没有 result.id 的骨架对象,调用方必须以 result.id 是否存在判断,
+     * 不能以响应成功或 mobile 字段判断(2026-11-27 在 138 实测确认)。
+     *
+     * @param mobile 手机号
+     * @return 契约锁原始响应
+     */
+    public static JSONObject getUserByMobile(String mobile) {
+        Map<String, String> params = new HashMap<>();
+        params.put("mobile", encode(mobile));
+        return parse(SignaturePostUtil.sendGet(SIGN_HTTP_TOP + "/user?" + queryString(params),
+                authHeader(), "UTF-8"));
+    }
+
+    /**
+     * 创建内部企业员工(个人账号不存在时平台按 contact 一并创建,个人账号已存在则只建员工关系)
+     *
+     * @param name 姓名
+     * @param mobile 手机号
+     * @return 契约锁原始响应,result 为第三方员工id
+     */
+    public static JSONObject createEmployee(String name, String mobile) {
+        Map<String, Object> body = new HashMap<>();
+        body.put("name", name);
+        body.put("contact", mobile);
+        body.put("companyName", TENANT_NAME);
+        return parse(SignaturePostUtil.sendPostApplicationJson(SIGN_HTTP_TOP + "/employee/create",
+                JSON.toJSONString(body), APPTOKEN, SIGNATURE));
+    }
+
+    /**
+     * 从企业移出员工(个人账号保留,已实名认证的个人账号平台不提供删除接口)
+     *
+     * @param mobile 手机号
+     * @return 契约锁原始响应
+     */
+    public static JSONObject removeEmployee(String mobile) {
+        Map<String, String> params = new HashMap<>();
+        params.put("contact", encode(mobile));
+        params.put("companyName", encode(TENANT_NAME));
+        return parse(SignaturePostUtil.sendGet(SIGN_HTTP_TOP + "/company/removeemployee?" + queryString(params),
+                authHeader(), "UTF-8"));
+    }
+
+    /**
      * 隔离点 #2:强制结束合同,让合同进终态触发 CONTRACT_COMPLETE 回调
      *
      * 【已停用,仅留手动兜底入口】2026-11-24 换形态后节点 1 签完合同自然进终态,主链路不再需要它;

+ 21 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reportVerificationSeal/service/dto/CwReportVerificationSealBatchDownloadDTO.java

@@ -0,0 +1,21 @@
+package com.jeeplus.finance.reportVerificationSeal.service.dto;
+
+import com.jeeplus.core.service.dto.BaseDTO;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 报告验证章批量下载入参
+ * @author: 徐滕
+ * @version: 2026-11-27 10:00
+ */
+@Data
+public class CwReportVerificationSealBatchDownloadDTO extends BaseDTO {
+
+    private static final long serialVersionUID = 1L;
+
+    /** 选中的申请id集合(列表页多选,只打包完成且有已盖章件的单) */
+    private List<String> ids;
+
+}

+ 4 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/feign/WorkAttachmentApiImpl.java

@@ -144,5 +144,9 @@ public class WorkAttachmentApiImpl implements IWorkAttachmentApi {
         return null;
     }
 
+    @Override
+    public String getTemporaryUrl(String url) {
+        return ossService.getFileTemporaryLookUrl(url);
+    }
 
 }

+ 1 - 1
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/feign/UserApiImpl.java

@@ -111,7 +111,7 @@ public class UserApiImpl implements IUserApi {
 
     @Override
     public void updateUser(UserDTO userDTO) {
-        userService.updateById ( UserWrapper.INSTANCE.toEntity ( userDTO ) );
+        userService.updateUser ( userDTO );
     }
 
     @Override

+ 2 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/xml/OfficeMapper.xml

@@ -19,6 +19,7 @@
         a.fax as "fax",
         a.email as "email",
         a.useable as "useable",
+        a.qys_sync_flag as "qysSyncFlag",
         a.primary_person as "primaryPerson",
         a.deputy_person as "deputyPerson",
 		a.create_by_id as "createBy.id",
@@ -67,6 +68,7 @@
                a.update_time,
                a.del_flag,
                a.useable      AS useable,
+               a.qys_sync_flag AS qysSyncFlag,
                a.tenant_id    AS "tenantDTO.id",
                a.administrator,
                su.name as adminName,

+ 147 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/service/UserService.java

@@ -22,7 +22,9 @@ import com.jeeplus.common.constant.CommonConstants;
 import com.jeeplus.common.redis.RedisUtils;
 import com.jeeplus.common.utils.RequestUtils;
 import com.jeeplus.core.query.QueryWrapperGenerator;
+import com.jeeplus.flowable.dto.QysEmployeeSyncDTO;
 import com.jeeplus.flowable.feign.IHumanApi;
+import com.jeeplus.flowable.feign.IQysEmployeeApi;
 import com.jeeplus.sys.domain.*;
 import com.jeeplus.sys.feign.IDictApi;
 import com.jeeplus.sys.feign.IUserApi;
@@ -34,12 +36,20 @@ import com.jeeplus.sys.service.mapstruct.CertWrapper;
 import com.jeeplus.sys.service.mapstruct.UserWrapper;
 import com.jeeplus.sys.utils.UserUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.support.TransactionSynchronization;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -55,6 +65,18 @@ import java.util.stream.Stream;
 @Transactional
 public class UserService extends ServiceImpl<UserMapper, User> {
 
+    private static Logger log = LoggerFactory.getLogger(UserService.class);
+
+    /**
+     * 契约锁员工同步线程池:外部调用不放请求线程;队列满时丢弃,下次保存/启停会重试
+     */
+    private static final ExecutorService QYS_EMPLOYEE_SYNC_EXECUTOR = new ThreadPoolExecutor(1, 2, 60L,
+            TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(200), runnable -> {
+                Thread thread = new Thread(runnable, "qys-employee-sync");
+                thread.setDaemon(true);
+                return thread;
+            }, (runnable, executor) -> log.warn("契约锁人员同步队列已满,本次丢弃,待下次保存/启停重试"));
+
     // 通过 -?[0-9]+(\\\\.[0-9]+)? 进行匹配是否为数字
     private static Pattern pattern = Pattern.compile("-?[0-9]+(\\\\.[0-9]+)?");
 
@@ -82,6 +104,9 @@ public class UserService extends ServiceImpl<UserMapper, User> {
     @Autowired
     private RedisUtils redisUtils;
 
+    @Autowired
+    private IQysEmployeeApi qysEmployeeApi;
+
     public UserDTO getByOpenId(String openId) {
         return baseMapper.getByOpenId(openId);
     }
@@ -519,6 +544,8 @@ public class UserService extends ServiceImpl<UserMapper, User> {
      */
     public void saveOrUpdate(UserDTO userDTO) {
         User user = userWrapper.toEntity(userDTO);
+        // 契约锁同步用:变更前的机构与登录状态
+        User oldUser = StringUtils.isNotBlank(userDTO.getId()) ? super.getById(userDTO.getId()) : null;
         if (StringUtils.isNotBlank(userDTO.getOpenId())) {
             user.setOpenId(userDTO.getOpenId());
         }
@@ -587,15 +614,106 @@ public class UserService extends ServiceImpl<UserMapper, User> {
         } else {
             userMapper.deleteByUserId(user.getId());
         }
+        // 事务提交后按机构标记同步契约锁(失败不影响人员保存,下次保存/启停自动重试)
+        syncQysEmployee(user.getId(),
+                StringUtils.defaultIfBlank(user.getName(), oldUser == null ? null : oldUser.getName()),
+                StringUtils.defaultIfBlank(user.getMobile(), oldUser == null ? null : oldUser.getMobile()),
+                StringUtils.defaultIfBlank(user.getTenantId(), oldUser == null ? null : oldUser.getTenantId()),
+                oldUser == null ? null : oldUser.getOfficeId(),
+                oldUser == null ? null : oldUser.getLoginFlag(),
+                StringUtils.defaultIfBlank(user.getOfficeId(), oldUser == null ? null : oldUser.getOfficeId()),
+                user.getLoginFlag());
+    }
 
+    /**
+     * 判断机构及其所有上级机构是否勾选了“同步契约锁人员”
+     *
+     * @param officeId 机构id
+     * @return 是否命中标记
+     */
+    private boolean isQysSyncOffice(String officeId) {
+        String currentId = officeId;
+        Set<String> visited = new HashSet<>();
+        while (StringUtils.isNotBlank(currentId) && visited.add(currentId) && visited.size() <= 30) {
+            Office office = officeMapper.selectById(currentId);
+            if (office == null) {
+                return false;
+            }
+            if ("1".equals(office.getQysSyncFlag())) {
+                return true;
+            }
+            currentId = office.getParentId();
+        }
+        return false;
     }
 
+    /**
+     * 按机构标记与登录状态决定契约锁侧动作:
+     * 标记内且允许登录=确保员工存在;移出标记或禁止登录=移出企业员工
+     *
+     * @param userId 用户id
+     * @param name 姓名
+     * @param mobile 手机号
+     * @param tenantId 租户id
+     * @param oldOfficeId 变更前机构id(新增用户传空)
+     * @param oldLoginFlag 变更前登录标记(新增用户传空)
+     * @param newOfficeId 变更后机构id
+     * @param newLoginFlag 变更后登录标记(空时沿用变更前,仍为空按允许登录)
+     */
+    private void syncQysEmployee(String userId, String name, String mobile, String tenantId,
+                                 String oldOfficeId, String oldLoginFlag,
+                                 String newOfficeId, String newLoginFlag) {
+        if (StringUtils.isBlank(mobile)) {
+            return;
+        }
+        String effectiveLoginFlag = StringUtils.defaultIfBlank(newLoginFlag,
+                StringUtils.defaultIfBlank(oldLoginFlag, "1"));
+        boolean newMarked = isQysSyncOffice(newOfficeId);
+        boolean oldMarked = isQysSyncOffice(oldOfficeId);
+        boolean ensure = newMarked && "1".equals(effectiveLoginFlag);
+        boolean remove = !ensure && oldMarked && ("1".equals(oldLoginFlag) || !newMarked);
+        if (!ensure && !remove) {
+            return;
+        }
+        QysEmployeeSyncDTO syncDTO = new QysEmployeeSyncDTO();
+        syncDTO.setUserId(userId);
+        syncDTO.setName(name);
+        syncDTO.setMobile(mobile);
+        syncDTO.setTenantId(tenantId);
+        Runnable task = () -> {
+            try {
+                if (ensure) {
+                    qysEmployeeApi.ensureEmployee(syncDTO);
+                } else {
+                    qysEmployeeApi.removeEmployee(syncDTO);
+                }
+            } catch (Exception e) {
+                log.error("契约锁人员同步调用失败,userId={},action={}", userId,
+                        ensure ? "ensure" : "remove", e);
+            }
+        };
+        if (TransactionSynchronizationManager.isSynchronizationActive()) {
+            TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
+                @Override
+                public void afterCommit() {
+                    QYS_EMPLOYEE_SYNC_EXECUTOR.execute(task);
+                }
+            });
+        } else {
+            QYS_EMPLOYEE_SYNC_EXECUTOR.execute(task);
+        }
+    }
 
     public void deleteUser(UserDTO userDTO) {
+        User oldUser = super.getById(userDTO.getId());
         baseMapper.deleteUserRole(userDTO.getId());
         baseMapper.deleteUserPost(userDTO.getId());
         super.removeById(userDTO.getId());
         UserUtils.deleteCache(userDTO);
+        if (oldUser != null) {
+            syncQysEmployee(userDTO.getId(), oldUser.getName(), oldUser.getMobile(), oldUser.getTenantId(),
+                    oldUser.getOfficeId(), oldUser.getLoginFlag(), null, "0");
+        }
     }
 
     /**
@@ -960,7 +1078,31 @@ public class UserService extends ServiceImpl<UserMapper, User> {
      * @return
      */
     public void updateLoginFlag(String id, String loginFlag) {
+        User oldUser = super.getById(id);
         userMapper.updateLoginFlag(id, loginFlag);
+        if (oldUser != null) {
+            syncQysEmployee(id, oldUser.getName(), oldUser.getMobile(), oldUser.getTenantId(),
+                    oldUser.getOfficeId(), oldUser.getLoginFlag(), oldUser.getOfficeId(), loginFlag);
+        }
+    }
+
+    /**
+     * 更新用户信息(仅更新非空字段),并同步契约锁员工
+     *
+     * @param userDTO 用户信息
+     */
+    public void updateUser(UserDTO userDTO) {
+        User user = userWrapper.toEntity(userDTO);
+        User oldUser = StringUtils.isNotBlank(userDTO.getId()) ? super.getById(userDTO.getId()) : null;
+        super.updateById(user);
+        syncQysEmployee(user.getId(),
+                StringUtils.defaultIfBlank(user.getName(), oldUser == null ? null : oldUser.getName()),
+                StringUtils.defaultIfBlank(user.getMobile(), oldUser == null ? null : oldUser.getMobile()),
+                StringUtils.defaultIfBlank(user.getTenantId(), oldUser == null ? null : oldUser.getTenantId()),
+                oldUser == null ? null : oldUser.getOfficeId(),
+                oldUser == null ? null : oldUser.getLoginFlag(),
+                StringUtils.defaultIfBlank(user.getOfficeId(), oldUser == null ? null : oldUser.getOfficeId()),
+                user.getLoginFlag());
     }
 
     public Integer selectCountByMobile(String mobile) {
@@ -1001,7 +1143,12 @@ public class UserService extends ServiceImpl<UserMapper, User> {
      * @param id
      */
     public void updateDelFlagById(String id) {
+        User oldUser = super.getById(id);
         userMapper.updateDelFlagById(id);
+        if (oldUser != null) {
+            syncQysEmployee(id, oldUser.getName(), oldUser.getMobile(), oldUser.getTenantId(),
+                    oldUser.getOfficeId(), oldUser.getLoginFlag(), null, "0");
+        }
     }
 
     /**