feat: 实现20260730优化方案全部功能
- AI文件审查:.docx上传提取文本,支持多种文档类型 - 用工办理工作流:WorkProcess页面+后端API,支持入职/续签/终止等流程 - 企业自建文本库:Templates页面Tab切换,企业模板CRUD+渲染+下载Word - 考勤发布:Attendance发布/取消发布按钮,员工端MyAttendance页面 - 工资条发布:Money发布/定时发送按钮+弹窗,portal端publishStatus过滤 - 合同到期弹窗:Dashboard合同到期预警可点击打开弹窗,支持续签/终止操作 - Prisma schema新增WorkProcess/EnterpriseTemplate/AttendancePublish模型 - 前后端编译验证全部通过
This commit is contained in:
@@ -5,6 +5,9 @@ import { seedKnowledgeBase, addKnowledge, searchKnowledge, ensureRAGTable, searc
|
||||
import prisma from '../lib/prisma'
|
||||
import { z } from 'zod'
|
||||
import { decrypt } from '../lib/crypto'
|
||||
import multer from 'multer'
|
||||
import path from 'path'
|
||||
import mammoth from 'mammoth'
|
||||
|
||||
const router = Router()
|
||||
|
||||
@@ -947,6 +950,42 @@ ${expiringContracts.length > 0 ? expiringContracts.join('\n') : '无'}`
|
||||
}
|
||||
})
|
||||
|
||||
// ========== AI 文件审查上传 ==========
|
||||
|
||||
const reviewUpload = multer({
|
||||
storage: multer.memoryStorage(),
|
||||
limits: { fileSize: 100 * 1024 * 1024 },
|
||||
fileFilter: (_req, file, cb) => {
|
||||
const ext = path.extname(file.originalname).toLowerCase()
|
||||
if (ext !== '.docx' && ext !== '.doc') {
|
||||
return cb(null, false)
|
||||
}
|
||||
cb(null, true)
|
||||
},
|
||||
})
|
||||
|
||||
router.post('/review/upload', authMiddleware, reviewUpload.single('file'), async (req: AuthRequest, res, next) => {
|
||||
try {
|
||||
if (!req.file) {
|
||||
return res.status(400).json({ success: false, error: { code: 'NO_FILE', message: '请上传 .docx 文件' } })
|
||||
}
|
||||
const ext = path.extname(req.file.originalname).toLowerCase()
|
||||
let text = ''
|
||||
if (ext === '.docx') {
|
||||
const result = await mammoth.extractRawText({ buffer: req.file.buffer })
|
||||
text = result.value
|
||||
} else {
|
||||
return res.status(400).json({ success: false, error: { code: 'UNSUPPORTED', message: '暂不支持 .doc 格式,请将文件另存为 .docx 后上传' } })
|
||||
}
|
||||
if (text.length > 50000) {
|
||||
text = text.slice(0, 50000) + '\n\n[文本过长,已截断]'
|
||||
}
|
||||
res.json({ success: true, data: { text, fileName: req.file.originalname } })
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
// ========== 人工咨询服务 ==========
|
||||
|
||||
router.post('/consultation', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
|
||||
Reference in New Issue
Block a user