Merge branch '0.8.X' of http://49.232.154.205:10100/DeXun/klp-oa into 0.8.X
This commit is contained in:
97
klp-ui/src/api/wms/seal.js
Normal file
97
klp-ui/src/api/wms/seal.js
Normal file
@@ -0,0 +1,97 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 用印申请
|
||||
export function listSealReq(query) {
|
||||
return request({
|
||||
url: '/wms/seal/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function getSealReq(bizId) {
|
||||
return request({
|
||||
url: `/wms/seal/${bizId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function addSealReq(data) {
|
||||
return request({
|
||||
url: '/wms/seal',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function editSealReq(data) {
|
||||
return request({
|
||||
url: '/wms/seal',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function delSealReq(bizIds) {
|
||||
return request({
|
||||
url: `/wms/seal/${bizIds}`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function approveSealReq(bizId, approvalOpinion) {
|
||||
return request({
|
||||
url: `/wms/seal/${bizId}/approve`,
|
||||
method: 'post',
|
||||
params: { approvalOpinion }
|
||||
})
|
||||
}
|
||||
|
||||
export function rejectSealReq(bizId, approvalOpinion) {
|
||||
return request({
|
||||
url: `/wms/seal/${bizId}/reject`,
|
||||
method: 'post',
|
||||
params: { approvalOpinion }
|
||||
})
|
||||
}
|
||||
|
||||
export function cancelSealReq(bizId) {
|
||||
return request({
|
||||
url: `/wms/seal/${bizId}/cancel`,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
export function stampSealJava(bizId, data) {
|
||||
const payload = {
|
||||
targetFileUrl: String(data.targetFileUrl || ''),
|
||||
stampImageUrl: String(data.stampImageUrl || ''),
|
||||
pageNo: Number(data.pageNo) || 1,
|
||||
xPx: Number(data.xPx) || 0,
|
||||
yPx: Number(data.yPx) || 0,
|
||||
viewportWidth: data.viewportWidth !== undefined && data.viewportWidth !== null ? Number(data.viewportWidth) : undefined,
|
||||
viewportHeight: data.viewportHeight !== undefined && data.viewportHeight !== null ? Number(data.viewportHeight) : undefined
|
||||
}
|
||||
if (data.widthPx !== undefined && data.widthPx !== null) {
|
||||
payload.widthPx = Number(data.widthPx)
|
||||
}
|
||||
if (data.heightPx !== undefined && data.heightPx !== null) {
|
||||
payload.heightPx = Number(data.heightPx)
|
||||
}
|
||||
if (payload.viewportWidth === undefined) delete payload.viewportWidth
|
||||
if (payload.viewportHeight === undefined) delete payload.viewportHeight
|
||||
|
||||
return request({
|
||||
url: `/wms/seal/${bizId}/stamp/java`,
|
||||
method: 'post',
|
||||
data: payload
|
||||
})
|
||||
}
|
||||
|
||||
export function stampSealPython(bizId, data) {
|
||||
return request({
|
||||
url: `/wms/seal/${bizId}/stamp/python`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
339
klp-ui/src/views/wms/seal/seal.vue
Normal file
339
klp-ui/src/views/wms/seal/seal.vue
Normal file
@@ -0,0 +1,339 @@
|
||||
<template>
|
||||
<div class="request-page">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-card class="form-card" shadow="never">
|
||||
<div slot="header" class="card-header">
|
||||
<span>用印申请</span>
|
||||
|
||||
</div>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px" size="small" class="metal-form">
|
||||
<div class="form-summary">
|
||||
<div class="summary-left">
|
||||
<div class="summary-title">发起用印</div>
|
||||
<div class="summary-sub">请完善信息后提交,系统会推送部门负责人审批</div>
|
||||
</div>
|
||||
<div class="summary-right">
|
||||
<div class="summary-item">
|
||||
<div class="k">申请人</div>
|
||||
<div class="v">{{ currentApplicantText }}</div>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<div class="k">用印类型</div>
|
||||
<div class="v">{{ form.sealType || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-form-item label="审批部门" prop="deptId">
|
||||
<el-select v-model="form.deptId" placeholder="请选择审批部门" filterable @change="onDeptChange" style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in deptOptions"
|
||||
:key="item.deptId"
|
||||
:label="item.deptName + (item.leaderNickName ? '(负责人:' + item.leaderNickName + ')' : '(无负责人)')"
|
||||
:value="item.deptId"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="hint-text">系统将根据部门负责人自动创建审批任务</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="用印类型" prop="sealType">
|
||||
<el-select
|
||||
v-model="form.sealType"
|
||||
filterable
|
||||
allow-create
|
||||
default-first-option
|
||||
clearable
|
||||
placeholder="选择或输入用印类型"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="dictItem in (dict.type.hrm_stamp_image || [])"
|
||||
:key="dictItem.value"
|
||||
:label="dictItem.label"
|
||||
:value="dictItem.label"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="hint-text">优先从字典选择;若字典未配置,可直接输入</div>
|
||||
</el-form-item>
|
||||
|
||||
<div class="block-title">用途与材料</div>
|
||||
<el-form-item label="用途说明" prop="purpose">
|
||||
<el-input v-model="form.purpose" type="textarea" :rows="4" placeholder="请说明用印用途、对象、份数等" show-word-limit maxlength="200" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="待盖章PDF" prop="applyFileIds">
|
||||
<file-upload
|
||||
v-model="form.applyFileIds"
|
||||
:limit="1"
|
||||
:file-size="50"
|
||||
:file-type="['pdf']"
|
||||
/>
|
||||
<div class="hint-text">仅支持 PDF,单个文件不超过 50MB</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="盖章页码" prop="pageNo" v-if="form.applyFileIds">
|
||||
<el-input-number
|
||||
v-model="form.pageNo"
|
||||
:min="1"
|
||||
:max="999"
|
||||
controls-position="right"
|
||||
placeholder="请输入需要盖章的页码(从第1页开始)"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div class="hint-text">请输入需要盖章的页码,从第1页开始计数</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="需要回执" prop="receiptRequired">
|
||||
<el-switch v-model="form.receiptRequired" :active-value="1" :inactive-value="0" />
|
||||
<div class="hint-text">开启后,盖章完成通常需要回传回执文件</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="2" placeholder="可选:补充说明" show-word-limit maxlength="200" />
|
||||
</el-form-item>
|
||||
|
||||
<div class="form-actions">
|
||||
<el-button @click="$router.back()">取消</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="submit">提交申请</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="16">
|
||||
<el-card class="list-card" shadow="never">
|
||||
<div slot="header" class="card-header">
|
||||
<span>我的用印申请</span>
|
||||
<div class="actions">
|
||||
<el-button size="mini" icon="el-icon-refresh" @click="getList">刷新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-table v-loading="listLoading" :data="sealList" border>
|
||||
<el-table-column label="状态" align="center" width="100">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="statusType(scope.row.status)">{{ statusText(scope.row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="用印类型" align="center" prop="sealType" />
|
||||
<el-table-column label="用途说明" align="center" prop="purpose" show-overflow-tooltip />
|
||||
<el-table-column label="申请时间" align="center" prop="createTime" width="160">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" @click="goDetail(scope.row)">查看</el-button>
|
||||
<el-button v-if="canPreviewReceipt(scope.row)" size="mini" type="text" @click="previewReceipt(scope.row)">预览</el-button>
|
||||
<el-button v-if="canPreviewReceipt(scope.row)" size="mini" type="text" @click="downloadReceipt(scope.row)">下载</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { addSealReq, listSealReq } from '@/api/wms/seal'
|
||||
import { listDept } from '@/api/wms/dept'
|
||||
import FileUpload from '@/components/FileUpload'
|
||||
|
||||
export default {
|
||||
name: 'WmsSealRequest',
|
||||
dicts: ['hrm_stamp_image'],
|
||||
components: { FileUpload },
|
||||
data() {
|
||||
return {
|
||||
submitting: false,
|
||||
listLoading: false,
|
||||
deptOptions: [],
|
||||
sealList: [],
|
||||
total: 0,
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
createBy: this.$store.getters.name
|
||||
},
|
||||
form: {
|
||||
empId: this.$store.getters.id,
|
||||
deptId: '',
|
||||
sealType: '',
|
||||
purpose: '',
|
||||
applyFileIds: '',
|
||||
pageNo: 1,
|
||||
receiptRequired: 0,
|
||||
remark: ''
|
||||
},
|
||||
rules: {
|
||||
deptId: [{ required: true, message: '请选择审批部门', trigger: 'change' }],
|
||||
sealType: [{ required: true, message: '请选择/输入用印类型', trigger: 'change' }],
|
||||
purpose: [{ required: true, message: '请填写用途说明', trigger: 'blur' }],
|
||||
applyFileIds: [{ required: true, message: '请上传 PDF 附件', trigger: 'change' }],
|
||||
pageNo: [{ required: true, message: '请输入盖章页码', trigger: 'blur' }],
|
||||
receiptRequired: [{ required: true, message: '请选择是否需要回执', trigger: 'change' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
currentApplicantText() {
|
||||
const user = this.$store?.state?.user || {}
|
||||
return user.nickName || user.userName || '当前用户'
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loadDeptList()
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
async loadDeptList() {
|
||||
try {
|
||||
const res = await listDept()
|
||||
this.deptOptions = res.data || []
|
||||
} catch (e) {
|
||||
this.deptOptions = []
|
||||
}
|
||||
},
|
||||
onDeptChange() {},
|
||||
statusText(status) {
|
||||
const map = { running: '审批中', draft: '草稿', approved: '已通过', rejected: '已驳回', canceled: '已撤销', pending: '待审批' }
|
||||
return map[status] || status || '-'
|
||||
},
|
||||
statusType(status) {
|
||||
const map = { running: 'warning', draft: 'info', approved: 'success', rejected: 'danger', canceled: 'info', pending: 'warning' }
|
||||
return map[status] || 'info'
|
||||
},
|
||||
getList() {
|
||||
this.listLoading = true
|
||||
listSealReq(this.queryParams)
|
||||
.then(res => {
|
||||
this.sealList = res.rows || []
|
||||
this.total = res.total || 0
|
||||
})
|
||||
.finally(() => {
|
||||
this.listLoading = false
|
||||
})
|
||||
},
|
||||
goDetail(row) {
|
||||
this.$router.push({ path: '/job/sealDetail', query: { bizId: row.bizId } })
|
||||
},
|
||||
canPreviewReceipt(row) {
|
||||
return row.status === 'approved' && row.receiptFileIds
|
||||
},
|
||||
previewReceipt(row) {
|
||||
if (row.receiptFileIds) {
|
||||
window.open(row.receiptFileIds, '_blank')
|
||||
}
|
||||
},
|
||||
downloadReceipt(row) {
|
||||
if (row.receiptFileIds) {
|
||||
window.open(row.receiptFileIds, '_blank')
|
||||
}
|
||||
},
|
||||
async submit() {
|
||||
try {
|
||||
await this.$refs.formRef.validate()
|
||||
this.submitting = true
|
||||
let remark = this.form.remark || ''
|
||||
if (this.form.pageNo) {
|
||||
remark = remark ? `${remark}\n[盖章页码:第${this.form.pageNo}页]` : `[盖章页码:第${this.form.pageNo}页]`
|
||||
}
|
||||
const payload = {
|
||||
empId: this.form.empId,
|
||||
deptId: this.form.deptId,
|
||||
sealType: this.form.sealType,
|
||||
purpose: this.form.purpose,
|
||||
applyFileIds: this.form.applyFileIds,
|
||||
receiptRequired: this.form.receiptRequired,
|
||||
remark,
|
||||
status: 'pending'
|
||||
}
|
||||
await addSealReq(payload)
|
||||
this.$message.success('提交成功')
|
||||
this.getList()
|
||||
} finally {
|
||||
this.submitting = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.request-page {
|
||||
padding: 16px 20px 32px;
|
||||
background: transparent;
|
||||
}
|
||||
.form-card {
|
||||
max-width: 980px;
|
||||
margin: 0 auto;
|
||||
border: 1px solid #eef0f4;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
box-shadow: none;
|
||||
}
|
||||
.list-card {
|
||||
border: 1px solid #eef0f4;
|
||||
border-radius: 10px;
|
||||
box-shadow: none;
|
||||
background: #ffffff;
|
||||
}
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-weight: 600;
|
||||
color: #2b2f36;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.metal-form { padding-right: 8px; }
|
||||
.block-title {
|
||||
margin: 18px 0 10px;
|
||||
padding-left: 10px;
|
||||
font-weight: 600;
|
||||
color: #2f3440;
|
||||
border-left: 2px solid #cbd1db;
|
||||
}
|
||||
.hint-text {
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
color: #8a8f99;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.form-summary {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 12px;
|
||||
margin-bottom: 12px;
|
||||
border: 1px solid #eef0f4;
|
||||
border-radius: 10px;
|
||||
background: transparent;
|
||||
}
|
||||
.summary-title { font-size: 15px; font-weight: 700; color: #2b2f36; }
|
||||
.summary-sub { margin-top: 4px; font-size: 12px; color: #8a8f99; }
|
||||
.summary-right { display: flex; gap: 16px; }
|
||||
.summary-item .k { font-size: 12px; color: #8a8f99; }
|
||||
.summary-item .v { margin-top: 2px; font-weight: 600; color: #2b2f36; }
|
||||
.form-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
margin-top: 24px;
|
||||
}
|
||||
@media (max-width: 1200px) {
|
||||
.summary-right { display: none; }
|
||||
}
|
||||
</style>
|
||||
549
klp-ui/src/views/wms/seal/sealDetail.vue
Normal file
549
klp-ui/src/views/wms/seal/sealDetail.vue
Normal file
@@ -0,0 +1,549 @@
|
||||
<template>
|
||||
<div class="request-page">
|
||||
<el-card class="form-card" shadow="never">
|
||||
<div slot="header" class="card-header">
|
||||
<span>用印详情</span>
|
||||
<div class="actions">
|
||||
<el-button size="mini" icon="el-icon-arrow-left" @click="$router.back()">返回</el-button>
|
||||
<el-button size="mini" icon="el-icon-refresh" @click="loadDetail">刷新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-summary" v-loading="loading">
|
||||
<div class="summary-left">
|
||||
<div class="summary-title">{{ seal.sealType || '用印申请' }}</div>
|
||||
<div class="summary-sub">
|
||||
申请编号:{{ seal.bizId || '-' }} · 状态:
|
||||
<el-tag size="mini" :type="statusType(seal.status)">{{ statusText(seal.status) }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary-right">
|
||||
<div class="summary-item">
|
||||
<div class="k">申请人</div>
|
||||
<div class="v">{{ applicantText }}</div>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<div class="k">需要回执</div>
|
||||
<div class="v">{{ seal.receiptRequired === 1 ? '是' : '否' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="block-title">用印信息</div>
|
||||
<el-descriptions :column="2" border size="small" v-loading="loading">
|
||||
<el-descriptions-item label="用印类型">{{ seal.sealType || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="申请人">{{ applicantText }}</el-descriptions-item>
|
||||
<el-descriptions-item label="用途说明" :span="2">{{ seal.purpose || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="盖章页码">
|
||||
<span v-if="stampForm.pageNo" class="page-no-text">第 {{ stampForm.pageNo }} 页</span>
|
||||
<span v-else class="text-muted">未指定</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="需要回执">{{ seal.receiptRequired === 1 ? '是' : '否' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="2">{{ seal.remark || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div class="block-title">申请材料附件</div>
|
||||
<el-card class="inner-card" shadow="never" v-loading="attachmentLoading">
|
||||
<div v-if="seal.receiptFileIds" class="receipt-panel">
|
||||
<div class="receipt-title">回执文件</div>
|
||||
<div class="receipt-actions">
|
||||
<el-button size="mini" type="primary" plain @click="previewReceipt">预览回执</el-button>
|
||||
<el-button size="mini" type="success" plain @click="downloadReceipt">下载回执</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="attachmentList.length > 0" class="attachment-list">
|
||||
<div v-for="file in attachmentList" :key="file.ossId" class="attachment-item">
|
||||
<div class="file-info">
|
||||
<i class="el-icon-document file-icon"></i>
|
||||
<div class="file-details">
|
||||
<div class="file-name">{{ file.originalName || file.fileName || `文件${file.ossId}` }}</div>
|
||||
<div class="file-meta">
|
||||
<span v-if="file.fileSize">{{ formatFileSize(file.fileSize) }}</span>
|
||||
<span v-if="file.createTime" class="file-time">{{ formatDate(file.createTime) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file-actions">
|
||||
<el-button size="mini" type="text" @click="previewFile(file)">预览</el-button>
|
||||
<el-button size="mini" type="text" @click="downloadFile(file.ossId)">下载</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty">暂无附件</div>
|
||||
</el-card>
|
||||
|
||||
<div class="block-title">盖章操作</div>
|
||||
<el-card class="inner-card" shadow="never">
|
||||
<div class="hint-text">仅当前审批人可操作盖章;盖章成功后才算审批通过。</div>
|
||||
<div v-if="canApprove" class="btn-row">
|
||||
<el-input v-model="actionRemark" type="textarea" :rows="3" placeholder="填写审批意见(可选)" />
|
||||
<div class="btn-row mt10">
|
||||
<el-button type="success" :loading="actionSubmitting" @click="openStampDialog">同意并盖章</el-button>
|
||||
<el-button type="danger" :loading="actionSubmitting" @click="reject">驳回</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty">当前无可操作的审批任务</div>
|
||||
</el-card>
|
||||
</el-card>
|
||||
|
||||
<el-dialog
|
||||
title="盖章确认"
|
||||
:visible.sync="stampDialogVisible"
|
||||
width="1200px"
|
||||
:close-on-click-modal="false"
|
||||
append-to-body
|
||||
class="pdf-preview-dialog"
|
||||
>
|
||||
<div class="pdf-preview-container">
|
||||
<div v-if="targetPdfFile && targetPdfFile.url" class="pdf-viewer">
|
||||
<div class="pdf-controls">
|
||||
<span class="hint-text" style="margin:0;">点击PDF选择盖章位置</span>
|
||||
<div style="flex:1;"></div>
|
||||
<el-button size="mini" @click="openPdfPreview">在新窗口打开</el-button>
|
||||
</div>
|
||||
|
||||
<PdfStamper
|
||||
:pdf-url="targetPdfFile.url"
|
||||
:initial-page="stampForm.pageNo || 1"
|
||||
@change="onStampChange"
|
||||
/>
|
||||
|
||||
<div class="pdf-hint">
|
||||
<div class="hint-text">当前选择:页码 {{ stampForm.pageNo || '-' }},x={{ stampForm.xPx !== null ? stampForm.xPx : '-' }},y={{ stampForm.yPx !== null ? stampForm.yPx : '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty">PDF文件加载失败</div>
|
||||
</div>
|
||||
|
||||
<div class="stamp-config">
|
||||
<el-form :model="stampForm" label-width="120px" size="small">
|
||||
<el-form-item label="选择印章">
|
||||
<el-select v-model="stampForm.stampImageUrl" placeholder="选择印章" filterable style="width: 100%">
|
||||
<el-option
|
||||
v-for="dict in dict.type.hrm_stamp_image"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="盖章页码">
|
||||
<el-input-number v-model="stampForm.pageNo" :min="1" :max="999" controls-position="right" style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="X 坐标">
|
||||
<el-input-number v-model="stampForm.xPx" :min="0" :precision="0" style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Y 坐标">
|
||||
<el-input-number v-model="stampForm.yPx" :min="0" :precision="0" style="width: 200px" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="stampDialogVisible = false">关闭</el-button>
|
||||
<el-button type="primary" :loading="stamping" @click="doStampAndApprove">盖章并通过</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getSealReq, rejectSealReq, approveSealReq, stampSealJava } from '@/api/wms/seal'
|
||||
import { listByIds } from '@/api/system/oss'
|
||||
import PdfStamper from '@/components/PdfStamper/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'WmsSealDetail',
|
||||
components: { PdfStamper },
|
||||
dicts: ['hrm_stamp_image'],
|
||||
data() {
|
||||
return {
|
||||
seal: {},
|
||||
loading: false,
|
||||
attachmentLoading: false,
|
||||
attachmentList: [],
|
||||
targetPdfFile: null,
|
||||
stampDialogVisible: false,
|
||||
stamping: false,
|
||||
actionSubmitting: false,
|
||||
actionRemark: '',
|
||||
stampForm: {
|
||||
pageNo: 1,
|
||||
stampImageUrl: '',
|
||||
xPx: null,
|
||||
yPx: null,
|
||||
widthPx: null,
|
||||
heightPx: null,
|
||||
viewportWidth: null,
|
||||
viewportHeight: null
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
currentBizId() {
|
||||
return this.$route?.params?.bizId || this.$route?.query?.bizId || this.$route?.params?.id
|
||||
},
|
||||
applicantText() {
|
||||
if (this.seal.createBy) {
|
||||
return this.seal.createBy
|
||||
}
|
||||
return this.seal.empId ? `员工ID:${this.seal.empId}` : '-'
|
||||
},
|
||||
canApprove() {
|
||||
const currentUserId = this.$store.getters.id
|
||||
return this.seal.status === 'running' && String(this.seal.approverId) === String(currentUserId)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loadDetail()
|
||||
},
|
||||
methods: {
|
||||
statusText(status) {
|
||||
const map = { running: '审批中', draft: '草稿', approved: '已通过', rejected: '已驳回', canceled: '已撤销' }
|
||||
return map[status] || status || '-'
|
||||
},
|
||||
statusType(status) {
|
||||
const map = { running: 'warning', draft: 'info', approved: 'success', rejected: 'danger', canceled: 'info' }
|
||||
return map[status] || 'info'
|
||||
},
|
||||
formatDate(val) {
|
||||
if (!val) return '-'
|
||||
const d = new Date(val)
|
||||
const p = n => (n < 10 ? `0${n}` : n)
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
|
||||
},
|
||||
async loadDetail() {
|
||||
const bizId = this.currentBizId
|
||||
if (!bizId) {
|
||||
this.$message.warning('缺少bizId')
|
||||
return
|
||||
}
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await getSealReq(bizId)
|
||||
this.seal = res.data || {}
|
||||
this.seal.approverId = this.seal.approverId || this.seal.approver_id || this.seal.approverUserId
|
||||
await this.loadAttachments()
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
async loadAttachments() {
|
||||
const fileIds = this.seal.applyFileIds
|
||||
if (!fileIds) {
|
||||
this.attachmentList = []
|
||||
this.targetPdfFile = null
|
||||
return
|
||||
}
|
||||
const ids = String(fileIds).split(',').map(id => id.trim()).filter(Boolean)
|
||||
if (!ids.length) {
|
||||
this.attachmentList = []
|
||||
this.targetPdfFile = null
|
||||
return
|
||||
}
|
||||
this.attachmentLoading = true
|
||||
try {
|
||||
const res = await listByIds(ids)
|
||||
this.attachmentList = res.data || []
|
||||
this.targetPdfFile = this.attachmentList.find(f => f.fileName && f.fileName.toLowerCase().endsWith('.pdf')) || this.attachmentList[0] || null
|
||||
const match = this.seal.remark ? this.seal.remark.match(/\[盖章页码:第(\d+)页\]/) : null
|
||||
if (match) {
|
||||
this.stampForm.pageNo = parseInt(match[1])
|
||||
}
|
||||
} catch (e) {
|
||||
this.attachmentList = []
|
||||
this.targetPdfFile = null
|
||||
} finally {
|
||||
this.attachmentLoading = false
|
||||
}
|
||||
},
|
||||
formatFileSize(bytes) {
|
||||
if (!bytes) return '-'
|
||||
const units = ['B', 'KB', 'MB', 'GB']
|
||||
let size = Number(bytes)
|
||||
let unitIndex = 0
|
||||
while (size >= 1024 && unitIndex < units.length - 1) {
|
||||
size /= 1024
|
||||
unitIndex++
|
||||
}
|
||||
return `${size.toFixed(2)} ${units[unitIndex]}`
|
||||
},
|
||||
previewFile(file) {
|
||||
if (file.url) {
|
||||
window.open(file.url, '_blank')
|
||||
} else {
|
||||
this.$message.warning('文件URL不存在')
|
||||
}
|
||||
},
|
||||
downloadFile(ossId) {
|
||||
window.open(`/system/oss/download/${ossId}`, '_blank')
|
||||
},
|
||||
previewReceipt() {
|
||||
if (!this.seal || !this.seal.receiptFileIds) return
|
||||
window.open(this.seal.receiptFileIds, '_blank')
|
||||
},
|
||||
downloadReceipt() {
|
||||
if (!this.seal || !this.seal.receiptFileIds) return
|
||||
window.open(this.seal.receiptFileIds, '_blank')
|
||||
},
|
||||
openPdfPreview() {
|
||||
if (this.targetPdfFile && this.targetPdfFile.url) {
|
||||
window.open(this.targetPdfFile.url, '_blank')
|
||||
} else {
|
||||
this.$message.warning('PDF文件URL不存在')
|
||||
}
|
||||
},
|
||||
openStampDialog() {
|
||||
if (!this.targetPdfFile || !this.targetPdfFile.url) {
|
||||
this.$message.warning('请先加载PDF文件')
|
||||
return
|
||||
}
|
||||
this.stampDialogVisible = true
|
||||
},
|
||||
onStampChange(params) {
|
||||
if (!params) return
|
||||
if (params.pageNo !== null && params.pageNo !== undefined) {
|
||||
this.stampForm.pageNo = Number(params.pageNo) || 1
|
||||
}
|
||||
if (params.xPx !== null && params.xPx !== undefined && !isNaN(Number(params.xPx))) {
|
||||
this.stampForm.xPx = Math.floor(Number(params.xPx))
|
||||
}
|
||||
if (params.yPx !== null && params.yPx !== undefined && !isNaN(Number(params.yPx))) {
|
||||
this.stampForm.yPx = Math.floor(Number(params.yPx))
|
||||
}
|
||||
if (params.viewportWidth !== null && params.viewportWidth !== undefined && !isNaN(Number(params.viewportWidth))) {
|
||||
this.stampForm.viewportWidth = Math.floor(Number(params.viewportWidth))
|
||||
}
|
||||
if (params.viewportHeight !== null && params.viewportHeight !== undefined && !isNaN(Number(params.viewportHeight))) {
|
||||
this.stampForm.viewportHeight = Math.floor(Number(params.viewportHeight))
|
||||
}
|
||||
},
|
||||
async doStampAndApprove() {
|
||||
if (!this.canApprove) {
|
||||
this.$message.warning('你不是当前审批人,无法盖章')
|
||||
return
|
||||
}
|
||||
if (!this.stampForm.stampImageUrl) {
|
||||
this.$message.warning('请选择印章')
|
||||
return
|
||||
}
|
||||
if (this.stampForm.xPx === null || this.stampForm.yPx === null) {
|
||||
this.$message.warning('请选择盖章位置')
|
||||
return
|
||||
}
|
||||
try {
|
||||
this.stamping = true
|
||||
const payload = {
|
||||
targetFileUrl: this.targetPdfFile.url,
|
||||
stampImageUrl: this.stampForm.stampImageUrl,
|
||||
pageNo: Number(this.stampForm.pageNo),
|
||||
xPx: Math.floor(Number(this.stampForm.xPx)),
|
||||
yPx: Math.floor(Number(this.stampForm.yPx)),
|
||||
viewportWidth: this.stampForm.viewportWidth,
|
||||
viewportHeight: this.stampForm.viewportHeight
|
||||
}
|
||||
await stampSealJava(this.currentBizId, payload)
|
||||
await approveSealReq(this.currentBizId, this.actionRemark)
|
||||
this.$message.success('盖章成功,审批已通过')
|
||||
this.stampDialogVisible = false
|
||||
this.loadDetail()
|
||||
} finally {
|
||||
this.stamping = false
|
||||
}
|
||||
},
|
||||
async reject() {
|
||||
this.actionSubmitting = true
|
||||
try {
|
||||
await rejectSealReq(this.currentBizId, this.actionRemark)
|
||||
this.$message.success('已驳回')
|
||||
this.loadDetail()
|
||||
} finally {
|
||||
this.actionSubmitting = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.request-page {
|
||||
padding: 16px 20px 32px;
|
||||
background: #f8f9fb;
|
||||
}
|
||||
.form-card {
|
||||
max-width: 980px;
|
||||
margin: 0 auto;
|
||||
border: 1px solid #d7d9df;
|
||||
border-radius: 12px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-weight: 700;
|
||||
color: #2b2f36;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.block-title {
|
||||
margin: 12px 0 8px;
|
||||
padding-left: 10px;
|
||||
font-weight: 700;
|
||||
color: #2f3440;
|
||||
border-left: 3px solid #9aa3b2;
|
||||
}
|
||||
.hint-text {
|
||||
margin: 6px 0 10px;
|
||||
font-size: 12px;
|
||||
color: #8a8f99;
|
||||
}
|
||||
.form-summary {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 12px;
|
||||
margin-bottom: 12px;
|
||||
border: 1px solid #e6e8ed;
|
||||
border-radius: 10px;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
|
||||
}
|
||||
.summary-title {
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
color: #2b2f36;
|
||||
}
|
||||
.summary-sub {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: #8a8f99;
|
||||
}
|
||||
.summary-right {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
.summary-item .k {
|
||||
font-size: 12px;
|
||||
color: #8a8f99;
|
||||
}
|
||||
.summary-item .v {
|
||||
margin-top: 2px;
|
||||
font-weight: 700;
|
||||
color: #2b2f36;
|
||||
}
|
||||
.inner-card {
|
||||
border: 1px solid #e6e8ed;
|
||||
}
|
||||
.empty {
|
||||
color: #a0a3ad;
|
||||
font-size: 13px;
|
||||
padding: 10px 4px;
|
||||
}
|
||||
.btn-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.mt10 {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.attachment-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.attachment-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #e6e8ed;
|
||||
border-radius: 8px;
|
||||
background: #fafbfc;
|
||||
}
|
||||
.file-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex: 1;
|
||||
}
|
||||
.file-icon {
|
||||
font-size: 24px;
|
||||
color: #9aa3b2;
|
||||
}
|
||||
.file-details {
|
||||
flex: 1;
|
||||
}
|
||||
.file-name {
|
||||
font-weight: 600;
|
||||
color: #2b2f36;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.file-meta {
|
||||
font-size: 12px;
|
||||
color: #8a8f99;
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
.file-time {
|
||||
margin-left: 8px;
|
||||
}
|
||||
.receipt-panel {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 12px;
|
||||
border: 1px dashed #d7d9df;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
.receipt-title {
|
||||
font-weight: 700;
|
||||
color: #2b2f36;
|
||||
}
|
||||
.page-no-text {
|
||||
font-weight: 600;
|
||||
color: #2b2f36;
|
||||
}
|
||||
.text-muted {
|
||||
color: #8a8f99;
|
||||
font-size: 12px;
|
||||
}
|
||||
.pdf-preview-container {
|
||||
padding: 12px 0;
|
||||
}
|
||||
.pdf-viewer {
|
||||
position: relative;
|
||||
}
|
||||
.pdf-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.pdf-hint {
|
||||
margin-top: 12px;
|
||||
padding: 12px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.stamp-config {
|
||||
margin-top: 12px;
|
||||
padding: 12px;
|
||||
background: #fafbfc;
|
||||
border-radius: 8px;
|
||||
}
|
||||
@media (max-width: 1200px) {
|
||||
.summary-right {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
40
klp-wms/src/main/java/com/klp/config/StampProperties.java
Normal file
40
klp-wms/src/main/java/com/klp/config/StampProperties.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.klp.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Stamp service configuration.
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "stamp")
|
||||
public class StampProperties {
|
||||
|
||||
private PythonService pythonService = new PythonService();
|
||||
private JavaService javaService = new JavaService();
|
||||
|
||||
@Data
|
||||
public static class PythonService {
|
||||
/**
|
||||
* Whether to call external python stamp service.
|
||||
*/
|
||||
private boolean enabled = false;
|
||||
private String baseUrl;
|
||||
private String apiKey;
|
||||
private Integer timeoutMs = 5000;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class JavaService {
|
||||
/**
|
||||
* Enable in-Java stamping.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
/**
|
||||
* Default DPI for px → user-space conversion if needed.
|
||||
*/
|
||||
private Integer dpi = 72;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.klp.controller;
|
||||
|
||||
import com.klp.common.annotation.Log;
|
||||
import com.klp.common.core.controller.BaseController;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.domain.R;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.domain.bo.WmsSealReqBo;
|
||||
import com.klp.domain.bo.WmsSealStampBo;
|
||||
import com.klp.domain.vo.WmsSealReqVo;
|
||||
import com.klp.service.IWmsSealReqService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 用印申请
|
||||
*/
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/wms/seal")
|
||||
public class WmsSealReqController extends BaseController {
|
||||
|
||||
private final IWmsSealReqService service;
|
||||
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WmsSealReqVo> list(WmsSealReqBo bo, PageQuery pageQuery) {
|
||||
return service.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@GetMapping("/{bizId}")
|
||||
public R<WmsSealReqVo> getInfo(@PathVariable @NotNull Long bizId) {
|
||||
return R.ok(service.queryById(bizId));
|
||||
}
|
||||
|
||||
@Log(title = "用印申请", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody WmsSealReqBo bo) {
|
||||
return toAjax(service.insertByBo(bo));
|
||||
}
|
||||
|
||||
@Log(title = "用印申请", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody WmsSealReqBo bo) {
|
||||
return toAjax(service.updateByBo(bo));
|
||||
}
|
||||
|
||||
@Log(title = "用印申请", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{bizIds}")
|
||||
public R<Void> remove(@PathVariable @NotEmpty Long[] bizIds) {
|
||||
return toAjax(service.deleteWithValidByIds(java.util.Arrays.asList(bizIds), true));
|
||||
}
|
||||
|
||||
@Log(title = "用印申请", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{bizId}/approve")
|
||||
public R<Void> approve(@PathVariable @NotNull Long bizId,
|
||||
@RequestParam(required = false) String approvalOpinion) {
|
||||
return toAjax(service.approveByDeptLeader(bizId, approvalOpinion));
|
||||
}
|
||||
|
||||
@Log(title = "用印申请", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{bizId}/reject")
|
||||
public R<Void> reject(@PathVariable @NotNull Long bizId,
|
||||
@RequestParam(required = false) String approvalOpinion) {
|
||||
return toAjax(service.rejectByDeptLeader(bizId, approvalOpinion));
|
||||
}
|
||||
|
||||
@Log(title = "用印申请", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{bizId}/cancel")
|
||||
public R<Void> cancel(@PathVariable @NotNull Long bizId) {
|
||||
return toAjax(service.updateStatus(bizId, "canceled"));
|
||||
}
|
||||
|
||||
@Log(title = "用印盖章(Java)", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{bizId}/stamp/java")
|
||||
public R<String> stampJava(@PathVariable @NotNull Long bizId, @Validated @RequestBody WmsSealStampBo bo) {
|
||||
log.info("收到盖章请求 - bizId: {}, yPx: {}, xPx: {}, pageNo: {}, yPx类型: {}",
|
||||
bizId, bo.getYPx(), bo.getXPx(), bo.getPageNo(),
|
||||
bo.getYPx() != null ? bo.getYPx().getClass().getName() : "null");
|
||||
if (bo.getYPx() == null) {
|
||||
log.error("yPx 为 null!接收到的 bo 对象: {}", bo);
|
||||
}
|
||||
return R.ok(service.stampWithJava(bizId, bo));
|
||||
}
|
||||
|
||||
@Log(title = "用印盖章(Python)", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{bizId}/stamp/python")
|
||||
public R<String> stampPython(@PathVariable @NotNull Long bizId, @Validated @RequestBody WmsSealStampBo bo) {
|
||||
return R.ok(service.stampWithPython(bizId, bo));
|
||||
}
|
||||
}
|
||||
55
klp-wms/src/main/java/com/klp/domain/WmsSealReq.java
Normal file
55
klp-wms/src/main/java/com/klp/domain/WmsSealReq.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.klp.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.klp.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用印申请
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("hrm_seal_req")
|
||||
public class WmsSealReq extends BaseEntity {
|
||||
|
||||
/** 业务ID */
|
||||
@TableId
|
||||
private Long bizId;
|
||||
|
||||
/** 申请人ID */
|
||||
private Long empId;
|
||||
|
||||
/** 申请部门ID */
|
||||
private Long deptId;
|
||||
|
||||
/** 用印类型(公章/合同章/财务章等) */
|
||||
private String sealType;
|
||||
|
||||
/** 用途说明 */
|
||||
private String purpose;
|
||||
|
||||
/** 申请材料附件ID列表(CSV,对应sys_oss) */
|
||||
private String applyFileIds;
|
||||
|
||||
/** 是否需要回执 1是0否 */
|
||||
private Integer receiptRequired;
|
||||
|
||||
/** 回执状态 none/pending/done */
|
||||
private String receiptStatus;
|
||||
|
||||
/** 回执附件ID列表(CSV,对应sys_oss或直接URL) */
|
||||
private String receiptFileIds;
|
||||
|
||||
/** 状态 draft/running/approved/rejected/canceled */
|
||||
private String status;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 删除标识 0正常 2删除 */
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
46
klp-wms/src/main/java/com/klp/domain/bo/WmsSealReqBo.java
Normal file
46
klp-wms/src/main/java/com/klp/domain/bo/WmsSealReqBo.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.klp.domain.bo;
|
||||
|
||||
import com.klp.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 用印申请 Bo
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WmsSealReqBo extends BaseEntity {
|
||||
|
||||
/** 业务ID(编辑/审批时必填) */
|
||||
private Long bizId;
|
||||
|
||||
/** 申请人ID */
|
||||
@NotNull(message = "申请人不能为空")
|
||||
private Long empId;
|
||||
|
||||
/** 用印类型 */
|
||||
@NotBlank(message = "用印类型不能为空")
|
||||
private String sealType;
|
||||
|
||||
/** 用途说明 */
|
||||
private String purpose;
|
||||
|
||||
/** 申请材料附件ID列表(CSV,对应sys_oss) */
|
||||
private String applyFileIds;
|
||||
|
||||
/** 是否需要回执 1是0否 */
|
||||
private Integer receiptRequired;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 申请部门ID */
|
||||
@NotNull(message = "申请部门不能为空")
|
||||
private Long deptId;
|
||||
|
||||
/** 状态 draft/running/approved/rejected/canceled */
|
||||
private String status;
|
||||
}
|
||||
98
klp-wms/src/main/java/com/klp/domain/bo/WmsSealStampBo.java
Normal file
98
klp-wms/src/main/java/com/klp/domain/bo/WmsSealStampBo.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package com.klp.domain.bo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 盖章命令(Java/Python 坐标统一使用 px)
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||
public class WmsSealStampBo {
|
||||
|
||||
/** 待盖章 PDF 的 OSS 完整 URL */
|
||||
@NotBlank(message = "待盖章文件地址不能为空")
|
||||
@JsonProperty("targetFileUrl")
|
||||
private String targetFileUrl;
|
||||
|
||||
/** 章图片 OSS 完整 URL(透明 PNG/JPG) */
|
||||
@NotBlank(message = "章图片地址不能为空")
|
||||
@JsonProperty("stampImageUrl")
|
||||
private String stampImageUrl;
|
||||
|
||||
/** 页码(从1开始) */
|
||||
@NotNull
|
||||
@Min(1)
|
||||
@JsonProperty("pageNo")
|
||||
private Integer pageNo;
|
||||
|
||||
/** 左下角 X 坐标(px) */
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@JsonProperty("xPx")
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||
@Setter(lombok.AccessLevel.NONE)
|
||||
private Integer xPx;
|
||||
|
||||
/** 左下角 Y 坐标(px) */
|
||||
@NotNull
|
||||
@Min(0)
|
||||
@JsonProperty("yPx")
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||
@Setter(lombok.AccessLevel.NONE)
|
||||
private Integer yPx;
|
||||
|
||||
/** 盖章宽度(px,可选) */
|
||||
@Min(1)
|
||||
@JsonProperty("widthPx")
|
||||
private Integer widthPx;
|
||||
|
||||
/** 盖章高度(px,可选) */
|
||||
@Min(1)
|
||||
@JsonProperty("heightPx")
|
||||
private Integer heightPx;
|
||||
|
||||
/**
|
||||
* 前端渲染的 viewport 宽度(像素):用于把前端点击坐标换算成 PDFBox 坐标(pt)。
|
||||
* 注意:这不是 PDF 页面原始宽度,而是 pdf.js 按 scale 渲染到 canvas 的宽度。
|
||||
*/
|
||||
@Min(1)
|
||||
@JsonProperty("viewportWidth")
|
||||
private Integer viewportWidth;
|
||||
|
||||
/** 前端渲染的 viewport 高度(像素):用于坐标换算 */
|
||||
@Min(1)
|
||||
@JsonProperty("viewportHeight")
|
||||
private Integer viewportHeight;
|
||||
|
||||
/**
|
||||
* 手动添加 setter 方法,确保 Jackson 能够正确映射 yPx 字段
|
||||
* Lombok 生成的 setYPx() 可能与 Jackson 的字段名映射不匹配
|
||||
*/
|
||||
@JsonSetter("yPx")
|
||||
public void setYPx(Integer yPx) {
|
||||
this.yPx = yPx;
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动添加 setter 方法,确保 Jackson 能够正确映射 xPx 字段
|
||||
*/
|
||||
@JsonSetter("xPx")
|
||||
public void setXPx(Integer xPx) {
|
||||
this.xPx = xPx;
|
||||
}
|
||||
}
|
||||
50
klp-wms/src/main/java/com/klp/domain/vo/WmsSealReqVo.java
Normal file
50
klp-wms/src/main/java/com/klp/domain/vo/WmsSealReqVo.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.klp.domain.vo;
|
||||
|
||||
import com.klp.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用印申请 VO
|
||||
*/
|
||||
@Data
|
||||
public class WmsSealReqVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Excel(name = "业务ID")
|
||||
private Long bizId;
|
||||
|
||||
@Excel(name = "申请人ID")
|
||||
private Long empId;
|
||||
|
||||
@Excel(name = "用印类型")
|
||||
private String sealType;
|
||||
|
||||
@Excel(name = "用途说明")
|
||||
private String purpose;
|
||||
|
||||
@Excel(name = "申请材料附件ID列表")
|
||||
private String applyFileIds;
|
||||
|
||||
@Excel(name = "是否需要回执")
|
||||
private Integer receiptRequired;
|
||||
|
||||
@Excel(name = "回执状态")
|
||||
private String receiptStatus;
|
||||
|
||||
@Excel(name = "回执附件ID列表")
|
||||
private String receiptFileIds;
|
||||
|
||||
@Excel(name = "状态")
|
||||
private String status;
|
||||
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
private String createBy;
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
private Date updateTime;
|
||||
}
|
||||
11
klp-wms/src/main/java/com/klp/mapper/WmsSealReqMapper.java
Normal file
11
klp-wms/src/main/java/com/klp/mapper/WmsSealReqMapper.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.klp.mapper;
|
||||
|
||||
import com.klp.common.core.mapper.BaseMapperPlus;
|
||||
import com.klp.domain.WmsSealReq;
|
||||
import com.klp.domain.vo.WmsSealReqVo;
|
||||
|
||||
/**
|
||||
* 用印申请 Mapper
|
||||
*/
|
||||
public interface WmsSealReqMapper extends BaseMapperPlus<WmsSealReqMapper, WmsSealReq, WmsSealReqVo> {
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.klp.service;
|
||||
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.domain.bo.WmsSealReqBo;
|
||||
import com.klp.domain.bo.WmsSealStampBo;
|
||||
import com.klp.domain.vo.WmsSealReqVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface IWmsSealReqService {
|
||||
|
||||
WmsSealReqVo queryById(Long bizId);
|
||||
|
||||
TableDataInfo<WmsSealReqVo> queryPageList(WmsSealReqBo bo, PageQuery pageQuery);
|
||||
|
||||
List<WmsSealReqVo> queryList(WmsSealReqBo bo);
|
||||
|
||||
Boolean insertByBo(WmsSealReqBo bo);
|
||||
|
||||
Boolean updateByBo(WmsSealReqBo bo);
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 部门负责人审批通过
|
||||
*/
|
||||
Boolean approveByDeptLeader(Long bizId, String approvalOpinion);
|
||||
|
||||
/**
|
||||
* 部门负责人审批驳回
|
||||
*/
|
||||
Boolean rejectByDeptLeader(Long bizId, String approvalOpinion);
|
||||
|
||||
/**
|
||||
* 简单状态更新(draft/running/approved/rejected/canceled)
|
||||
*/
|
||||
Boolean updateStatus(Long bizId, String status);
|
||||
|
||||
/**
|
||||
* Java 盖章,返回盖章后文件 URL
|
||||
*/
|
||||
String stampWithJava(Long bizId, WmsSealStampBo cmd);
|
||||
|
||||
/**
|
||||
* Python 盖章占位(调用外部服务)
|
||||
*/
|
||||
String stampWithPython(Long bizId, WmsSealStampBo cmd);
|
||||
}
|
||||
@@ -0,0 +1,363 @@
|
||||
package com.klp.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.domain.entity.SysUser;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.exception.ServiceException;
|
||||
import com.klp.config.StampProperties;
|
||||
import com.klp.domain.WmsApproval;
|
||||
import com.klp.domain.WmsApprovalTask;
|
||||
import com.klp.domain.WmsDept;
|
||||
import com.klp.domain.WmsSealReq;
|
||||
import com.klp.domain.bo.WmsSealReqBo;
|
||||
import com.klp.domain.bo.WmsSealStampBo;
|
||||
import com.klp.domain.vo.WmsSealReqVo;
|
||||
import com.klp.mapper.WmsApprovalMapper;
|
||||
import com.klp.mapper.WmsApprovalTaskMapper;
|
||||
import com.klp.mapper.WmsDeptMapper;
|
||||
import com.klp.mapper.WmsSealReqMapper;
|
||||
import com.klp.oss.core.OssClient;
|
||||
import com.klp.oss.entity.UploadResult;
|
||||
import com.klp.oss.factory.OssFactory;
|
||||
import com.klp.service.IWmsSealReqService;
|
||||
import com.klp.system.mapper.SysUserMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.PDPage;
|
||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
||||
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用印申请 服务实现
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class WmsSealReqServiceImpl implements IWmsSealReqService {
|
||||
|
||||
private final WmsSealReqMapper baseMapper;
|
||||
private final WmsDeptMapper wmsDeptMapper;
|
||||
private final SysUserMapper sysUserMapper;
|
||||
private final WmsApprovalMapper approvalMapper;
|
||||
private final WmsApprovalTaskMapper approvalTaskMapper;
|
||||
private final StampProperties stampProperties;
|
||||
|
||||
@Override
|
||||
public WmsSealReqVo queryById(Long bizId) {
|
||||
return baseMapper.selectVoById(bizId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WmsSealReqVo> queryPageList(WmsSealReqBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<WmsSealReq> lqw = buildQueryWrapper(bo);
|
||||
Page<WmsSealReqVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WmsSealReqVo> queryList(WmsSealReqBo bo) {
|
||||
LambdaQueryWrapper<WmsSealReq> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(WmsSealReqBo bo) {
|
||||
WmsSealReq add = BeanUtil.toBean(bo, WmsSealReq.class);
|
||||
add.setStatus(defaultStatus(add.getStatus()));
|
||||
validEntityBeforeSave(add);
|
||||
boolean ok = baseMapper.insert(add) > 0;
|
||||
if (ok) {
|
||||
createDeptLeaderApproval(add, bo.getDeptId());
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(WmsSealReqBo bo) {
|
||||
if (bo.getBizId() == null) {
|
||||
throw new ServiceException("bizId不能为空");
|
||||
}
|
||||
WmsSealReq update = BeanUtil.toBean(bo, WmsSealReq.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
// 可添加业务校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean approveByDeptLeader(Long bizId, String approvalOpinion) {
|
||||
WmsSealReq req = baseMapper.selectById(bizId);
|
||||
if (req == null) {
|
||||
throw new ServiceException("用印申请不存在");
|
||||
}
|
||||
WmsApproval approval = getApprovalByApplyId(bizId);
|
||||
if (approval == null) {
|
||||
throw new ServiceException("审批记录不存在");
|
||||
}
|
||||
WmsApprovalTask task = getPendingTaskForCurrentLeader(approval.getApprovalId(), req.getDeptId());
|
||||
if (task == null) {
|
||||
throw new ServiceException("当前用户不是该部门负责人或审批任务不存在");
|
||||
}
|
||||
|
||||
task.setTaskStatus("approved");
|
||||
task.setApprovalOpinion(approvalOpinion);
|
||||
task.setApprovalTime(new Date());
|
||||
approvalTaskMapper.updateById(task);
|
||||
|
||||
approval.setApprovalStatus("已同意");
|
||||
approval.setFinalStatus("all_approved");
|
||||
approval.setApprovalOpinion(approvalOpinion);
|
||||
approval.setApprovalTime(new Date());
|
||||
approvalMapper.updateById(approval);
|
||||
|
||||
updateStatus(bizId, "approved");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean rejectByDeptLeader(Long bizId, String approvalOpinion) {
|
||||
WmsSealReq req = baseMapper.selectById(bizId);
|
||||
if (req == null) {
|
||||
throw new ServiceException("用印申请不存在");
|
||||
}
|
||||
WmsApproval approval = getApprovalByApplyId(bizId);
|
||||
if (approval == null) {
|
||||
throw new ServiceException("审批记录不存在");
|
||||
}
|
||||
WmsApprovalTask task = getPendingTaskForCurrentLeader(approval.getApprovalId(), req.getDeptId());
|
||||
if (task == null) {
|
||||
throw new ServiceException("当前用户不是该部门负责人或审批任务不存在");
|
||||
}
|
||||
|
||||
task.setTaskStatus("rejected");
|
||||
task.setApprovalOpinion(approvalOpinion);
|
||||
task.setApprovalTime(new Date());
|
||||
approvalTaskMapper.updateById(task);
|
||||
|
||||
approval.setApprovalStatus("已驳回");
|
||||
approval.setFinalStatus("rejected");
|
||||
approval.setApprovalOpinion(approvalOpinion);
|
||||
approval.setApprovalTime(new Date());
|
||||
approvalMapper.updateById(approval);
|
||||
|
||||
updateStatus(bizId, "rejected");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateStatus(Long bizId, String status) {
|
||||
WmsSealReq req = new WmsSealReq();
|
||||
req.setBizId(bizId);
|
||||
req.setStatus(status);
|
||||
return baseMapper.updateById(req) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String stampWithJava(Long bizId, WmsSealStampBo cmd) {
|
||||
if (!Boolean.TRUE.equals(stampProperties.getJavaService().isEnabled())) {
|
||||
throw new ServiceException("Java盖章未启用");
|
||||
}
|
||||
String resultUrl = doPdfStamp(cmd);
|
||||
WmsSealReq update = new WmsSealReq();
|
||||
update.setBizId(bizId);
|
||||
update.setReceiptStatus("done");
|
||||
update.setReceiptFileIds(resultUrl);
|
||||
baseMapper.updateById(update);
|
||||
return resultUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String stampWithPython(Long bizId, WmsSealStampBo cmd) {
|
||||
if (!Boolean.TRUE.equals(stampProperties.getPythonService().isEnabled())) {
|
||||
throw new ServiceException("Python盖章未启用");
|
||||
}
|
||||
throw new ServiceException("Python盖章接口未实现");
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WmsSealReq> buildQueryWrapper(WmsSealReqBo bo) {
|
||||
LambdaQueryWrapper<WmsSealReq> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getBizId() != null, WmsSealReq::getBizId, bo.getBizId());
|
||||
lqw.eq(bo.getEmpId() != null, WmsSealReq::getEmpId, bo.getEmpId());
|
||||
lqw.eq(bo.getSealType() != null, WmsSealReq::getSealType, bo.getSealType());
|
||||
lqw.eq(bo.getStatus() != null, WmsSealReq::getStatus, bo.getStatus());
|
||||
lqw.orderByDesc(WmsSealReq::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
private void validEntityBeforeSave(WmsSealReq entity) {
|
||||
// 预留数据校验,如唯一约束
|
||||
}
|
||||
|
||||
private String defaultStatus(String status) {
|
||||
return status == null ? "draft" : status;
|
||||
}
|
||||
|
||||
private void createDeptLeaderApproval(WmsSealReq req, Long deptId) {
|
||||
if (deptId == null) {
|
||||
return;
|
||||
}
|
||||
WmsDept dept = wmsDeptMapper.selectById(deptId);
|
||||
if (dept == null || dept.getLeader() == null) {
|
||||
return;
|
||||
}
|
||||
SysUser leader = sysUserMapper.selectById(dept.getLeader());
|
||||
if (leader == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
WmsApproval approval = new WmsApproval();
|
||||
approval.setApplyType("seal");
|
||||
approval.setApplyId(req.getBizId());
|
||||
approval.setApproverName(leader.getNickName());
|
||||
approval.setApprovalStatus("待审批");
|
||||
approval.setApprovalType("single");
|
||||
approval.setRequiredApprovers(1);
|
||||
approval.setCurrentApprovers(0);
|
||||
approval.setFinalStatus("pending");
|
||||
approval.setCreateBy(req.getCreateBy());
|
||||
approval.setCreateTime(req.getCreateTime());
|
||||
approvalMapper.insert(approval);
|
||||
|
||||
WmsApprovalTask task = new WmsApprovalTask();
|
||||
task.setApprovalId(approval.getApprovalId());
|
||||
task.setApproverId(leader.getUserId());
|
||||
task.setApproverName(leader.getNickName());
|
||||
task.setTaskStatus("pending");
|
||||
task.setCreateBy(req.getCreateBy());
|
||||
task.setCreateTime(req.getCreateTime());
|
||||
approvalTaskMapper.insert(task);
|
||||
|
||||
updateStatus(req.getBizId(), "running");
|
||||
}
|
||||
|
||||
private WmsApproval getApprovalByApplyId(Long applyId) {
|
||||
return approvalMapper.selectOne(Wrappers.<WmsApproval>lambdaQuery()
|
||||
.eq(WmsApproval::getApplyType, "seal")
|
||||
.eq(WmsApproval::getApplyId, applyId)
|
||||
.eq(WmsApproval::getDelFlag, 0));
|
||||
}
|
||||
|
||||
private WmsApprovalTask getPendingTaskForCurrentLeader(Long approvalId, Long deptId) {
|
||||
if (approvalId == null || deptId == null) {
|
||||
return null;
|
||||
}
|
||||
WmsDept dept = wmsDeptMapper.selectById(deptId);
|
||||
if (dept == null || dept.getLeader() == null) {
|
||||
return null;
|
||||
}
|
||||
Long leaderId = dept.getLeader();
|
||||
return approvalTaskMapper.selectOne(Wrappers.<WmsApprovalTask>lambdaQuery()
|
||||
.eq(WmsApprovalTask::getApprovalId, approvalId)
|
||||
.eq(WmsApprovalTask::getApproverId, leaderId)
|
||||
.eq(WmsApprovalTask::getTaskStatus, "pending")
|
||||
.eq(WmsApprovalTask::getDelFlag, 0));
|
||||
}
|
||||
|
||||
private String doPdfStamp(WmsSealStampBo cmd) {
|
||||
try (InputStream pdfIn = getObject(cmd.getTargetFileUrl());
|
||||
InputStream imgIn = getObject(cmd.getStampImageUrl());
|
||||
PDDocument document = PDDocument.load(pdfIn);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
|
||||
|
||||
int pageIndex = cmd.getPageNo() - 1;
|
||||
if (pageIndex < 0 || pageIndex >= document.getNumberOfPages()) {
|
||||
throw new ServiceException("页码超出范围");
|
||||
}
|
||||
PDPage page = document.getPage(pageIndex);
|
||||
PDRectangle mediaBox = page.getMediaBox();
|
||||
|
||||
byte[] imgBytes = IoUtil.readBytes(imgIn);
|
||||
PDImageXObject image = PDImageXObject.createFromByteArray(document, imgBytes, "stamp");
|
||||
|
||||
float stampW = image.getWidth();
|
||||
float stampH = image.getHeight();
|
||||
|
||||
float pdfW = mediaBox.getWidth();
|
||||
float pdfH = mediaBox.getHeight();
|
||||
|
||||
float x;
|
||||
float y;
|
||||
if (cmd.getViewportWidth() != null && cmd.getViewportHeight() != null
|
||||
&& cmd.getViewportWidth() > 0 && cmd.getViewportHeight() > 0) {
|
||||
float ratioX = pdfW / cmd.getViewportWidth();
|
||||
float ratioY = pdfH / cmd.getViewportHeight();
|
||||
x = cmd.getXPx() * ratioX;
|
||||
y = cmd.getYPx() * ratioY;
|
||||
} else {
|
||||
x = cmd.getXPx();
|
||||
y = cmd.getYPx();
|
||||
}
|
||||
|
||||
final float maxCm = 4.0f;
|
||||
final float maxPt = maxCm * 72.0f / 2.54f;
|
||||
float scale = Math.min(maxPt / stampW, maxPt / stampH);
|
||||
scale = Math.min(scale, 1.0f);
|
||||
|
||||
float width = stampW * scale;
|
||||
float height = stampH * scale;
|
||||
|
||||
log.info("[stamp] pdfW={},pdfH={}, viewportW={},viewportH={}, ratioX={},ratioY={}, xPx={},yPx={}, x={},y={}, stampW={},stampH={}, drawW={},drawH={}",
|
||||
pdfW, pdfH,
|
||||
cmd.getViewportWidth(), cmd.getViewportHeight(),
|
||||
(cmd.getViewportWidth() != null && cmd.getViewportWidth() > 0) ? (pdfW / cmd.getViewportWidth()) : null,
|
||||
(cmd.getViewportHeight() != null && cmd.getViewportHeight() > 0) ? (pdfH / cmd.getViewportHeight()) : null,
|
||||
cmd.getXPx(), cmd.getYPx(),
|
||||
x, y,
|
||||
stampW, stampH,
|
||||
width, height);
|
||||
|
||||
if (x + width > mediaBox.getWidth()) {
|
||||
x = Math.max(0, mediaBox.getWidth() - width);
|
||||
}
|
||||
if (y + height > mediaBox.getHeight()) {
|
||||
y = Math.max(0, mediaBox.getHeight() - height);
|
||||
}
|
||||
|
||||
try (PDPageContentStream contentStream = new PDPageContentStream(document, page,
|
||||
PDPageContentStream.AppendMode.APPEND, true, true)) {
|
||||
contentStream.drawImage(image, x, y, width, height);
|
||||
}
|
||||
|
||||
document.save(bos);
|
||||
|
||||
OssClient storage = OssFactory.instance();
|
||||
UploadResult uploadResult = storage.uploadSuffix(bos.toByteArray(), ".pdf", "application/pdf");
|
||||
return uploadResult.getUrl();
|
||||
} catch (Exception e) {
|
||||
log.error("PDF盖章失败", e);
|
||||
throw new ServiceException("PDF盖章失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream getObject(String url) {
|
||||
OssClient storage = OssFactory.instance();
|
||||
return storage.getObjectContent(url);
|
||||
}
|
||||
}
|
||||
25
klp-wms/src/main/resources/mapper/klp/WmsSealReqMapper.xml
Normal file
25
klp-wms/src/main/resources/mapper/klp/WmsSealReqMapper.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.klp.mapper.WmsSealReqMapper">
|
||||
|
||||
<resultMap type="com.klp.domain.WmsSealReq" id="WmsSealReqResult">
|
||||
<id property="bizId" column="biz_id"/>
|
||||
<result property="empId" column="emp_id"/>
|
||||
<result property="sealType" column="seal_type"/>
|
||||
<result property="purpose" column="purpose"/>
|
||||
<result property="applyFileIds" column="apply_file_ids"/>
|
||||
<result property="receiptRequired" column="receipt_required"/>
|
||||
<result property="receiptStatus" column="receipt_status"/>
|
||||
<result property="receiptFileIds" column="receipt_file_ids"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user