feat(wms): 规程主表 wms_process_spec 全栈 CRUD(任务2)

新增规程档案后端(Entity/BO/VO/Mapper/Service/Controller),接口前缀 /wms/processSpec,
含分页查询、导出、详情、增删改;保存时校验规程编号唯一;逻辑删除与全局配置一致(0 未删 / 2 已删)。

新增 Flyway 脚本 V10 建表及唯一索引;前端增加 api/wms/processSpec.js 与 views/wms/processSpec/index.vue,
支持按编号/名称/类型/产线/产品类型/启用状态筛选,产线下拉关联现有产线接口。

说明:需在目标库执行迁移并在菜单中配置组件路径 wms/processSpec/index。
This commit is contained in:
王文昊
2026-04-20 18:20:29 +08:00
parent ee199388d5
commit 62b594026b
11 changed files with 869 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
-- 冷轧涂镀数智运营 - 规程主表
CREATE TABLE wms_process_spec (
spec_id BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键',
spec_code VARCHAR(64) NOT NULL COMMENT '规程编号',
spec_name VARCHAR(200) NOT NULL COMMENT '规程名称',
spec_type VARCHAR(32) NOT NULL DEFAULT 'PROCESS' COMMENT '类型(PROCESS=工艺规程,STANDARD=标准)',
line_id BIGINT NOT NULL COMMENT '产线ID',
product_type VARCHAR(100) NULL COMMENT '产品类型',
is_enabled TINYINT NOT NULL DEFAULT 1 COMMENT '是否启用(0否1是)',
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 (spec_id),
UNIQUE KEY uk_wms_process_spec_code (spec_code),
KEY idx_wms_process_spec_line (line_id),
KEY idx_wms_process_spec_type (spec_type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='规程主表';

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询规程主表列表
export function listProcessSpec(query) {
return request({
url: '/wms/processSpec/list',
method: 'get',
params: query
})
}
// 查询规程主表详细
export function getProcessSpec(specId) {
return request({
url: '/wms/processSpec/' + specId,
method: 'get'
})
}
// 新增规程主表
export function addProcessSpec(data) {
return request({
url: '/wms/processSpec',
method: 'post',
data: data
})
}
// 修改规程主表
export function updateProcessSpec(data) {
return request({
url: '/wms/processSpec',
method: 'put',
data: data
})
}
// 删除规程主表
export function delProcessSpec(specId) {
return request({
url: '/wms/processSpec/' + specId,
method: 'delete'
})
}

View File

@@ -0,0 +1,306 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
<el-form-item label="规程编号" prop="specCode">
<el-input v-model="queryParams.specCode" placeholder="规程编号" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="规程名称" prop="specName">
<el-input v-model="queryParams.specName" placeholder="规程名称" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="规程类型" prop="specType">
<el-select v-model="queryParams.specType" placeholder="全部" clearable>
<el-option v-for="item in specTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="产线" prop="lineId">
<el-select v-model="queryParams.lineId" placeholder="全部" clearable filterable>
<el-option
v-for="line in lineOptions"
:key="line.lineId"
:label="formatLineOption(line)"
:value="line.lineId"
/>
</el-select>
</el-form-item>
<el-form-item label="产品类型" prop="productType">
<el-input v-model="queryParams.productType" placeholder="产品类型" clearable />
</el-form-item>
<el-form-item label="是否启用" prop="isEnabled">
<el-select v-model="queryParams.isEnabled" placeholder="全部" clearable>
<el-option label="启用" :value="1" />
<el-option label="禁用" :value="0" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<KLPTable v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="规程编号" align="center" prop="specCode" min-width="120" show-overflow-tooltip />
<el-table-column label="规程名称" align="center" prop="specName" min-width="140" show-overflow-tooltip />
<el-table-column label="规程类型" align="center" prop="specType" width="100">
<template slot-scope="scope">
<span>{{ formatSpecType(scope.row.specType) }}</span>
</template>
</el-table-column>
<el-table-column label="产线" align="center" min-width="160" show-overflow-tooltip>
<template slot-scope="scope">
{{ getLineName(scope.row.lineId) }}
</template>
</el-table-column>
<el-table-column label="产品类型" align="center" prop="productType" min-width="100" show-overflow-tooltip />
<el-table-column label="是否启用" align="center" prop="isEnabled" width="90">
<template slot-scope="scope">
<dict-tag :options="dict.type.common_swicth" :value="scope.row.isEnabled" />
</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">
<template slot-scope="scope">
<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>
</el-table-column>
</KLPTable>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<el-dialog :title="title" :visible.sync="open" width="560px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="规程编号" prop="specCode">
<el-input v-model="form.specCode" placeholder="唯一编号" maxlength="64" show-word-limit />
</el-form-item>
<el-form-item label="规程名称" prop="specName">
<el-input v-model="form.specName" placeholder="规程名称" maxlength="200" show-word-limit />
</el-form-item>
<el-form-item label="规程类型" prop="specType">
<el-select v-model="form.specType" placeholder="请选择">
<el-option v-for="item in specTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="产线" prop="lineId">
<el-select v-model="form.lineId" placeholder="请选择产线" filterable style="width: 100%">
<el-option
v-for="line in lineOptions"
:key="line.lineId"
:label="formatLineOption(line)"
:value="line.lineId"
/>
</el-select>
</el-form-item>
<el-form-item label="产品类型" prop="productType">
<el-input v-model="form.productType" placeholder="可选" maxlength="100" />
</el-form-item>
<el-form-item label="是否启用" prop="isEnabled">
<el-radio-group v-model="form.isEnabled">
<el-radio :label="1">启用</el-radio>
<el-radio :label="0">禁用</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="备注" maxlength="500" show-word-limit rows="2" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listProcessSpec, getProcessSpec, delProcessSpec, updateProcessSpec, addProcessSpec } from '@/api/wms/processSpec'
import { listProductionLine } from '@/api/wms/productionLine'
export default {
name: 'ProcessSpec',
dicts: ['common_swicth'],
data() {
return {
buttonLoading: false,
loading: true,
ids: [],
single: true,
multiple: true,
showSearch: true,
total: 0,
dataList: [],
title: '',
open: false,
lineOptions: [],
specTypeOptions: [
{ label: '工艺规程', value: 'PROCESS' },
{ label: '标准', value: 'STANDARD' }
],
queryParams: {
pageNum: 1,
pageSize: 20,
specCode: undefined,
specName: undefined,
specType: undefined,
lineId: undefined,
productType: undefined,
isEnabled: undefined
},
form: {},
rules: {
specCode: [{ required: true, message: '规程编号不能为空', trigger: 'blur' }],
specName: [{ required: true, message: '规程名称不能为空', trigger: 'blur' }],
specType: [{ required: true, message: '规程类型不能为空', trigger: 'change' }],
lineId: [{ required: true, message: '产线不能为空', trigger: 'change' }]
}
}
},
created() {
this.loadLineOptions()
this.getList()
},
methods: {
formatSpecType(value) {
const hit = this.specTypeOptions.find((x) => x.value === value)
return hit ? hit.label : value
},
formatLineOption(line) {
if (!line) {
return ''
}
return line.lineCode ? `${line.lineName}${line.lineCode}` : line.lineName
},
getLineName(lineId) {
if (lineId == null) {
return ''
}
const hit = this.lineOptions.find((o) => o.lineId === lineId)
return hit ? this.formatLineOption(hit) : lineId
},
loadLineOptions() {
listProductionLine({ pageNum: 1, pageSize: 500 }).then((res) => {
this.lineOptions = res.rows || []
}).catch((err) => {
console.error('加载产线列表失败', err)
})
},
getList() {
this.loading = true
listProcessSpec(this.queryParams).then((response) => {
this.dataList = response.rows
this.total = response.total
this.loading = false
}).catch((err) => {
console.error('加载规程列表失败', err)
this.loading = false
})
},
cancel() {
this.open = false
this.reset()
},
reset() {
this.form = {
specId: undefined,
specCode: undefined,
specName: undefined,
specType: 'PROCESS',
lineId: undefined,
productType: undefined,
isEnabled: 1,
remark: undefined
}
this.resetForm('form')
},
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
resetQuery() {
this.resetForm('queryForm')
this.handleQuery()
},
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.specId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
handleAdd() {
this.reset()
this.open = true
this.title = '添加规程'
},
handleUpdate(row) {
this.loading = true
this.reset()
const specId = row.specId || this.ids
getProcessSpec(specId).then((response) => {
this.loading = false
this.form = response.data
this.open = true
this.title = '修改规程'
}).catch((err) => {
console.error('获取规程详情失败', err)
this.loading = false
})
},
submitForm() {
this.$refs.form.validate((valid) => {
if (!valid) {
return
}
this.buttonLoading = true
const req = this.form.specId != null ? updateProcessSpec(this.form) : addProcessSpec(this.form)
req.then(() => {
this.$modal.msgSuccess(this.form.specId != null ? '修改成功' : '新增成功')
this.open = false
this.getList()
}).catch((err) => {
console.error('保存规程失败', err)
}).finally(() => {
this.buttonLoading = false
})
})
},
handleDelete(row) {
const specIds = row.specId || this.ids
this.$modal.confirm('是否确认删除选中的规程数据?').then(() => {
this.loading = true
return delProcessSpec(specIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess('删除成功')
}).catch(() => {}).finally(() => {
this.loading = false
})
},
handleExport() {
this.download('wms/processSpec/export', {
...this.queryParams
}, `processSpec_${new Date().getTime()}.xlsx`)
}
}
}
</script>

View File

@@ -0,0 +1,99 @@
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.WmsProcessSpecBo;
import com.klp.domain.vo.WmsProcessSpecVo;
import com.klp.service.IWmsProcessSpecService;
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/processSpec")
public class WmsProcessSpecController extends BaseController {
private final IWmsProcessSpecService wmsProcessSpecService;
/**
* 查询规程主表列表
*/
@GetMapping("/list")
public TableDataInfo<WmsProcessSpecVo> list(WmsProcessSpecBo bo, PageQuery pageQuery) {
return wmsProcessSpecService.queryPageList(bo, pageQuery);
}
/**
* 导出规程主表列表
*/
@Log(title = "规程主表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(WmsProcessSpecBo bo, HttpServletResponse response) {
List<WmsProcessSpecVo> list = wmsProcessSpecService.queryList(bo);
ExcelUtil.exportExcel(list, "规程主表", WmsProcessSpecVo.class, response);
}
/**
* 获取规程主表详细信息
*
* @param specId 主键
*/
@GetMapping("/{specId}")
public R<WmsProcessSpecVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long specId) {
return R.ok(wmsProcessSpecService.queryById(specId));
}
/**
* 新增规程主表
*/
@Log(title = "规程主表", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsProcessSpecBo bo) {
return toAjax(wmsProcessSpecService.insertByBo(bo));
}
/**
* 修改规程主表
*/
@Log(title = "规程主表", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsProcessSpecBo bo) {
return toAjax(wmsProcessSpecService.updateByBo(bo));
}
/**
* 删除规程主表
*
* @param specIds 主键串
*/
@Log(title = "规程主表", businessType = BusinessType.DELETE)
@DeleteMapping("/{specIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] specIds) {
return toAjax(wmsProcessSpecService.deleteWithValidByIds(Arrays.asList(specIds), true));
}
}

View File

@@ -0,0 +1,68 @@
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
*
* @author klp
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("wms_process_spec")
public class WmsProcessSpec extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "spec_id")
private Long specId;
/**
* 规程编号
*/
private String specCode;
/**
* 规程名称
*/
private String specName;
/**
* 类型(PROCESS/STANDARD)
*/
private String specType;
/**
* 产线ID
*/
private Long lineId;
/**
* 产品类型
*/
private String productType;
/**
* 是否启用0=否1=是)
*/
private Integer isEnabled;
/**
* 删除标志0=正常2=删除,与全局 logicDeleteValue 一致)
*/
@TableLogic
private Integer delFlag;
/**
* 备注
*/
private String remark;
}

View File

@@ -0,0 +1,65 @@
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
*
* @author klp
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WmsProcessSpecBo extends BaseEntity {
/**
* 主键
*/
@NotNull(message = "主键不能为空", groups = {EditGroup.class})
private Long specId;
/**
* 规程编号
*/
@NotBlank(message = "规程编号不能为空", groups = {AddGroup.class, EditGroup.class})
private String specCode;
/**
* 规程名称
*/
@NotBlank(message = "规程名称不能为空", groups = {AddGroup.class, EditGroup.class})
private String specName;
/**
* 类型(PROCESS/STANDARD)
*/
@NotBlank(message = "规程类型不能为空", groups = {AddGroup.class, EditGroup.class})
private String specType;
/**
* 产线ID
*/
@NotNull(message = "产线不能为空", groups = {AddGroup.class, EditGroup.class})
private Long lineId;
/**
* 产品类型
*/
private String productType;
/**
* 是否启用0=否1=是)
*/
private Integer isEnabled;
/**
* 备注
*/
private String remark;
}

View File

@@ -0,0 +1,82 @@
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
*
* @author klp
*/
@Data
@ExcelIgnoreUnannotated
public class WmsProcessSpecVo {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ExcelProperty(value = "主键")
private Long specId;
/**
* 规程编号
*/
@ExcelProperty(value = "规程编号")
private String specCode;
/**
* 规程名称
*/
@ExcelProperty(value = "规程名称")
private String specName;
/**
* 类型(PROCESS/STANDARD)
*/
@ExcelProperty(value = "规程类型")
private String specType;
/**
* 产线ID
*/
@ExcelProperty(value = "产线ID")
private Long lineId;
/**
* 产品类型
*/
@ExcelProperty(value = "产品类型")
private String productType;
/**
* 是否启用0=否1=是)
*/
@ExcelProperty(value = "是否启用")
private Integer isEnabled;
/**
* 备注
*/
@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;
}

View File

@@ -0,0 +1,14 @@
package com.klp.mapper;
import com.klp.common.core.mapper.BaseMapperPlus;
import com.klp.domain.WmsProcessSpec;
import com.klp.domain.vo.WmsProcessSpecVo;
/**
* 规程主表Mapper接口
*
* @author klp
*/
public interface WmsProcessSpecMapper extends BaseMapperPlus<WmsProcessSpecMapper, WmsProcessSpec, WmsProcessSpecVo> {
}

View File

@@ -0,0 +1,47 @@
package com.klp.service;
import com.klp.common.core.domain.PageQuery;
import com.klp.common.core.page.TableDataInfo;
import com.klp.domain.bo.WmsProcessSpecBo;
import com.klp.domain.vo.WmsProcessSpecVo;
import java.util.Collection;
import java.util.List;
/**
* 规程主表Service接口
*
* @author klp
*/
public interface IWmsProcessSpecService {
/**
* 查询规程主表
*/
WmsProcessSpecVo queryById(Long specId);
/**
* 查询规程主表分页列表
*/
TableDataInfo<WmsProcessSpecVo> queryPageList(WmsProcessSpecBo bo, PageQuery pageQuery);
/**
* 查询规程主表列表
*/
List<WmsProcessSpecVo> queryList(WmsProcessSpecBo bo);
/**
* 新增规程主表
*/
Boolean insertByBo(WmsProcessSpecBo bo);
/**
* 修改规程主表
*/
Boolean updateByBo(WmsProcessSpecBo bo);
/**
* 校验并批量删除规程主表
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@@ -0,0 +1,101 @@
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.WmsProcessSpec;
import com.klp.domain.bo.WmsProcessSpecBo;
import com.klp.domain.vo.WmsProcessSpecVo;
import com.klp.mapper.WmsProcessSpecMapper;
import com.klp.service.IWmsProcessSpecService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
/**
* 规程主表Service业务层处理
*
* @author klp
*/
@RequiredArgsConstructor
@Service
public class WmsProcessSpecServiceImpl implements IWmsProcessSpecService {
private final WmsProcessSpecMapper baseMapper;
@Override
public WmsProcessSpecVo queryById(Long specId) {
return baseMapper.selectVoById(specId);
}
@Override
public TableDataInfo<WmsProcessSpecVo> queryPageList(WmsProcessSpecBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<WmsProcessSpec> lqw = buildQueryWrapper(bo);
Page<WmsProcessSpecVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
@Override
public List<WmsProcessSpecVo> queryList(WmsProcessSpecBo bo) {
LambdaQueryWrapper<WmsProcessSpec> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<WmsProcessSpec> buildQueryWrapper(WmsProcessSpecBo bo) {
LambdaQueryWrapper<WmsProcessSpec> lqw = Wrappers.lambdaQuery();
lqw.eq(StringUtils.isNotBlank(bo.getSpecCode()), WmsProcessSpec::getSpecCode, bo.getSpecCode());
lqw.like(StringUtils.isNotBlank(bo.getSpecName()), WmsProcessSpec::getSpecName, bo.getSpecName());
lqw.eq(StringUtils.isNotBlank(bo.getSpecType()), WmsProcessSpec::getSpecType, bo.getSpecType());
lqw.eq(bo.getLineId() != null, WmsProcessSpec::getLineId, bo.getLineId());
lqw.like(StringUtils.isNotBlank(bo.getProductType()), WmsProcessSpec::getProductType, bo.getProductType());
lqw.eq(bo.getIsEnabled() != null, WmsProcessSpec::getIsEnabled, bo.getIsEnabled());
return lqw;
}
@Override
public Boolean insertByBo(WmsProcessSpecBo bo) {
WmsProcessSpec add = BeanUtil.toBean(bo, WmsProcessSpec.class);
if (add.getIsEnabled() == null) {
add.setIsEnabled(1);
}
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setSpecId(add.getSpecId());
}
return flag;
}
@Override
public Boolean updateByBo(WmsProcessSpecBo bo) {
WmsProcessSpec update = BeanUtil.toBean(bo, WmsProcessSpec.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
private void validEntityBeforeSave(WmsProcessSpec entity) {
LambdaQueryWrapper<WmsProcessSpec> lqw = Wrappers.lambdaQuery();
lqw.eq(WmsProcessSpec::getSpecCode, entity.getSpecCode());
if (entity.getSpecId() != null) {
lqw.ne(WmsProcessSpec::getSpecId, entity.getSpecId());
}
if (baseMapper.selectCount(lqw) > 0) {
throw new ServiceException("规程编号已存在");
}
}
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (Boolean.TRUE.equals(isValid)) {
// 任务3 可在此校验版本等从表数据
}
return baseMapper.deleteBatchIds(ids) > 0;
}
}

View File

@@ -0,0 +1,23 @@
<?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.WmsProcessSpecMapper">
<resultMap type="com.klp.domain.WmsProcessSpec" id="WmsProcessSpecResult">
<result property="specId" column="spec_id"/>
<result property="specCode" column="spec_code"/>
<result property="specName" column="spec_name"/>
<result property="specType" column="spec_type"/>
<result property="lineId" column="line_id"/>
<result property="productType" column="product_type"/>
<result property="isEnabled" column="is_enabled"/>
<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>