✨ 异常处置跟进支持上传附件

跟进记录新增 attachments_json 列,存 [{name, url}] 形式的 JSON 数组。
跟进说明与附件至少填其一即可:只传附件时,follow_content 列为 NOT NULL,
故写入固定文案「已上传跟进附件」,列表按该文案展示。

建表脚本补 COLLATE:原先只写 CHARSET,落到 MySQL 8 服务器默认排序规则,
与库中实际的 utf8mb4_0900_ai_ci 不一致。
This commit is contained in:
2026-10-05 01:09:33 +08:00
parent 8d35abd23e
commit 7296a5af21
5 changed files with 48 additions and 7 deletions
@@ -46,4 +46,7 @@ public class ExceptionDisposalFollowRequest implements Serializable {
@Schema(description = "跟进说明")
private String followContent;
@Schema(description = "附件JSON,[{\"name\":\"...\",\"url\":\"...\"}]")
private String attachmentsJson;
}
@@ -51,6 +51,9 @@ public class ExceptionDisposalFollowRecord extends TenantEntity {
@Schema(description = "跟进说明")
private String followContent;
@Schema(description = "附件JSON")
private String attachmentsJson;
@Schema(description = "跟进人")
private Long followUser;
@@ -267,23 +267,30 @@ public class ExceptionDisposalServiceImpl
if (request == null || request.getId() == null) {
throw new ServiceException("请选择需要跟进的异常");
}
if (Func.isBlank(request.getFollowContent())) {
throw new ServiceException("请填写跟进说明");
boolean hasAttachments = Func.isNotBlank(request.getAttachmentsJson());
if (Func.isBlank(request.getFollowContent()) && !hasAttachments) {
throw new ServiceException("请填写跟进说明或上传附件");
}
if (request.getFollowContent().length() > 500) {
if (Func.isNotBlank(request.getFollowContent()) && request.getFollowContent().length() > 500) {
throw new ServiceException("跟进说明不能超过500字");
}
ExceptionDisposal disposal = getExisting(request.getId());
if (STATUS_COMPLETED.equals(disposal.getDisposalStatus())) {
throw new ServiceException("已完成的异常不允许继续跟进");
}
// 上传了附件但没写说明时,跟进说明留空,列表按附件回退展示
String followContent = Func.isBlank(request.getFollowContent())
? null
: request.getFollowContent();
disposal.setDisposalStatus(STATUS_PROCESSING);
disposal.setLatestFollowContent(request.getFollowContent());
disposal.setLatestFollowContent(Func.isBlank(followContent) ? "已上传跟进附件" : followContent);
updateById(disposal);
ExceptionDisposalFollowRecord record = new ExceptionDisposalFollowRecord();
record.setDisposalId(disposal.getId());
record.setFollowContent(request.getFollowContent());
// follow_content 列为 NOT NULL
record.setFollowContent(Func.isBlank(followContent) ? "已上传跟进附件" : followContent);
record.setAttachmentsJson(hasAttachments ? request.getAttachmentsJson() : null);
record.setFollowUser(AuthUtil.getUserId());
record.setFollowUserName(UserCache.getUserRealName(AuthUtil.getUserId()));
record.setFollowTime(LocalDateTime.now());
@@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS `blade_exception_disposal` (
KEY `idx_exception_disposal_status` (`disposal_status`) USING BTREE,
KEY `idx_exception_disposal_report_time` (`report_time`) USING BTREE,
KEY `idx_exception_disposal_create_time` (`create_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='异常处置';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='异常处置';
CREATE TABLE IF NOT EXISTS `blade_exception_disposal_follow_record` (
`id` bigint(20) NOT NULL COMMENT '主键',
@@ -48,13 +48,14 @@ CREATE TABLE IF NOT EXISTS `blade_exception_disposal_follow_record` (
`is_deleted` int(11) DEFAULT '0' COMMENT '是否已删除',
`disposal_id` bigint(20) NOT NULL COMMENT '异常处置ID',
`follow_content` varchar(500) NOT NULL COMMENT '跟进说明',
`attachments_json` text DEFAULT NULL COMMENT '附件JSON',
`follow_user` bigint(20) DEFAULT NULL COMMENT '跟进人',
`follow_user_name` varchar(100) DEFAULT NULL COMMENT '跟进人姓名',
`follow_time` datetime DEFAULT NULL COMMENT '跟进时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_exception_follow_disposal` (`disposal_id`) USING BTREE,
KEY `idx_exception_follow_time` (`follow_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='异常处置跟进记录';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='异常处置跟进记录';
INSERT INTO `blade_menu` (`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `component`, `remark`, `is_deleted`)
VALUES
@@ -0,0 +1,27 @@
-- 异常处置跟进记录补充附件
-- 日期:2026-10-10
--
-- 附件以 JSON 数组存放([{"name":"...","url":"..."}]),与本仓库其它附件字段一致。
DELIMITER $$
DROP PROCEDURE IF EXISTS `upgrade_blade_exception_disposal_follow_attachments_20261010`$$
CREATE PROCEDURE `upgrade_blade_exception_disposal_follow_attachments_20261010`()
BEGIN
DECLARE db_name varchar(128);
SET db_name = DATABASE();
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
WHERE table_schema = db_name
AND table_name = 'blade_exception_disposal_follow_record'
AND column_name = 'attachments_json') THEN
ALTER TABLE `blade_exception_disposal_follow_record`
ADD COLUMN `attachments_json` text DEFAULT NULL COMMENT '附件JSON'
AFTER `follow_content`;
END IF;
END$$
CALL `upgrade_blade_exception_disposal_follow_attachments_20261010`()$$
DROP PROCEDURE `upgrade_blade_exception_disposal_follow_attachments_20261010`$$
DELIMITER ;