feat(wms): 增加版本管理功能和操作按钮
在规程主表的操作列中新增“版本与方案”按钮,点击后可跳转至版本管理页面。更新了操作列的宽度以适应新按钮。同时,在后端服务中添加了对规程版本存在性的校验,确保在删除规程时不会影响相关版本数据。
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
-- 规程版本表
|
||||
CREATE TABLE wms_process_spec_version (
|
||||
version_id BIGINT NOT NULL COMMENT '主键',
|
||||
spec_id BIGINT NOT NULL COMMENT '规程主表ID',
|
||||
version_code VARCHAR(64) NOT NULL COMMENT '版本号',
|
||||
is_active TINYINT NOT NULL DEFAULT 0 COMMENT '是否当前生效(0否1是)',
|
||||
status VARCHAR(32) NOT NULL DEFAULT 'DRAFT' COMMENT '状态(DRAFT草稿/PUBLISHED已发布/OBSOLETE作废等)',
|
||||
create_by VARCHAR(64) NULL COMMENT '创建人',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_by VARCHAR(64) NULL COMMENT '更新人',
|
||||
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
del_flag TINYINT NOT NULL DEFAULT 0 COMMENT '删除标志(0正常2删除)',
|
||||
remark VARCHAR(500) NULL COMMENT '备注',
|
||||
PRIMARY KEY (version_id),
|
||||
UNIQUE KEY uk_spec_version_code (spec_id, version_code),
|
||||
KEY idx_spec_version_spec (spec_id),
|
||||
KEY idx_spec_version_active (spec_id, is_active)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='规程版本表';
|
||||
|
||||
-- 方案点位表
|
||||
CREATE TABLE wms_process_plan (
|
||||
plan_id BIGINT NOT NULL COMMENT '主键',
|
||||
version_id BIGINT NOT NULL COMMENT '规程版本ID',
|
||||
segment_type VARCHAR(32) NOT NULL COMMENT '段类型(INLET/PROCESS/OUTLET)',
|
||||
segment_name VARCHAR(100) NULL COMMENT '段名称',
|
||||
point_name VARCHAR(200) NOT NULL COMMENT '点位名称',
|
||||
point_code VARCHAR(64) NOT NULL COMMENT '点位编码',
|
||||
sort_order INT NOT NULL DEFAULT 0 COMMENT '排序',
|
||||
create_by VARCHAR(64) NULL COMMENT '创建人',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_by VARCHAR(64) NULL COMMENT '更新人',
|
||||
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
del_flag TINYINT NOT NULL DEFAULT 0 COMMENT '删除标志(0正常2删除)',
|
||||
remark VARCHAR(500) NULL COMMENT '备注',
|
||||
PRIMARY KEY (plan_id),
|
||||
UNIQUE KEY uk_plan_version_point_code (version_id, point_code),
|
||||
KEY idx_plan_version (version_id),
|
||||
KEY idx_plan_sort (version_id, sort_order)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='方案点位表';
|
||||
39
klp-ui/src/api/wms/processPlan.js
Normal file
39
klp-ui/src/api/wms/processPlan.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listProcessPlan(query) {
|
||||
return request({
|
||||
url: '/wms/processPlan/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function getProcessPlan(planId) {
|
||||
return request({
|
||||
url: '/wms/processPlan/' + planId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function addProcessPlan(data) {
|
||||
return request({
|
||||
url: '/wms/processPlan',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateProcessPlan(data) {
|
||||
return request({
|
||||
url: '/wms/processPlan',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function delProcessPlan(planId) {
|
||||
return request({
|
||||
url: '/wms/processPlan/' + planId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
46
klp-ui/src/api/wms/processSpecVersion.js
Normal file
46
klp-ui/src/api/wms/processSpecVersion.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listProcessSpecVersion(query) {
|
||||
return request({
|
||||
url: '/wms/processSpecVersion/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function getProcessSpecVersion(versionId) {
|
||||
return request({
|
||||
url: '/wms/processSpecVersion/' + versionId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function addProcessSpecVersion(data) {
|
||||
return request({
|
||||
url: '/wms/processSpecVersion',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateProcessSpecVersion(data) {
|
||||
return request({
|
||||
url: '/wms/processSpecVersion',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function activateProcessSpecVersion(versionId) {
|
||||
return request({
|
||||
url: '/wms/processSpecVersion/activate/' + versionId,
|
||||
method: 'put'
|
||||
})
|
||||
}
|
||||
|
||||
export function delProcessSpecVersion(versionId) {
|
||||
return request({
|
||||
url: '/wms/processSpecVersion/' + versionId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
@@ -74,8 +74,9 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="160" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="140">
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-document" @click="goVersionManage(scope.row)">版本与方案</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
@@ -300,6 +301,21 @@ export default {
|
||||
this.download('wms/processSpec/export', {
|
||||
...this.queryParams
|
||||
}, `processSpec_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
goVersionManage(row) {
|
||||
const specId = row.specId
|
||||
if (specId == null || specId === '') {
|
||||
this.$modal.msgWarning('无法获取规程ID,请刷新列表后重试')
|
||||
return
|
||||
}
|
||||
// 固定落在「…/processSpec/version」,避免列表为 …/processSpec/list 时拼成 …/list/version 导致路由不匹配、query 丢失
|
||||
const pathCurrent = this.$route.path.replace(/\/$/, '')
|
||||
const m = pathCurrent.match(/^(.*\/processSpec)(?:\/.*)?$/)
|
||||
const base = m ? m[1] : pathCurrent
|
||||
this.$router.push({
|
||||
path: `${base}/version`,
|
||||
query: { specId: String(specId) }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
374
klp-ui/src/views/wms/processSpec/versionManage.vue
Normal file
374
klp-ui/src/views/wms/processSpec/versionManage.vue
Normal file
@@ -0,0 +1,374 @@
|
||||
<template>
|
||||
<div class="app-container" v-loading="pageLoading">
|
||||
<el-page-header v-if="specInfo.specId" @back="goBack" :content="'规程版本与方案 — ' + (specInfo.specName || '') + '(' + (specInfo.specCode || '') + ')'" />
|
||||
<el-card v-else shadow="never" class="mb8">
|
||||
<div slot="header">请选择规程</div>
|
||||
<p class="text-muted mb8" style="color: #909399; font-size: 13px">从「规程管理」列表进入时会自动带上规程;从菜单直接进入时请先选择规程。</p>
|
||||
<el-form inline size="small" @submit.native.prevent>
|
||||
<el-form-item label="规程">
|
||||
<el-select
|
||||
v-model="specPickerId"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择规程"
|
||||
style="min-width: 280px"
|
||||
:loading="specPickerLoading"
|
||||
>
|
||||
<el-option v-for="s in specPickerOptions" :key="s.specId" :label="(s.specCode || '') + ' — ' + (s.specName || '')" :value="String(s.specId)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :disabled="!specPickerId" @click="applySpecPicker">进入维护</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<template v-if="specInfo.specId">
|
||||
<el-card shadow="never" class="mb8">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>规程版本</span>
|
||||
<el-button style="float: right; padding: 3px 10px" type="primary" size="mini" icon="el-icon-plus" @click="openVersionDialog()">新建版本</el-button>
|
||||
</div>
|
||||
<KLPTable
|
||||
:data="versionList"
|
||||
highlight-current-row
|
||||
@row-click="onVersionRowClick"
|
||||
>
|
||||
<el-table-column label="版本号" prop="versionCode" min-width="120" align="center" />
|
||||
<el-table-column label="是否生效" prop="isActive" width="100" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.isActive === 1" type="success" size="mini">生效</el-tag>
|
||||
<span v-else>否</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" prop="status" width="120" align="center" />
|
||||
<el-table-column label="创建时间" prop="createTime" width="170" align="center" />
|
||||
<el-table-column label="操作" width="220" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click.stop="activateVersion(scope.row)">设为生效</el-button>
|
||||
<el-button type="text" size="mini" @click.stop="openVersionDialog(scope.row)">编辑</el-button>
|
||||
<el-button type="text" size="mini" @click.stop="removeVersion(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</KLPTable>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" v-if="selectedVersion">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>方案点位(版本 {{ selectedVersion.versionCode }})</span>
|
||||
<el-button style="float: right; padding: 3px 10px" type="primary" size="mini" icon="el-icon-plus" @click="openPlanDialog()">新建方案点位</el-button>
|
||||
</div>
|
||||
<KLPTable v-loading="planLoading" :data="planList">
|
||||
<el-table-column label="段类型" prop="segmentType" width="110" align="center" />
|
||||
<el-table-column label="段名称" prop="segmentName" min-width="100" show-overflow-tooltip align="center" />
|
||||
<el-table-column label="点位名称" prop="pointName" min-width="120" show-overflow-tooltip align="center" />
|
||||
<el-table-column label="点位编码" prop="pointCode" min-width="120" align="center" />
|
||||
<el-table-column label="排序" prop="sortOrder" width="80" align="center" />
|
||||
<el-table-column label="操作" width="140" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click="openPlanDialog(scope.row)">编辑</el-button>
|
||||
<el-button type="text" size="mini" @click="removePlan(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</KLPTable>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" v-else class="mb8">
|
||||
<el-empty description="请在上方选择一个规程版本以维护方案点位" />
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<!-- 版本 -->
|
||||
<el-dialog :title="versionTitle" :visible.sync="versionOpen" width="520px" append-to-body @close="versionForm = {}">
|
||||
<el-form ref="versionFormRef" :model="versionForm" :rules="versionRules" label-width="100px">
|
||||
<el-form-item label="版本号" prop="versionCode">
|
||||
<el-input v-model="versionForm.versionCode" maxlength="64" placeholder="如 V1.0" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="versionForm.status" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="s in statusOptions" :key="s" :label="s" :value="s" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="保存后生效" prop="isActive">
|
||||
<el-switch v-model="versionForm.isActive" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="versionForm.remark" type="textarea" rows="2" maxlength="500" show-word-limit />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button :loading="versionSubmitLoading" type="primary" @click="submitVersion">确 定</el-button>
|
||||
<el-button @click="versionOpen = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 方案点位 -->
|
||||
<el-dialog :title="planTitle" :visible.sync="planOpen" width="560px" append-to-body @close="planForm = {}">
|
||||
<el-form ref="planFormRef" :model="planForm" :rules="planRules" label-width="100px">
|
||||
<el-form-item label="段类型" prop="segmentType">
|
||||
<el-select v-model="planForm.segmentType" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="s in segmentOptions" :key="s.value" :label="s.label" :value="s.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="段名称" prop="segmentName">
|
||||
<el-input v-model="planForm.segmentName" maxlength="100" />
|
||||
</el-form-item>
|
||||
<el-form-item label="点位名称" prop="pointName">
|
||||
<el-input v-model="planForm.pointName" maxlength="200" />
|
||||
</el-form-item>
|
||||
<el-form-item label="点位编码" prop="pointCode">
|
||||
<el-input v-model="planForm.pointCode" maxlength="64" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sortOrder">
|
||||
<el-input-number v-model="planForm.sortOrder" :min="0" :max="999999" controls-position="right" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="planForm.remark" type="textarea" rows="2" maxlength="500" show-word-limit />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button :loading="planSubmitLoading" type="primary" @click="submitPlan">确 定</el-button>
|
||||
<el-button @click="planOpen = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getProcessSpec, listProcessSpec } from '@/api/wms/processSpec'
|
||||
import {
|
||||
listProcessSpecVersion,
|
||||
addProcessSpecVersion,
|
||||
updateProcessSpecVersion,
|
||||
delProcessSpecVersion,
|
||||
activateProcessSpecVersion
|
||||
} from '@/api/wms/processSpecVersion'
|
||||
import { listProcessPlan, addProcessPlan, updateProcessPlan, delProcessPlan } from '@/api/wms/processPlan'
|
||||
|
||||
export default {
|
||||
name: 'ProcessSpecVersionManage',
|
||||
data() {
|
||||
return {
|
||||
pageLoading: false,
|
||||
specId: undefined,
|
||||
specInfo: {},
|
||||
versionList: [],
|
||||
selectedVersion: null,
|
||||
planList: [],
|
||||
planLoading: false,
|
||||
statusOptions: ['DRAFT', 'PUBLISHED', 'OBSOLETE'],
|
||||
segmentOptions: [
|
||||
{ label: '入口', value: 'INLET' },
|
||||
{ label: '过程', value: 'PROCESS' },
|
||||
{ label: '出口', value: 'OUTLET' }
|
||||
],
|
||||
versionOpen: false,
|
||||
versionTitle: '',
|
||||
versionSubmitLoading: false,
|
||||
versionForm: {},
|
||||
versionRules: {
|
||||
versionCode: [{ required: true, message: '版本号不能为空', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '状态不能为空', trigger: 'change' }]
|
||||
},
|
||||
planOpen: false,
|
||||
planTitle: '',
|
||||
planSubmitLoading: false,
|
||||
planForm: {},
|
||||
planRules: {
|
||||
segmentType: [{ required: true, message: '段类型不能为空', trigger: 'change' }],
|
||||
pointName: [{ required: true, message: '点位名称不能为空', trigger: 'blur' }],
|
||||
pointCode: [{ required: true, message: '点位编码不能为空', trigger: 'blur' }],
|
||||
sortOrder: [{ required: true, message: '排序不能为空', trigger: 'blur' }]
|
||||
},
|
||||
specPickerId: '',
|
||||
specPickerOptions: [],
|
||||
specPickerLoading: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route': {
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.syncSpecIdFromRoute()
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
syncSpecIdFromRoute() {
|
||||
const raw = this.$route.query.specId
|
||||
if (raw != null && raw !== '') {
|
||||
this.specId = String(raw)
|
||||
} else {
|
||||
this.specId = undefined
|
||||
}
|
||||
this.initPage()
|
||||
},
|
||||
loadSpecPickerOptions() {
|
||||
this.specPickerLoading = true
|
||||
listProcessSpec({ pageNum: 1, pageSize: 500 })
|
||||
.then((res) => {
|
||||
this.specPickerOptions = res.rows || []
|
||||
})
|
||||
.catch((e) => console.error('加载规程列表失败', e))
|
||||
.finally(() => {
|
||||
this.specPickerLoading = false
|
||||
})
|
||||
},
|
||||
applySpecPicker() {
|
||||
if (!this.specPickerId) {
|
||||
return
|
||||
}
|
||||
this.$router.replace({
|
||||
path: this.$route.path,
|
||||
query: { ...this.$route.query, specId: this.specPickerId }
|
||||
})
|
||||
},
|
||||
goBack() {
|
||||
this.$router.go(-1)
|
||||
},
|
||||
initPage() {
|
||||
if (!this.specId) {
|
||||
this.specInfo = {}
|
||||
if (this.specPickerOptions.length === 0) {
|
||||
this.loadSpecPickerOptions()
|
||||
}
|
||||
return
|
||||
}
|
||||
this.pageLoading = true
|
||||
getProcessSpec(this.specId)
|
||||
.then((res) => {
|
||||
this.specInfo = res.data || {}
|
||||
return listProcessSpecVersion({ specId: this.specId, pageNum: 1, pageSize: 200 })
|
||||
})
|
||||
.then((res) => {
|
||||
this.versionList = res.rows || []
|
||||
this.selectedVersion = null
|
||||
this.planList = []
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error('加载规程版本失败', e)
|
||||
})
|
||||
.finally(() => {
|
||||
this.pageLoading = false
|
||||
})
|
||||
},
|
||||
onVersionRowClick(row) {
|
||||
this.selectedVersion = row
|
||||
this.loadPlans(row.versionId)
|
||||
},
|
||||
loadPlans(versionId) {
|
||||
if (!versionId) {
|
||||
this.planList = []
|
||||
return
|
||||
}
|
||||
this.planLoading = true
|
||||
listProcessPlan({ versionId, pageNum: 1, pageSize: 500 })
|
||||
.then((res) => {
|
||||
this.planList = res.rows || []
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error('加载方案点位失败', e)
|
||||
})
|
||||
.finally(() => {
|
||||
this.planLoading = false
|
||||
})
|
||||
},
|
||||
openVersionDialog(row) {
|
||||
this.versionForm = row
|
||||
? { ...row }
|
||||
: {
|
||||
specId: this.specId,
|
||||
versionCode: undefined,
|
||||
status: 'DRAFT',
|
||||
isActive: 0,
|
||||
remark: undefined
|
||||
}
|
||||
this.versionTitle = row ? '编辑版本' : '新建版本'
|
||||
this.versionOpen = true
|
||||
this.$nextTick(() => this.$refs.versionFormRef && this.$refs.versionFormRef.clearValidate())
|
||||
},
|
||||
submitVersion() {
|
||||
this.$refs.versionFormRef.validate((ok) => {
|
||||
if (!ok) return
|
||||
this.versionSubmitLoading = true
|
||||
const req = this.versionForm.versionId
|
||||
? updateProcessSpecVersion({ ...this.versionForm, specId: this.specId })
|
||||
: addProcessSpecVersion({ ...this.versionForm, specId: this.specId })
|
||||
req
|
||||
.then(() => {
|
||||
this.$modal.msgSuccess('保存成功')
|
||||
this.versionOpen = false
|
||||
this.initPage()
|
||||
})
|
||||
.catch((e) => console.error('保存版本失败', e))
|
||||
.finally(() => {
|
||||
this.versionSubmitLoading = false
|
||||
})
|
||||
})
|
||||
},
|
||||
activateVersion(row) {
|
||||
this.$modal.confirm('确认将版本「' + row.versionCode + '」设为当前生效版本?').then(() => {
|
||||
return activateProcessSpecVersion(row.versionId)
|
||||
}).then(() => {
|
||||
this.$modal.msgSuccess('已生效')
|
||||
this.initPage()
|
||||
}).catch(() => {})
|
||||
},
|
||||
removeVersion(row) {
|
||||
this.$modal.confirm('确认删除版本「' + row.versionCode + '」及其下方案点位?').then(() => {
|
||||
return delProcessSpecVersion(row.versionId)
|
||||
}).then(() => {
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
this.selectedVersion = null
|
||||
this.planList = []
|
||||
this.initPage()
|
||||
}).catch(() => {})
|
||||
},
|
||||
openPlanDialog(row) {
|
||||
if (!this.selectedVersion) {
|
||||
this.$modal.msgWarning('请先选择一个规程版本')
|
||||
return
|
||||
}
|
||||
this.planForm = row
|
||||
? { ...row }
|
||||
: {
|
||||
versionId: this.selectedVersion.versionId,
|
||||
segmentType: 'PROCESS',
|
||||
segmentName: undefined,
|
||||
pointName: undefined,
|
||||
pointCode: undefined,
|
||||
sortOrder: 0,
|
||||
remark: undefined
|
||||
}
|
||||
this.planTitle = row ? '编辑方案点位' : '新建方案点位'
|
||||
this.planOpen = true
|
||||
this.$nextTick(() => this.$refs.planFormRef && this.$refs.planFormRef.clearValidate())
|
||||
},
|
||||
submitPlan() {
|
||||
this.$refs.planFormRef.validate((ok) => {
|
||||
if (!ok) return
|
||||
this.planSubmitLoading = true
|
||||
const req = this.planForm.planId ? updateProcessPlan(this.planForm) : addProcessPlan(this.planForm)
|
||||
req
|
||||
.then(() => {
|
||||
this.$modal.msgSuccess('保存成功')
|
||||
this.planOpen = false
|
||||
this.loadPlans(this.selectedVersion.versionId)
|
||||
})
|
||||
.catch((e) => console.error('保存方案点位失败', e))
|
||||
.finally(() => {
|
||||
this.planSubmitLoading = false
|
||||
})
|
||||
})
|
||||
},
|
||||
removePlan(row) {
|
||||
this.$modal.confirm('确认删除该方案点位?').then(() => {
|
||||
return delProcessPlan(row.planId)
|
||||
}).then(() => {
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
this.loadPlans(this.selectedVersion.versionId)
|
||||
}).catch(() => {})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.klp.controller;
|
||||
|
||||
import com.klp.common.annotation.Log;
|
||||
import com.klp.common.annotation.RepeatSubmit;
|
||||
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.core.validate.AddGroup;
|
||||
import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.domain.bo.WmsProcessPlanBo;
|
||||
import com.klp.domain.vo.WmsProcessPlanVo;
|
||||
import com.klp.service.IWmsProcessPlanService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 方案点位
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/wms/processPlan")
|
||||
public class WmsProcessPlanController extends BaseController {
|
||||
|
||||
private final IWmsProcessPlanService wmsProcessPlanService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WmsProcessPlanVo> list(WmsProcessPlanBo bo, PageQuery pageQuery) {
|
||||
return wmsProcessPlanService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@Log(title = "方案点位", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(WmsProcessPlanBo bo, HttpServletResponse response) {
|
||||
List<WmsProcessPlanVo> list = wmsProcessPlanService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "方案点位", WmsProcessPlanVo.class, response);
|
||||
}
|
||||
|
||||
@GetMapping("/{planId}")
|
||||
public R<WmsProcessPlanVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long planId) {
|
||||
return R.ok(wmsProcessPlanService.queryById(planId));
|
||||
}
|
||||
|
||||
@Log(title = "方案点位", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsProcessPlanBo bo) {
|
||||
return toAjax(wmsProcessPlanService.insertByBo(bo));
|
||||
}
|
||||
|
||||
@Log(title = "方案点位", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsProcessPlanBo bo) {
|
||||
return toAjax(wmsProcessPlanService.updateByBo(bo));
|
||||
}
|
||||
|
||||
@Log(title = "方案点位", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{planIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] planIds) {
|
||||
return toAjax(wmsProcessPlanService.deleteWithValidByIds(Arrays.asList(planIds), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.klp.controller;
|
||||
|
||||
import com.klp.common.annotation.Log;
|
||||
import com.klp.common.annotation.RepeatSubmit;
|
||||
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.core.validate.AddGroup;
|
||||
import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.domain.bo.WmsProcessSpecVersionBo;
|
||||
import com.klp.domain.vo.WmsProcessSpecVersionVo;
|
||||
import com.klp.service.IWmsProcessSpecVersionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规程版本
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/wms/processSpecVersion")
|
||||
public class WmsProcessSpecVersionController extends BaseController {
|
||||
|
||||
private final IWmsProcessSpecVersionService wmsProcessSpecVersionService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WmsProcessSpecVersionVo> list(WmsProcessSpecVersionBo bo, PageQuery pageQuery) {
|
||||
return wmsProcessSpecVersionService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@Log(title = "规程版本", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(WmsProcessSpecVersionBo bo, HttpServletResponse response) {
|
||||
List<WmsProcessSpecVersionVo> list = wmsProcessSpecVersionService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "规程版本", WmsProcessSpecVersionVo.class, response);
|
||||
}
|
||||
|
||||
@GetMapping("/{versionId}")
|
||||
public R<WmsProcessSpecVersionVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long versionId) {
|
||||
return R.ok(wmsProcessSpecVersionService.queryById(versionId));
|
||||
}
|
||||
|
||||
@Log(title = "规程版本", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsProcessSpecVersionBo bo) {
|
||||
return toAjax(wmsProcessSpecVersionService.insertByBo(bo));
|
||||
}
|
||||
|
||||
@Log(title = "规程版本", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsProcessSpecVersionBo bo) {
|
||||
return toAjax(wmsProcessSpecVersionService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设为当前生效版本(同规程下仅一条生效)
|
||||
*/
|
||||
@Log(title = "规程版本生效", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/activate/{versionId}")
|
||||
public R<Void> activate(@NotNull(message = "主键不能为空") @PathVariable Long versionId) {
|
||||
return toAjax(wmsProcessSpecVersionService.activateVersion(versionId));
|
||||
}
|
||||
|
||||
@Log(title = "规程版本", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{versionIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] versionIds) {
|
||||
return toAjax(wmsProcessSpecVersionService.deleteWithValidByIds(Arrays.asList(versionIds), true));
|
||||
}
|
||||
}
|
||||
59
klp-wms/src/main/java/com/klp/domain/WmsProcessPlan.java
Normal file
59
klp-wms/src/main/java/com/klp/domain/WmsProcessPlan.java
Normal file
@@ -0,0 +1,59 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 方案点位对象 wms_process_plan
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("wms_process_plan")
|
||||
public class WmsProcessPlan extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "plan_id")
|
||||
private Long planId;
|
||||
|
||||
/**
|
||||
* 规程版本ID
|
||||
*/
|
||||
private Long versionId;
|
||||
|
||||
/**
|
||||
* 段类型(INLET/PROCESS/OUTLET)
|
||||
*/
|
||||
private String segmentType;
|
||||
|
||||
/**
|
||||
* 段名称
|
||||
*/
|
||||
private String segmentName;
|
||||
|
||||
/**
|
||||
* 点位名称
|
||||
*/
|
||||
private String pointName;
|
||||
|
||||
/**
|
||||
* 点位编码
|
||||
*/
|
||||
private String pointCode;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sortOrder;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 规程版本对象 wms_process_spec_version
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("wms_process_spec_version")
|
||||
public class WmsProcessSpecVersion extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "version_id")
|
||||
private Long versionId;
|
||||
|
||||
/**
|
||||
* 规程主表ID
|
||||
*/
|
||||
private Long specId;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String versionCode;
|
||||
|
||||
/**
|
||||
* 是否当前生效(0=否,1=是)
|
||||
*/
|
||||
private Integer isActive;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.klp.domain.bo;
|
||||
|
||||
import com.klp.common.core.domain.BaseEntity;
|
||||
import com.klp.common.core.validate.AddGroup;
|
||||
import com.klp.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 方案点位业务对象 wms_process_plan
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WmsProcessPlanBo extends BaseEntity {
|
||||
|
||||
@NotNull(message = "主键不能为空", groups = {EditGroup.class})
|
||||
private Long planId;
|
||||
|
||||
@NotNull(message = "版本不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long versionId;
|
||||
|
||||
@NotBlank(message = "段类型不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String segmentType;
|
||||
|
||||
private String segmentName;
|
||||
|
||||
@NotBlank(message = "点位名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String pointName;
|
||||
|
||||
@NotBlank(message = "点位编码不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String pointCode;
|
||||
|
||||
@NotNull(message = "排序不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Integer sortOrder;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.klp.domain.bo;
|
||||
|
||||
import com.klp.common.core.domain.BaseEntity;
|
||||
import com.klp.common.core.validate.AddGroup;
|
||||
import com.klp.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 规程版本业务对象 wms_process_spec_version
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WmsProcessSpecVersionBo extends BaseEntity {
|
||||
|
||||
@NotNull(message = "主键不能为空", groups = {EditGroup.class})
|
||||
private Long versionId;
|
||||
|
||||
@NotNull(message = "规程不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long specId;
|
||||
|
||||
@NotBlank(message = "版本号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String versionCode;
|
||||
|
||||
/**
|
||||
* 是否当前生效(0=否,1=是)
|
||||
*/
|
||||
private Integer isActive;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.klp.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 方案点位视图对象 wms_process_plan
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class WmsProcessPlanVo {
|
||||
|
||||
@ExcelProperty(value = "方案点位ID")
|
||||
private Long planId;
|
||||
|
||||
@ExcelProperty(value = "版本ID")
|
||||
private Long versionId;
|
||||
|
||||
@ExcelProperty(value = "段类型")
|
||||
private String segmentType;
|
||||
|
||||
@ExcelProperty(value = "段名称")
|
||||
private String segmentName;
|
||||
|
||||
@ExcelProperty(value = "点位名称")
|
||||
private String pointName;
|
||||
|
||||
@ExcelProperty(value = "点位编码")
|
||||
private String pointCode;
|
||||
|
||||
@ExcelProperty(value = "排序")
|
||||
private Integer sortOrder;
|
||||
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@ExcelProperty(value = "更新时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.klp.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 规程版本视图对象 wms_process_spec_version
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class WmsProcessSpecVersionVo {
|
||||
|
||||
@ExcelProperty(value = "版本ID")
|
||||
private Long versionId;
|
||||
|
||||
@ExcelProperty(value = "规程ID")
|
||||
private Long specId;
|
||||
|
||||
@ExcelProperty(value = "版本号")
|
||||
private String versionCode;
|
||||
|
||||
@ExcelProperty(value = "是否生效")
|
||||
private Integer isActive;
|
||||
|
||||
@ExcelProperty(value = "状态")
|
||||
private String status;
|
||||
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@ExcelProperty(value = "更新时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.klp.mapper;
|
||||
|
||||
import com.klp.common.core.mapper.BaseMapperPlus;
|
||||
import com.klp.domain.WmsProcessPlan;
|
||||
import com.klp.domain.vo.WmsProcessPlanVo;
|
||||
|
||||
/**
|
||||
* 方案点位Mapper
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
public interface WmsProcessPlanMapper extends BaseMapperPlus<WmsProcessPlanMapper, WmsProcessPlan, WmsProcessPlanVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.klp.mapper;
|
||||
|
||||
import com.klp.common.core.mapper.BaseMapperPlus;
|
||||
import com.klp.domain.WmsProcessSpecVersion;
|
||||
import com.klp.domain.vo.WmsProcessSpecVersionVo;
|
||||
|
||||
/**
|
||||
* 规程版本Mapper
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
public interface WmsProcessSpecVersionMapper extends BaseMapperPlus<WmsProcessSpecVersionMapper, WmsProcessSpecVersion, WmsProcessSpecVersionVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.klp.service;
|
||||
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.domain.bo.WmsProcessPlanBo;
|
||||
import com.klp.domain.vo.WmsProcessPlanVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 方案点位Service
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
public interface IWmsProcessPlanService {
|
||||
|
||||
WmsProcessPlanVo queryById(Long planId);
|
||||
|
||||
TableDataInfo<WmsProcessPlanVo> queryPageList(WmsProcessPlanBo bo, PageQuery pageQuery);
|
||||
|
||||
List<WmsProcessPlanVo> queryList(WmsProcessPlanBo bo);
|
||||
|
||||
Boolean insertByBo(WmsProcessPlanBo bo);
|
||||
|
||||
Boolean updateByBo(WmsProcessPlanBo bo);
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.klp.service;
|
||||
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.domain.bo.WmsProcessSpecVersionBo;
|
||||
import com.klp.domain.vo.WmsProcessSpecVersionVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规程版本Service
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
public interface IWmsProcessSpecVersionService {
|
||||
|
||||
WmsProcessSpecVersionVo queryById(Long versionId);
|
||||
|
||||
TableDataInfo<WmsProcessSpecVersionVo> queryPageList(WmsProcessSpecVersionBo bo, PageQuery pageQuery);
|
||||
|
||||
List<WmsProcessSpecVersionVo> queryList(WmsProcessSpecVersionBo bo);
|
||||
|
||||
Boolean insertByBo(WmsProcessSpecVersionBo bo);
|
||||
|
||||
Boolean updateByBo(WmsProcessSpecVersionBo bo);
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 将指定版本设为当前规程下唯一生效版本
|
||||
*/
|
||||
Boolean activateVersion(Long versionId);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.klp.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.page.TableDataInfo;
|
||||
import com.klp.common.exception.ServiceException;
|
||||
import com.klp.common.utils.StringUtils;
|
||||
import com.klp.domain.WmsProcessPlan;
|
||||
import com.klp.domain.WmsProcessSpecVersion;
|
||||
import com.klp.domain.bo.WmsProcessPlanBo;
|
||||
import com.klp.domain.vo.WmsProcessPlanVo;
|
||||
import com.klp.mapper.WmsProcessPlanMapper;
|
||||
import com.klp.mapper.WmsProcessSpecVersionMapper;
|
||||
import com.klp.service.IWmsProcessPlanService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 方案点位Service实现
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class WmsProcessPlanServiceImpl implements IWmsProcessPlanService {
|
||||
|
||||
private final WmsProcessPlanMapper baseMapper;
|
||||
private final WmsProcessSpecVersionMapper wmsProcessSpecVersionMapper;
|
||||
|
||||
@Override
|
||||
public WmsProcessPlanVo queryById(Long planId) {
|
||||
return baseMapper.selectVoById(planId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WmsProcessPlanVo> queryPageList(WmsProcessPlanBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<WmsProcessPlan> lqw = buildQueryWrapper(bo);
|
||||
Page<WmsProcessPlanVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WmsProcessPlanVo> queryList(WmsProcessPlanBo bo) {
|
||||
return baseMapper.selectVoList(buildQueryWrapper(bo));
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WmsProcessPlan> buildQueryWrapper(WmsProcessPlanBo bo) {
|
||||
LambdaQueryWrapper<WmsProcessPlan> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getVersionId() != null, WmsProcessPlan::getVersionId, bo.getVersionId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSegmentType()), WmsProcessPlan::getSegmentType, bo.getSegmentType());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getPointName()), WmsProcessPlan::getPointName, bo.getPointName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getPointCode()), WmsProcessPlan::getPointCode, bo.getPointCode());
|
||||
lqw.orderByAsc(WmsProcessPlan::getSortOrder).orderByAsc(WmsProcessPlan::getPlanId);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(WmsProcessPlanBo bo) {
|
||||
WmsProcessSpecVersion ver = wmsProcessSpecVersionMapper.selectById(bo.getVersionId());
|
||||
if (ver == null) {
|
||||
throw new ServiceException("规程版本不存在");
|
||||
}
|
||||
WmsProcessPlan add = BeanUtil.toBean(bo, WmsProcessPlan.class);
|
||||
if (add.getSortOrder() == null) {
|
||||
add.setSortOrder(0);
|
||||
}
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setPlanId(add.getPlanId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(WmsProcessPlanBo bo) {
|
||||
WmsProcessPlan update = BeanUtil.toBean(bo, WmsProcessPlan.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
private void validEntityBeforeSave(WmsProcessPlan entity) {
|
||||
LambdaQueryWrapper<WmsProcessPlan> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(WmsProcessPlan::getVersionId, entity.getVersionId());
|
||||
lqw.eq(WmsProcessPlan::getPointCode, entity.getPointCode());
|
||||
if (entity.getPlanId() != null) {
|
||||
lqw.ne(WmsProcessPlan::getPlanId, entity.getPlanId());
|
||||
}
|
||||
if (baseMapper.selectCount(lqw) > 0) {
|
||||
throw new ServiceException("同一版本下点位编码已存在");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (Boolean.TRUE.equals(isValid)) {
|
||||
// 可扩展业务校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,11 @@ import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.exception.ServiceException;
|
||||
import com.klp.common.utils.StringUtils;
|
||||
import com.klp.domain.WmsProcessSpec;
|
||||
import com.klp.domain.WmsProcessSpecVersion;
|
||||
import com.klp.domain.bo.WmsProcessSpecBo;
|
||||
import com.klp.domain.vo.WmsProcessSpecVo;
|
||||
import com.klp.mapper.WmsProcessSpecMapper;
|
||||
import com.klp.mapper.WmsProcessSpecVersionMapper;
|
||||
import com.klp.service.IWmsProcessSpecService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -29,6 +31,7 @@ import java.util.List;
|
||||
public class WmsProcessSpecServiceImpl implements IWmsProcessSpecService {
|
||||
|
||||
private final WmsProcessSpecMapper baseMapper;
|
||||
private final WmsProcessSpecVersionMapper wmsProcessSpecVersionMapper;
|
||||
|
||||
@Override
|
||||
public WmsProcessSpecVo queryById(Long specId) {
|
||||
@@ -94,7 +97,13 @@ public class WmsProcessSpecServiceImpl implements IWmsProcessSpecService {
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (Boolean.TRUE.equals(isValid)) {
|
||||
// 任务3 可在此校验版本等从表数据
|
||||
for (Long specId : ids) {
|
||||
LambdaQueryWrapper<WmsProcessSpecVersion> vq = Wrappers.lambdaQuery();
|
||||
vq.eq(WmsProcessSpecVersion::getSpecId, specId);
|
||||
if (wmsProcessSpecVersionMapper.selectCount(vq) > 0) {
|
||||
throw new ServiceException("规程下存在版本数据,请先删除版本及方案");
|
||||
}
|
||||
}
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.klp.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
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.page.TableDataInfo;
|
||||
import com.klp.common.exception.ServiceException;
|
||||
import com.klp.common.utils.StringUtils;
|
||||
import com.klp.domain.WmsProcessSpec;
|
||||
import com.klp.domain.WmsProcessPlan;
|
||||
import com.klp.domain.WmsProcessSpecVersion;
|
||||
import com.klp.domain.bo.WmsProcessSpecVersionBo;
|
||||
import com.klp.domain.vo.WmsProcessSpecVersionVo;
|
||||
import com.klp.mapper.WmsProcessPlanMapper;
|
||||
import com.klp.mapper.WmsProcessSpecMapper;
|
||||
import com.klp.mapper.WmsProcessSpecVersionMapper;
|
||||
import com.klp.service.IWmsProcessSpecVersionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规程版本Service实现
|
||||
*
|
||||
* @author klp
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class WmsProcessSpecVersionServiceImpl implements IWmsProcessSpecVersionService {
|
||||
|
||||
private final WmsProcessSpecVersionMapper baseMapper;
|
||||
private final WmsProcessSpecMapper wmsProcessSpecMapper;
|
||||
private final WmsProcessPlanMapper wmsProcessPlanMapper;
|
||||
|
||||
@Override
|
||||
public WmsProcessSpecVersionVo queryById(Long versionId) {
|
||||
return baseMapper.selectVoById(versionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WmsProcessSpecVersionVo> queryPageList(WmsProcessSpecVersionBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<WmsProcessSpecVersion> lqw = buildQueryWrapper(bo);
|
||||
Page<WmsProcessSpecVersionVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WmsProcessSpecVersionVo> queryList(WmsProcessSpecVersionBo bo) {
|
||||
return baseMapper.selectVoList(buildQueryWrapper(bo));
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WmsProcessSpecVersion> buildQueryWrapper(WmsProcessSpecVersionBo bo) {
|
||||
LambdaQueryWrapper<WmsProcessSpecVersion> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getSpecId() != null, WmsProcessSpecVersion::getSpecId, bo.getSpecId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getVersionCode()), WmsProcessSpecVersion::getVersionCode, bo.getVersionCode());
|
||||
lqw.eq(bo.getIsActive() != null, WmsProcessSpecVersion::getIsActive, bo.getIsActive());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), WmsProcessSpecVersion::getStatus, bo.getStatus());
|
||||
lqw.orderByDesc(WmsProcessSpecVersion::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(WmsProcessSpecVersionBo bo) {
|
||||
WmsProcessSpec spec = wmsProcessSpecMapper.selectById(bo.getSpecId());
|
||||
if (spec == null) {
|
||||
throw new ServiceException("规程不存在");
|
||||
}
|
||||
WmsProcessSpecVersion add = BeanUtil.toBean(bo, WmsProcessSpecVersion.class);
|
||||
if (add.getIsActive() == null) {
|
||||
add.setIsActive(0);
|
||||
}
|
||||
if (StringUtils.isBlank(add.getStatus())) {
|
||||
add.setStatus("DRAFT");
|
||||
}
|
||||
validEntityBeforeSave(add);
|
||||
boolean ok = baseMapper.insert(add) > 0;
|
||||
if (ok) {
|
||||
bo.setVersionId(add.getVersionId());
|
||||
if (Integer.valueOf(1).equals(add.getIsActive())) {
|
||||
activateVersion(add.getVersionId());
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(WmsProcessSpecVersionBo bo) {
|
||||
WmsProcessSpecVersion exist = baseMapper.selectById(bo.getVersionId());
|
||||
if (exist == null) {
|
||||
throw new ServiceException("版本不存在");
|
||||
}
|
||||
WmsProcessSpecVersion update = BeanUtil.toBean(bo, WmsProcessSpecVersion.class);
|
||||
validEntityBeforeSave(update);
|
||||
boolean ok = baseMapper.updateById(update) > 0;
|
||||
if (ok && Integer.valueOf(1).equals(update.getIsActive())) {
|
||||
activateVersion(update.getVersionId());
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
private void validEntityBeforeSave(WmsProcessSpecVersion entity) {
|
||||
LambdaQueryWrapper<WmsProcessSpecVersion> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(WmsProcessSpecVersion::getSpecId, entity.getSpecId());
|
||||
lqw.eq(WmsProcessSpecVersion::getVersionCode, entity.getVersionCode());
|
||||
if (entity.getVersionId() != null) {
|
||||
lqw.ne(WmsProcessSpecVersion::getVersionId, entity.getVersionId());
|
||||
}
|
||||
if (baseMapper.selectCount(lqw) > 0) {
|
||||
throw new ServiceException("同一规程下版本号已存在");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean activateVersion(Long versionId) {
|
||||
WmsProcessSpecVersion v = baseMapper.selectById(versionId);
|
||||
if (v == null) {
|
||||
throw new ServiceException("版本不存在");
|
||||
}
|
||||
LambdaUpdateWrapper<WmsProcessSpecVersion> clear = Wrappers.lambdaUpdate();
|
||||
clear.eq(WmsProcessSpecVersion::getSpecId, v.getSpecId());
|
||||
clear.set(WmsProcessSpecVersion::getIsActive, 0);
|
||||
baseMapper.update(null, clear);
|
||||
|
||||
WmsProcessSpecVersion one = new WmsProcessSpecVersion();
|
||||
one.setVersionId(versionId);
|
||||
one.setIsActive(1);
|
||||
return baseMapper.updateById(one) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
for (Long versionId : ids) {
|
||||
LambdaQueryWrapper<WmsProcessPlan> pq = Wrappers.lambdaQuery();
|
||||
pq.eq(WmsProcessPlan::getVersionId, versionId);
|
||||
wmsProcessPlanMapper.delete(pq);
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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.WmsProcessPlanMapper">
|
||||
|
||||
<resultMap type="com.klp.domain.WmsProcessPlan" id="WmsProcessPlanResult">
|
||||
<result property="planId" column="plan_id"/>
|
||||
<result property="versionId" column="version_id"/>
|
||||
<result property="segmentType" column="segment_type"/>
|
||||
<result property="segmentName" column="segment_name"/>
|
||||
<result property="pointName" column="point_name"/>
|
||||
<result property="pointCode" column="point_code"/>
|
||||
<result property="sortOrder" column="sort_order"/>
|
||||
<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"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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.WmsProcessSpecVersionMapper">
|
||||
|
||||
<resultMap type="com.klp.domain.WmsProcessSpecVersion" id="WmsProcessSpecVersionResult">
|
||||
<result property="versionId" column="version_id"/>
|
||||
<result property="specId" column="spec_id"/>
|
||||
<result property="versionCode" column="version_code"/>
|
||||
<result property="isActive" column="is_active"/>
|
||||
<result property="status" column="status"/>
|
||||
<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"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user